├── .vscode └── settings.json ├── README.md ├── firmware_joystick_interface ├── .gitignore ├── 10_joy_Multi.eww ├── Firmware_STM8_IoTNode │ ├── ClockUartLed.c │ ├── ClockUartLed.h │ ├── Firmware_STM8_IoTNode.dep │ ├── Firmware_STM8_IoTNode.ewd │ ├── Firmware_STM8_IoTNode.ewp │ ├── Firmware_STM8_IoTNode.ewt │ ├── commonTypes.h │ └── main.c └── raspi_joystick │ ├── SConstruct │ ├── joystick.cpp │ ├── joystick.hpp │ ├── main.cpp │ ├── serial.cpp │ └── serial.hpp ├── firmware_rf_dongle ├── firmware_rf_dongle.eww ├── rf_bridge │ ├── .gitignore │ ├── RTX_Error.txt │ ├── deviceType.h │ ├── main.c │ ├── nRF_Configuration.h │ ├── rf_bridge.dep │ ├── rf_bridge.ewd │ ├── rf_bridge.ewp │ ├── rf_bridge.ewt │ ├── rgb_config.h │ └── uart_config.h ├── rf_emulator │ ├── .gitignore │ ├── deviceType.h │ ├── main_rfemul.c │ ├── rf_emulator.dep │ ├── rf_emulator.ewd │ ├── rf_emulator.ewp │ ├── rf_emulator.ewt │ ├── serial_log.txt │ └── uart_config.h ├── rf_receiver_logger │ ├── .gitignore │ ├── deviceType.h │ ├── main_rflog.c │ ├── nRF_Configuration.h │ ├── nRF_Configuration.h.bak │ ├── rf_receiver_logger.dep │ ├── rf_receiver_logger.ewd │ ├── rf_receiver_logger.ewp │ ├── rf_receiver_logger.ewt │ ├── rgb_config.h │ ├── serial_log.txt │ ├── test_log_2.txt │ └── uart_config.h └── settings │ ├── firmware_rf_dongle.wsdt │ └── firmware_rf_dongle.wspos ├── firmware_rf_sensors_node ├── IoT_Mobile_Node.eww ├── debug.txt ├── measures.txt ├── pr01_Node_Alive │ ├── .gitignore │ ├── deviceType.h │ ├── main.c │ ├── nRF_Configuration.h │ ├── nRF_Configuration.h.bak │ ├── pr01_Node_Alive.dep │ ├── pr01_Node_Alive.ewd │ ├── pr01_Node_Alive.ewp │ ├── pr01_Node_Alive.ewt │ ├── uart_config.h │ ├── working_program.hex │ └── working_rom.hex ├── pr02_AmbientLight │ ├── deviceType.h │ ├── main.c │ ├── nRF_Configuration.h │ ├── pr02_AmbientLight.dep │ ├── pr02_AmbientLight.ewd │ ├── pr02_AmbientLight.ewp │ └── pr02_AmbientLight.ewt ├── pr03_PressHumTemp │ ├── .gitignore │ ├── deviceType.h │ ├── main.c │ ├── main.c.bak │ ├── nRF_Configuration.h │ ├── nRF_Configuration.h.bak │ ├── pr03_PressHumTemp.dep │ ├── pr03_PressHumTemp.ewd │ ├── pr03_PressHumTemp.ewp │ ├── pr03_PressHumTemp.ewt │ ├── serial_log.txt │ ├── uart_config.h │ ├── working_program.hex │ └── working_rom.hex ├── pr04_LightBroadcast │ ├── .gitignore │ ├── deviceType.h │ ├── main.c │ ├── nRF_Configuration.h │ ├── pr04_LightBroadcast.dep │ ├── pr04_LightBroadcast.ewd │ ├── pr04_LightBroadcast.ewp │ ├── pr04_LightBroadcast.ewt │ └── uart_config.h └── settings │ ├── IoT_Mobile_Node.wsdt │ └── IoT_Mobile_Node.wspos ├── libs ├── WS2812B.c ├── WS2812B.h ├── adc.c ├── adc.h ├── bme280.c ├── bme280.h ├── clock_led.c ├── clock_led.h ├── cmdutils.c ├── cmdutils.h ├── commonTypes.h ├── eeprom.h ├── i2c_stm8x.c ├── i2c_stm8x.h ├── irq_debug.c ├── light_dimmer_krida.c ├── light_dimmer_krida.h ├── max44009.c ├── max44009.h ├── nRF.c ├── nRF.h ├── nRF_IRQ_stm8x.c ├── nRF_IRQ_stm8x.h ├── nRF_RegText.c ├── nRF_RegText.h ├── nRF_SPI.c ├── nRF_SPI.h ├── nRF_Tx.c ├── nRF_Tx.h ├── pwm.c ├── pwm.h ├── rf_messages.c ├── rf_messages.h ├── rf_protocol.c ├── rf_protocol.h ├── spi_stm8x.c ├── spi_stm8x.h ├── temp_ds18b20.c ├── temp_ds18b20.h ├── timer2_pwm.c ├── timer2_pwm.h ├── uart.c ├── uart.h ├── uart_stm8x.c └── uart_stm8x.h ├── light_dimmer ├── README.md ├── firmware │ ├── current_watch │ │ ├── current_watch.ewd │ │ ├── current_watch.ewp │ │ ├── current_watch.ewt │ │ ├── deviceType.h │ │ └── main.c │ ├── dimmer_solo │ │ ├── deviceType.h │ │ ├── dimmer_solo.ewd │ │ ├── dimmer_solo.ewp │ │ ├── dimmer_solo.ewt │ │ ├── main.c │ │ └── settings │ │ │ └── dimmer_solo.Debug.cspy.bat │ ├── light_dimmer.eww │ ├── light_server │ │ ├── deviceType.h │ │ ├── light_server.ewd │ │ ├── light_server.ewp │ │ ├── light_server.ewt │ │ ├── main.c │ │ ├── script.txt │ │ ├── timers_config.h │ │ └── uart_config.h │ └── sync_counter │ │ ├── deviceType.h │ │ ├── main.c │ │ ├── sync_counter.ewd │ │ ├── sync_counter.ewp │ │ └── sync_counter.ewt └── log.txt ├── mesh_controller_interface ├── mesh_controller_interface.eww ├── rf_p2p_tester │ ├── .gitignore │ ├── deviceType.h │ ├── main_rfp2p.c │ ├── nRF_Configuration.h │ ├── rf_p2p_tester.dep │ ├── rf_p2p_tester.ewd │ ├── rf_p2p_tester.ewp │ ├── rf_p2p_tester.ewt │ ├── rgb_config.h │ ├── serial_log.txt │ └── uart_config.h ├── rf_tester │ ├── .gitignore │ ├── deviceType.h │ ├── main_rfTester.c │ ├── nRF_Configuration.h │ ├── rf_tester.dep │ ├── rf_tester.ewd │ ├── rf_tester.ewp │ ├── rf_tester.ewt │ ├── serial_log.txt │ ├── test_logs │ │ ├── Node0x09.txt │ │ └── Node0x0C.txt │ └── uart_config.h ├── rfmaster │ ├── .gitignore │ ├── deviceType.h │ ├── main.c │ ├── main_config.h │ ├── nRF_Configuration.h │ ├── rfmaster.dep │ ├── rfmaster.ewd │ ├── rfmaster.ewp │ ├── rfmaster.ewt │ ├── script.txt │ └── uart_config.h ├── settings │ ├── mesh_controller_interface.wsdt │ └── mesh_controller_interface.wspos └── uarttester │ ├── deviceType.h │ ├── main.c │ ├── timers_config.h │ ├── uart_config.h │ ├── uarttester.dep │ ├── uarttester.ewd │ ├── uarttester.ewp │ └── uarttester.ewt ├── rgb_leds ├── hello_rgb │ ├── .gitignore │ ├── deviceType.h │ ├── hello_rgb.dep │ ├── hello_rgb.ewd │ ├── hello_rgb.ewp │ ├── hello_rgb.ewt │ ├── mainRGB.c │ ├── rgb_config.h │ └── uart_config.h ├── rgb_led_bar │ ├── .gitignore │ ├── deviceType.h │ ├── mainBAR.c │ ├── rgb_config.h │ ├── rgb_led_bar.dep │ ├── rgb_led_bar.ewd │ ├── rgb_led_bar.ewp │ ├── rgb_led_bar.ewt │ └── uart_config.h ├── rgb_leds.eww ├── rgb_leds_rf │ ├── .gitignore │ ├── build.bat │ ├── deviceType.h │ ├── iar.bat │ ├── main_LedRf.c │ ├── nRF_Configuration.h │ ├── rgb_config.h │ ├── rgb_leds_rf.dep │ ├── rgb_leds_rf.ewd │ ├── rgb_leds_rf.ewp │ ├── rgb_leds_rf.ewt │ └── uart_config.h ├── rgb_rf_commander │ ├── .gitignore │ ├── deviceType.h │ ├── main_RfCommand.c │ ├── nRF_Configuration.h │ ├── rgb_config.h │ ├── rgb_rf_commander.dep │ ├── rgb_rf_commander.ewd │ ├── rgb_rf_commander.ewp │ ├── rgb_rf_commander.ewt │ └── uart_config.h └── settings │ ├── rgb_leds.wsdt │ └── rgb_leds.wspos ├── smartio_firmware ├── 01_EEPROM_To_Output │ ├── ClockUartLed.c │ ├── ClockUartLed.h │ └── main.c ├── 02_EESeqence_Console │ ├── ClockUartLed.c │ ├── ClockUartLed.h │ ├── main.c │ ├── readme.md │ └── sequenceSample.hex.txt ├── 03_io_serial_server │ ├── .gitignore │ ├── 03_io_serial_server.dep │ ├── 03_io_serial_server.ewd │ ├── 03_io_serial_server.ewp │ ├── 03_io_serial_server.ewt │ ├── deviceType.h │ ├── main.c │ ├── timers_config.h │ └── uart_config.h ├── README.md ├── STM8_IO_Interface.url ├── settings │ ├── smartio.wsdt │ └── smartio.wspos └── smartio.eww ├── ws01_WeatherLogger ├── pr00_LibraryCommon │ ├── ClockUartLed.c │ ├── ClockUartLed.h │ ├── commonTypes.h │ ├── nRF_IRQ.c │ ├── nRF_IRQ.h │ ├── nRF_LowLevel.c │ ├── nRF_LowLevel.h │ ├── nRF_Modes.c │ ├── nRF_Modes.h │ ├── nRF_RegText.c │ ├── nRF_RegText.h │ ├── nRF_SPI.c │ ├── nRF_SPI.h │ ├── nRF_Tx.c │ ├── nRF_Tx.h │ ├── temp_ds18b20.c │ └── temp_ds18b20.h ├── pr01_Temperature_RF_Sender │ ├── .gitignore │ ├── 01_Temperature_RF_Sender.dep │ ├── 01_Temperature_RF_Sender.ewd │ ├── 01_Temperature_RF_Sender.ewp │ ├── 01_Temperature_RF_Sender.ewt │ ├── mainTx.c │ └── nRF_Configuration.h ├── pr02_RF_ReceiveLogger │ ├── .gitignore │ ├── 02_RF_ReceiveLogger.dep │ ├── 02_RF_ReceiveLogger.ewd │ ├── 02_RF_ReceiveLogger.ewp │ ├── 02_RF_ReceiveLogger.ewt │ ├── mainRx.c │ └── nRF_Configuration.h ├── pr03_RFSender_LowPower │ ├── .gitignore │ ├── Batteries Log.txt │ ├── mainTxLP.c │ ├── nRF_Configuration.h │ ├── pr03_RFSender_LowPower.dep │ ├── pr03_RFSender_LowPower.ewd │ ├── pr03_RFSender_LowPower.ewp │ └── pr03_RFSender_LowPower.ewt ├── pr04_RF_Light_Temperature │ ├── .gitignore │ ├── i2c_m.c │ ├── i2c_m.h │ ├── mainTx.c │ ├── nRF_Configuration.h │ ├── pr04_RF_Light_Temperature.ewd │ ├── pr04_RF_Light_Temperature.ewp │ └── pr04_RF_Light_Temperature.ewt ├── settings │ ├── ws01_WeatherLogger.wsdt │ └── ws01_WeatherLogger.wspos └── ws01_WeatherLogger.eww └── ws03_RF_Sync ├── pr00_LibraryCommon ├── ClockUartLed.c ├── ClockUartLed.h ├── WS2812B.c ├── WS2812B.h ├── commonTypes.h ├── nRF_IRQ.c ├── nRF_IRQ.h ├── nRF_LowLevel.c ├── nRF_LowLevel.h ├── nRF_Modes.c ├── nRF_Modes.h ├── nRF_RegText.c ├── nRF_RegText.h ├── nRF_SPI.c ├── nRF_SPI.h ├── nRF_Tx.c ├── nRF_Tx.h ├── temp_ds18b20.c └── temp_ds18b20.h ├── pr01_RF_Client ├── mainClient.c ├── nRF_Configuration.h ├── pr01_RF_Client.dep ├── pr01_RF_Client.ewd ├── pr01_RF_Client.ewp ├── pr01_RF_Client.ewt └── settings │ ├── pr01_RF_Client.Debug.cspy.bat │ ├── pr01_RF_Client.dbgdt │ └── pr01_RF_Client.dni ├── pr02_RF_Server ├── mainServer.c ├── nRF_Configuration.h ├── pr02_RF_Server.dep ├── pr02_RF_Server.ewd ├── pr02_RF_Server.ewp ├── pr02_RF_Server.ewt └── settings │ ├── pr02_RF_Server.Debug.cspy.bat │ ├── pr02_RF_Server.dbgdt │ └── pr02_RF_Server.dni ├── pr03_RF_Alive ├── deviceType.h ├── mainServer.c ├── nRF_Configuration.h ├── pr03_RF_Alive.ewd ├── pr03_RF_Alive.ewp └── pr03_RF_Alive.ewt └── ws03_RF_Sync.eww /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.associations": { 3 | "xlocale": "c", 4 | "nrf_tx.h": "c", 5 | "uart.h": "c" 6 | } 7 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # IoT_STM8 2 | for old deprecated projects history 3 | taken out from https://github.com/wassfila/IoT_Frameworks/ a8d40472c15fb9d84360f2dcc34aef2bf5e036aa 4 | Moved directories, so build include path to be adapted 5 | -------------------------------------------------------------------------------- /firmware_joystick_interface/.gitignore: -------------------------------------------------------------------------------- 1 | Debug/ 2 | settings/ 3 | -------------------------------------------------------------------------------- /firmware_joystick_interface/10_joy_Multi.eww: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | $WS_DIR$\Firmware_STM8_IoTNode\Firmware_STM8_IoTNode.ewp 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /firmware_joystick_interface/Firmware_STM8_IoTNode/ClockUartLed.h: -------------------------------------------------------------------------------- 1 | /** @file ClockUartLed.h 2 | * 3 | * @author Wassim FILALI taken over from http://blog.mark-stevens.co.uk/ 4 | * 5 | * @compiler IAR STM8 6 | * 7 | * 8 | * $Date: 20.09.2015 9 | * $Revision: 10 | * 11 | */ 12 | 13 | 14 | #define delay_1us(); delay(0); 15 | 16 | #define delay_10us(); delay(18); 17 | 18 | #define delay_50us(); delay(98); 19 | 20 | #define delay_100us(); delay(198); 21 | 22 | #define delay_1ms(); delay(1998); 23 | 24 | #define delay_10ms(); delay(19998); 25 | 26 | 27 | void InitialiseUART(); 28 | 29 | void UARTPrintf(char const *message); 30 | 31 | void UARTPrintfLn(char const *message); 32 | 33 | void UARTPrintfHex(unsigned char val); 34 | 35 | void UARTPrintfHexTable(unsigned char *pval,unsigned char length); 36 | 37 | void UARTPrintfHexLn(unsigned char val); 38 | 39 | void UARTPrintf_sint(signed int num); 40 | 41 | void UARTPrintf_uint(unsigned int num); 42 | 43 | void InitialiseSystemClock(); 44 | 45 | void delay(unsigned int n); 46 | 47 | void delay_ms(unsigned int n); 48 | 49 | 50 | // L E D 51 | void Initialise_TestLed_GPIO_B5(); 52 | void Test_Led_On(); 53 | void Test_Led_Off(); 54 | 55 | -------------------------------------------------------------------------------- /firmware_joystick_interface/Firmware_STM8_IoTNode/Firmware_STM8_IoTNode.dep: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2 5 | 3149452703 6 | 7 | Debug 8 | 9 | $TOOLKIT_DIR$\inc\io_macros.h 10 | $TOOLKIT_DIR$\inc\c\intrinsics.h 11 | $TOOLKIT_DIR$\inc\iostm8s103f3.h 12 | $PROJ_DIR$\Debug\Obj\ClockUartLed.o 13 | $PROJ_DIR$\Debug\Obj\main.o 14 | $PROJ_DIR$\Debug\Exe\Firmware_STM8_IoTNode.out 15 | $PROJ_DIR$\Debug\Obj\Firmware_STM8_IoTNode.pbd 16 | $PROJ_DIR$\Debug\Obj\main.pbi 17 | $PROJ_DIR$\Debug\Obj\ClockUartLed.pbi 18 | $PROJ_DIR$\ClockUartLed.c 19 | $PROJ_DIR$\ClockUartLed.h 20 | $PROJ_DIR$\main.c 21 | $PROJ_DIR$\commonTypes.h 22 | $TOOLKIT_DIR$\lib\dlstm8smn.a 23 | $TOOLKIT_DIR$\config\lnkstm8s103f3.icf 24 | $TOOLKIT_DIR$\lib\dbgstm8smd.a 25 | 26 | 27 | [ROOT_NODE] 28 | 29 | 30 | ILINK 31 | 5 32 | 33 | 34 | 35 | 36 | $PROJ_DIR$\Debug\Exe\Firmware_STM8_IoTNode.out 37 | 38 | 39 | ILINK 40 | 14 3 4 13 15 41 | 42 | 43 | 44 | 45 | $PROJ_DIR$\ClockUartLed.c 46 | 47 | 48 | BICOMP 49 | 8 50 | 51 | 52 | ICCSTM8 53 | 3 54 | 55 | 56 | 57 | 58 | BICOMP 59 | 0 2 10 60 | 61 | 62 | ICCSTM8 63 | 10 2 0 64 | 65 | 66 | 67 | 68 | $PROJ_DIR$\main.c 69 | 70 | 71 | BICOMP 72 | 7 73 | 74 | 75 | ICCSTM8 76 | 4 77 | 78 | 79 | 80 | 81 | BICOMP 82 | 0 10 2 12 1 83 | 84 | 85 | ICCSTM8 86 | 1 2 0 10 12 87 | 88 | 89 | 90 | 91 | 92 | Release 93 | 94 | 95 | [MULTI_TOOL] 96 | ILINK 97 | 98 | 99 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /firmware_joystick_interface/Firmware_STM8_IoTNode/Firmware_STM8_IoTNode.ewt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2 5 | 6 | Debug 7 | 8 | STM8 9 | 10 | 1 11 | 12 | 13 | Release 14 | 15 | STM8 16 | 17 | 0 18 | 19 | 20 | $PROJ_DIR$\ClockUartLed.c 21 | 22 | 23 | $PROJ_DIR$\ClockUartLed.h 24 | 25 | 26 | $PROJ_DIR$\commonTypes.h 27 | 28 | 29 | $PROJ_DIR$\main.c 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /firmware_joystick_interface/Firmware_STM8_IoTNode/commonTypes.h: -------------------------------------------------------------------------------- 1 | /** @file nRF_Modes.h 2 | * 3 | * @author Wassim FILALI 4 | * 5 | * 6 | * @compiler IAR STM8 7 | * 8 | * 9 | * $Date: 13.12.2015 10 | * $Revision: 11 | * 12 | */ 13 | 14 | // UINT type definition 15 | #ifndef _UINT_DEF_ 16 | #define _UINT_DEF_ 17 | typedef unsigned int UINT; 18 | #endif 19 | 20 | // BYTE type definition 21 | #ifndef _BYTE_DEF_ 22 | #define _BYTE_DEF_ 23 | typedef unsigned char BYTE; 24 | #endif 25 | 26 | 27 | #ifndef E_OK 28 | #define E_OK 0x00 29 | #endif 30 | 31 | #ifndef E_Already_Initialised 32 | #define E_Already_Initialised 0x01 33 | #endif 34 | 35 | -------------------------------------------------------------------------------- /firmware_joystick_interface/raspi_joystick/SConstruct: -------------------------------------------------------------------------------- 1 | # - Glob() adds all the files with the extension to the list 2 | # - CPPPATH define the path where to look for source files which have include dependendcies 3 | # so that when these include files change, a recompilation of the source file is triggered 4 | # CPPPATH = ['include', '/home/project/inc'] 5 | Program('joy', Glob('*.cpp'),CPPPATH = '.') 6 | -------------------------------------------------------------------------------- /firmware_joystick_interface/raspi_joystick/joystick.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | author : wassfila 3 | date : 16.07.2016 4 | 5 | Joystick cpp wrapper 6 | 7 | 8 | */ 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | #define JOY_MAX_AXIS 20 15 | #define JOY_MAX_BUTTONS 20 16 | 17 | 18 | class JAxis 19 | { 20 | public: 21 | int i_value; 22 | bool update; 23 | int time; 24 | public: 25 | JAxis(); 26 | bool isUpdated(); 27 | float getValue(); 28 | }; 29 | 30 | class JButton 31 | { 32 | public: 33 | bool b_value; 34 | bool update; 35 | int time; 36 | public: 37 | JButton(); 38 | bool isUpdated(); 39 | bool getState(); 40 | std::string getStateText(); 41 | }; 42 | 43 | class Joystick 44 | { 45 | private: 46 | int fd; 47 | struct js_event jse; 48 | std::vector Axes; 49 | std::vector Buttons; 50 | public: 51 | std::string Name; 52 | public: 53 | void start(std::string device); 54 | void info(); 55 | void printUpdates(); 56 | bool update(); 57 | void consumeAll(); 58 | JAxis &getAxis(int axisId); 59 | 60 | }; 61 | 62 | -------------------------------------------------------------------------------- /firmware_joystick_interface/raspi_joystick/main.cpp: -------------------------------------------------------------------------------- 1 | 2 | //for usleep 3 | #include 4 | //for printf 5 | #include 6 | //for stdout 7 | #include 8 | 9 | //for abs 10 | #include 11 | 12 | #include "joystick.hpp" 13 | #include "serial.hpp" 14 | 15 | #define RESET "\033[0m" 16 | #define BLACK "\033[30m" /* Black */ 17 | #define RED "\033[31m" /* Red */ 18 | #define GREEN "\033[32m" /* Green */ 19 | #define YELLOW "\033[33m" /* Yellow */ 20 | #define BLUE "\033[34m" /* Blue */ 21 | #define MAGENTA "\033[35m" /* Magenta */ 22 | #define CYAN "\033[36m" /* Cyan */ 23 | #define WHITE "\033[37m" /* White */ 24 | #define BOLDBLACK "\033[1m\033[30m" /* Bold Black */ 25 | #define BOLDRED "\033[1m\033[31m" /* Bold Red */ 26 | #define BOLDGREEN "\033[1m\033[32m" /* Bold Green */ 27 | #define BOLDYELLOW "\033[1m\033[33m" /* Bold Yellow */ 28 | #define BOLDBLUE "\033[1m\033[34m" /* Bold Blue */ 29 | #define BOLDMAGENTA "\033[1m\033[35m" /* Bold Magenta */ 30 | #define BOLDCYAN "\033[1m\033[36m" /* Bold Cyan */ 31 | #define BOLDWHITE "\033[1m\033[37m" /* Bold White */ 32 | 33 | #define CLEAR "\033[2J" // clear screen escape code 34 | 35 | //Axis 5 : 1520 - 1950 36 | 37 | void MapAxis(JAxis &axis,char c,int pos1,int pos2,Serial&ser) 38 | { 39 | if(axis.isUpdated()) 40 | { 41 | const int s_path = pos2 - pos1; 42 | int val = pos1 + s_path/2 + axis.getValue()*s_path/2; 43 | std::cout << "(" << val << ")"; 44 | char data[4]; 45 | data[0] = 'H'; 46 | data[3] = c; 47 | data[1] = val / 256; 48 | data[2] = val % 256; 49 | ser.send(data,4); 50 | } 51 | } 52 | 53 | int main() 54 | { 55 | Joystick joy; 56 | Serial ser; 57 | 58 | joy.start("/dev/input/js0"); 59 | 60 | ser.start("/dev/ttyUSB0"); 61 | 62 | 63 | //std::cout << MAGENTA << "Colored " << CYAN << "Text" << RESET << std::endl; 64 | 65 | while (1) 66 | { 67 | std::cout << CYAN; 68 | //Update the Joystick input 69 | if(joy.update())//multiple events will be filtered, only last would appear afterwards 70 | { 71 | joy.printUpdates(); 72 | } 73 | 74 | MapAxis(joy.getAxis(5),'1',1050,1950,ser);//Up 75 | MapAxis(joy.getAxis(2),'2',1050,1950,ser);//Side 76 | MapAxis(joy.getAxis(1),'3',500,2500,ser);//servo 77 | 78 | joy.consumeAll(); 79 | 80 | std::cout << RESET; 81 | //display Received log 82 | if(ser.update()) 83 | { 84 | ser.print(); 85 | } 86 | usleep (10000); 87 | 88 | } 89 | 90 | return 0; 91 | } 92 | -------------------------------------------------------------------------------- /firmware_joystick_interface/raspi_joystick/serial.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | author : wassfila 3 | date : 16.07.2016 4 | 5 | serial port cpp wrapper 6 | 7 | 8 | */ 9 | 10 | #include 11 | #include 12 | 13 | class Serial 14 | { 15 | private: 16 | int fd; 17 | char buf [100]; 18 | int n; 19 | public: 20 | std::string Name; 21 | public: 22 | void start(std::string device); 23 | bool update(); 24 | void print(); 25 | void send(char* buffer,int size); 26 | 27 | }; 28 | 29 | -------------------------------------------------------------------------------- /firmware_rf_dongle/firmware_rf_dongle.eww: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | $WS_DIR$\rf_bridge\rf_bridge.ewp 6 | 7 | 8 | $WS_DIR$\rf_emulator\rf_emulator.ewp 9 | 10 | 11 | $WS_DIR$\rf_receiver_logger\rf_receiver_logger.ewp 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /firmware_rf_dongle/rf_bridge/.gitignore: -------------------------------------------------------------------------------- 1 | Debug/ 2 | settings/ 3 | -------------------------------------------------------------------------------- /firmware_rf_dongle/rf_bridge/deviceType.h: -------------------------------------------------------------------------------- 1 | #define DEVICE_STM8S 1 2 | -------------------------------------------------------------------------------- /firmware_rf_dongle/rf_bridge/rgb_config.h: -------------------------------------------------------------------------------- 1 | /** @file rgb_config.h 2 | * 3 | * @author Wassim FILALI 4 | * 5 | * 6 | * 7 | * $Date: 27.02.2017 8 | * $Revision: 9 | * 10 | */ 11 | #ifndef _RGB_CONFIG_ 12 | #define _RGB_CONFIG_ 13 | 14 | //NB_LEDS : Number of LED to be supported which would derive the size of the memory 15 | // to be allocated Table[NB_LEDS*3] as that table will contain {R,G,B} Bytes per LED 16 | //1 - 255 : this parameter has for limit the size of the RAM and the 8bit counter => 255 17 | //the value of 256 == 0 was not tested 18 | //255 => 75% of RAM 19 | #define NB_LEDS 1 20 | 21 | 22 | 23 | //RGBLedPIN_A : the Port A pin number to be used, supported values for the Fixed Node v2 Target Board : 24 | // 2 => Not recommended as not High speed 25 | // 3 => Recommend with High speed setting 3.3 V driving 5V TTL input 26 | // recommended settings Vin min = 0.7Vdd ; 5V => 3.5V so 3.3 is not enough, not recommended but working 27 | #define RGBLedPIN_A 3 28 | 29 | #endif /*_RGB_CONFIG_*/ 30 | -------------------------------------------------------------------------------- /firmware_rf_dongle/rf_bridge/uart_config.h: -------------------------------------------------------------------------------- 1 | /** @file uart_config.h 2 | * 3 | * @author Wassim FILALI 4 | * 5 | * 6 | * 7 | * $Date: 12.11.2016 8 | * $Revision: 9 | * 10 | */ 11 | #ifndef _UART_CONFIG_ 12 | #define _UART_CONFIG_ 13 | 14 | //UART_BAUD_RATE possible values 115200 9600 15 | #define UART_BAUD_RATE 115200 16 | 17 | //----------------------------------- Interruptions --------------------------------------- 18 | //Flag: UART_USE_RX_INETRRUPT 19 | // 1 : Enabled 20 | // declares the IRQ and requires teh user to declare a uart_callback() function 21 | 22 | #define UART_USE_RX_INETRRUPT 0 23 | 24 | //Flag: UART_CALLBACK_POLLING 25 | // 1 : Enabled => 'uart_rx_user_callback_pending' has to be polled 26 | // consume 'uart_BUFFER' with 'uart_index', 27 | // acknowledge with 'uart_rx_user_callback_performed' 28 | // 0 : INTERRUPT => The 'uart_rx_user_callback()' will be called from the uart interrupt context 29 | // Flags dependencies 30 | // '#define UART_USE_RX_INETRRUPT 1' has to be set to 1 31 | #define UART_CALLBACK_POLLING 0 32 | 33 | 34 | #define UART_FRAME_SIZE 31 35 | 36 | //the terminal sends 13 37 | #define UART_EOL_C 13 38 | 39 | //Flag: UART_Through_RF_Delay 40 | //1 : Enabled this delay is added after every end of line to allow proper transmission of messages through radio 41 | //0 : Disabled, normal behaviour 42 | #define UART_Through_RF_Delay 0 43 | 44 | #endif /*_UART_CONFIG_*/ 45 | -------------------------------------------------------------------------------- /firmware_rf_dongle/rf_emulator/.gitignore: -------------------------------------------------------------------------------- 1 | Debug/ 2 | settings/ 3 | -------------------------------------------------------------------------------- /firmware_rf_dongle/rf_emulator/deviceType.h: -------------------------------------------------------------------------------- 1 | #define DEVICE_STM8S 1 2 | -------------------------------------------------------------------------------- /firmware_rf_dongle/rf_emulator/main_rfemul.c: -------------------------------------------------------------------------------- 1 | /* 2 | main.c for 3 | IoT_Frameworks 4 | \sensors_logger 5 | \firmware_rf_dongle 6 | \rf_receiver_logger 7 | 8 | started 9 | refactored 29.10.2016 10 | 11 | */ 12 | 13 | //Test Led is Port B Pin 5 14 | 15 | 16 | #include "uart.h" 17 | #include "clock_led.h" 18 | 19 | /* 20 | 21 | NodeId:7;BME280: 0x53 EB 00 7C 77 00 70 08 22 | 23 | NodeId:6;BME280: 0x56 33 00 7F 82 00 62 34 24 | */ 25 | 26 | void emulate_sensors_log(int count) 27 | { 28 | count*=8;//0 -> 2040 29 | 30 | //printf_ln("NodeId:77;BME280: 0x53 EB 00 7C 77 00 70 08"); 31 | delay_ms(100); 32 | 33 | printf("NodeId:77,Light: "); 34 | printf_uint(count); 35 | printf_eol(); 36 | delay_ms(100); 37 | 38 | delay_ms(1000); 39 | //printf_ln("NodeId:6;BME280: 0x56 33 00 7F 82 00 62 34"); 40 | delay_ms(100); 41 | 42 | printf("NodeId:66,Light: "); 43 | printf_uint(count); 44 | printf_eol(); 45 | delay_ms(100); 46 | } 47 | 48 | 49 | int main( void ) 50 | { 51 | 52 | BYTE AliveActiveCounter = 0; 53 | 54 | InitialiseSystemClock(); 55 | 56 | Initialise_TestLed_GPIO_B5(); 57 | 58 | Test_Led_Off(); 59 | 60 | uart_init(); 61 | 62 | printf("\r\n__________________________________________________\n\r"); 63 | printf("sensors_logger\\firmware_rf_dongle\\rf_emulator\\\n\r"); 64 | 65 | while (1) 66 | { 67 | AliveActiveCounter++;//Why are you counting ? 68 | 69 | Test_Led_Off(); 70 | delay_ms(3900); 71 | 72 | Test_Led_On(); 73 | delay_ms(100); 74 | emulate_sensors_log(AliveActiveCounter); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /firmware_rf_dongle/rf_emulator/rf_emulator.ewt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2 5 | 6 | Debug 7 | 8 | STM8 9 | 10 | 1 11 | 12 | 13 | Release 14 | 15 | STM8 16 | 17 | 0 18 | 19 | 20 | libs 21 | 22 | $PROJ_DIR$\..\..\..\libs\clock_led.c 23 | 24 | 25 | $PROJ_DIR$\..\..\..\libs\clock_led.h 26 | 27 | 28 | $PROJ_DIR$\..\..\..\libs\uart.c 29 | 30 | 31 | $PROJ_DIR$\..\..\..\libs\uart.h 32 | 33 | 34 | $PROJ_DIR$\..\..\..\libs\uart_stm8x.c 35 | 36 | 37 | $PROJ_DIR$\..\..\..\libs\uart_stm8x.h 38 | 39 | 40 | 41 | $PROJ_DIR$\deviceType.h 42 | 43 | 44 | $PROJ_DIR$\main_rfemul.c 45 | 46 | 47 | $PROJ_DIR$\uart_config.h 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /firmware_rf_dongle/rf_emulator/serial_log.txt: -------------------------------------------------------------------------------- 1 | rfId:0xE2;Error:dataSize not 11 but 10 2 | rfId:0xE2;Error:CRC 3 | __________________________________________________ 4 | 5 | sensors_logger\firmware_rf_dongle\rf_receiver_logger\ 6 | 7 | 8 | __________________________________________________ 9 | 10 | sensors_logger\firmware_rf_dongle\rf_receiver_logger\ 11 | 12 | rfId:0xE2;Error:CRC 13 | NodeId:6,is:Alive 14 | 15 | __________________________________________________ 16 | 17 | sensors_logger\firmware_rf_dongle\rf_receiver_logger\ 18 | 19 | NodeId:4,is:Alive 20 | NodeId:7;BME280: 0x07 53 F5 00 7E F6 00 73 EB 21 | NodeId:7;BME280: 0x07 53 F7 00 7E F7 00 73 07 22 | NodeId:7;BME280: 0x07 53 F9 00 7E F5 00 73 BB 23 | NodeId:6,is:Alive 24 | NodeId:6,Light: 1701 25 | NodeId:4,is:Alive 26 | NodeId:7;BME280: 0x07 53 F7 00 7E F7 00 73 6C 27 | NodeId:7;BME280: 0x07 53 F3 00 7E F1 00 74 3F 28 | NodeId:6,is:Alive 29 | NodeId:6,Light: 1700 30 | NodeId:7;BME280: 0x07 53 F6 00 7E ED 00 73 70 31 | NodeId:4,is:Alive 32 | NodeId:7;BME280: 0x07 53 F5 00 7E EF 00 74 44 33 | -------------------------------------------------------------------------------- /firmware_rf_dongle/rf_emulator/uart_config.h: -------------------------------------------------------------------------------- 1 | /** @file uart_config.h 2 | * 3 | * @author Wassim FILALI 4 | * 5 | * 6 | * 7 | * $Date: 12.11.2016 8 | * $Revision: 9 | * 10 | */ 11 | #ifndef _UART_CONFIG_ 12 | #define _UART_CONFIG_ 13 | 14 | //UART_BAUD_RATE possible values 115200 9600 15 | #define UART_BAUD_RATE 115200 16 | 17 | 18 | //----------------------------------- Interruptions --------------------------------------- 19 | //Flag: UART_USE_RX_INETRRUPT 20 | // 1 : Enabled 21 | // declares the IRQ and requires teh user to declare a uart_callback() function 22 | 23 | #define UART_USE_RX_INETRRUPT 0 24 | 25 | //Flag: UART_CALLBACK_POLLING 26 | // 1 : Enabled => 'uart_rx_user_callback_pending' has to be polled 27 | // consume 'uart_BUFFER' with 'uart_index', 28 | // acknowledge with 'uart_rx_user_callback_performed' 29 | // 0 : INTERRUPT => The 'uart_rx_user_callback()' will be called from the uart interrupt context 30 | // Flags dependencies 31 | // '#define UART_USE_RX_INETRRUPT 1' has to be set to 1 32 | #define UART_CALLBACK_POLLING 0 33 | 34 | 35 | #define UART_FRAME_SIZE 31 36 | 37 | //the terminal sends 13 38 | #define UART_EOL_C 13 39 | 40 | //Flag: UART_Through_RF_Delay 41 | //1 : Enabled this delay is added after every end of line to allow proper transmission of messages through radio 42 | //0 : Disabled, normal behaviour 43 | #define UART_Through_RF_Delay 0 44 | 45 | #endif /*_UART_CONFIG_*/ 46 | -------------------------------------------------------------------------------- /firmware_rf_dongle/rf_receiver_logger/.gitignore: -------------------------------------------------------------------------------- 1 | Debug/ 2 | settings/ 3 | -------------------------------------------------------------------------------- /firmware_rf_dongle/rf_receiver_logger/deviceType.h: -------------------------------------------------------------------------------- 1 | #define DEVICE_STM8S 1 2 | -------------------------------------------------------------------------------- /firmware_rf_dongle/rf_receiver_logger/rgb_config.h: -------------------------------------------------------------------------------- 1 | /** @file rgb_config.h 2 | * 3 | * @author Wassim FILALI 4 | * 5 | * 6 | * 7 | * $Date: 27.02.2017 8 | * $Revision: 9 | * 10 | */ 11 | #ifndef _RGB_CONFIG_ 12 | #define _RGB_CONFIG_ 13 | 14 | //NB_LEDS : Number of LED to be supported which would derive the size of the memory 15 | // to be allocated Table[NB_LEDS*3] as that table will contain {R,G,B} Bytes per LED 16 | //1 - 255 : this parameter has for limit the size of the RAM and the 8bit counter => 255 17 | //the value of 256 == 0 was not tested 18 | //255 => 75% of RAM 19 | #define NB_LEDS 1 20 | 21 | 22 | 23 | //RGBLedPIN_A : the Port A pin number to be used, supported values for the Fixed Node v2 Target Board : 24 | // 2 => Not recommended as not High speed 25 | // 3 => Recommend with High speed setting 3.3 V driving 5V TTL input 26 | // recommended settings Vin min = 0.7Vdd ; 5V => 3.5V so 3.3 is not enough, not recommended but working 27 | #define RGBLedPIN_A 3 28 | 29 | #endif /*_RGB_CONFIG_*/ 30 | -------------------------------------------------------------------------------- /firmware_rf_dongle/rf_receiver_logger/serial_log.txt: -------------------------------------------------------------------------------- 1 | rfId:0xE2;Error:dataSize not 11 but 10 2 | rfId:0xE2;Error:CRC 3 | __________________________________________________ 4 | 5 | sensors_logger\firmware_rf_dongle\rf_receiver_logger\ 6 | 7 | 8 | __________________________________________________ 9 | 10 | sensors_logger\firmware_rf_dongle\rf_receiver_logger\ 11 | 12 | rfId:0xE2;Error:CRC 13 | NodeId:6,is:Alive 14 | 15 | __________________________________________________ 16 | 17 | sensors_logger\firmware_rf_dongle\rf_receiver_logger\ 18 | 19 | NodeId:4,is:Alive 20 | NodeId:7;BME280: 0x07 53 F5 00 7E F6 00 73 EB 21 | NodeId:7;BME280: 0x07 53 F7 00 7E F7 00 73 07 22 | NodeId:7;BME280: 0x07 53 F9 00 7E F5 00 73 BB 23 | NodeId:6,is:Alive 24 | NodeId:6,Light: 1701 25 | NodeId:4,is:Alive 26 | NodeId:7;BME280: 0x07 53 F7 00 7E F7 00 73 6C 27 | NodeId:7;BME280: 0x07 53 F3 00 7E F1 00 74 3F 28 | NodeId:6,is:Alive 29 | NodeId:6,Light: 1700 30 | NodeId:7;BME280: 0x07 53 F6 00 7E ED 00 73 70 31 | NodeId:4,is:Alive 32 | NodeId:7;BME280: 0x07 53 F5 00 7E EF 00 74 44 33 | -------------------------------------------------------------------------------- /firmware_rf_dongle/rf_receiver_logger/test_log_2.txt: -------------------------------------------------------------------------------- 1 | __________________________________________________ 2 | 3 | STATUS: 0x0E : No Data Ready i; No Data Sent i; No Max Ret i; Rx Fifo Empty ; Available TX Fifo Locations; 4 | CONFIG: 0x31 : RX IRQ Active; TX IRQ Masked; Max RT IRQ Masked; CRC Disabled; CRC 1 Bytes; Power Down; P RX Mode; 5 | ChipEnable Low 6 | Channel 2 selected : 2402 MHz 7 | Address Width : 5 bytes 8 | Rx Address P0: 0xE7 9 | Tx Address : 0xE7 10 | __________________________________________________ 11 | 12 | NodeId:14;is:Alive 13 | RTX:0;rx crc Fail : 0x03 F5 0E 7D FA 14 | Node0x0C> 15 | NodeId:12;SetRGB_to:3;R:1;G:1;B:0;Success:1 16 | NodeId:6;BME280: 0x57 45 00 80 6B 00 67 57 17 | RTX:0;rx crc Fail : 0x0B E2 06 57 45 00 80 6B 00 67 57 82 3A 18 | Node0x0C> 19 | rx crc Fail : 0x04 59 02 0C 4C 7B 20 | NodeId:12;SetRGB_to:18;R:1;G:1;B:0;Success:2 21 | RTX:0;rx crc Fail : 0x0B E2 10 4A E9 00 7B CD 00 6B B8 6E AB 22 | NodeId:14;is:Alive 23 | RTX:0;rx crc Fail : 0x03 F5 0E 7B EF 24 | rx crc Fail : 0x05 BA 06 48 0A B4 19 25 | RTX:0;NodeId:6;Light:1162 26 | NodeId:14;is:Alive 27 | RTX:0;rx crc Fail : 0x03 F5 0E 7F 5F 28 | NodeId:14;is:Alive 29 | RTX:0;rx crc Fail : 0x03 F5 0E 7D 93 30 | rx crc Fail : 0x0B E2 07 54 71 00 79 9E 00 71 72 8B B8 31 | RTX:0;NodeId:7;BME280: 0x54 71 00 7B 9E 00 71 72 32 | NodeId:6;BME280: 0x57 42 00 80 68 00 67 B9 33 | RTX:0;NodeId:6;BME280: 0x57 42 00 80 68 00 67 B9 34 | RTX:0;rx crc Fail : 0x0B E2 10 4A E6 00 7B CF 00 6B CB 7D E7 35 | RTX:0;rx crc Fail : 0x0B E2 10 42 E6 00 7B CF 00 6B CB D4 B1 36 | NodeId:14;is:Alive 37 | RTX:0;rx crc Fail : 0x03 F5 0E 54 BE 38 | -------------------------------------------------------------------------------- /firmware_rf_dongle/rf_receiver_logger/uart_config.h: -------------------------------------------------------------------------------- 1 | /** @file uart_config.h 2 | * 3 | * @author Wassim FILALI 4 | * 5 | * 6 | * 7 | * $Date: 12.11.2016 8 | * $Revision: 9 | * 10 | */ 11 | #ifndef _UART_CONFIG_ 12 | #define _UART_CONFIG_ 13 | 14 | //UART_BAUD_RATE possible values 115200 9600 15 | #define UART_BAUD_RATE 115200 16 | 17 | //----------------------------------- Interruptions --------------------------------------- 18 | //Flag: UART_USE_RX_INETRRUPT 19 | // 1 : Enabled 20 | // declares the IRQ and requires teh user to declare a uart_callback() function 21 | 22 | #define UART_USE_RX_INETRRUPT 1 23 | 24 | #if UART_USE_RX_INETRRUPT == 1 25 | #define UART_ECHO 0 26 | #endif 27 | //Flag: UART_CALLBACK_POLLING 28 | // 1 : Enabled => simplified to just calling uart_rx_user_poll() 29 | // which will if necessary call the uart_rx_user_callback() 30 | // The work behind is : 31 | // 'uart_rx_user_callback_pending' will be polled 32 | // consume 'uart_BUFFER' with 'uart_index', 33 | // acknowledge with 'uart_rx_user_callback_performed' 34 | // 0 : INTERRUPT => The 'uart_rx_user_callback()' will be called from the uart interrupt context 35 | // Flags dependencies 36 | // '#define UART_USE_RX_INETRRUPT 1' has to be set to 1 37 | #define UART_CALLBACK_POLLING 0 38 | 39 | 40 | #define UART_FRAME_SIZE 31 41 | 42 | //the terminal sends 13 43 | #define UART_EOL_C 13 44 | 45 | //Flag: UART_Through_RF_Delay 46 | //1 : Enabled this delay is added after every end of line to allow proper transmission of messages through radio 47 | //0 : Disabled, normal behaviour 48 | #define UART_Through_RF_Delay 0 49 | 50 | #endif /*_UART_CONFIG_*/ 51 | -------------------------------------------------------------------------------- /firmware_rf_dongle/settings/firmware_rf_dongle.wspos: -------------------------------------------------------------------------------- 1 | [MainWindow] 2 | WindowPlacement=_ 114 67 2075 1329 1 3 | -------------------------------------------------------------------------------- /firmware_rf_sensors_node/IoT_Mobile_Node.eww: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | $WS_DIR$\pr01_Node_Alive\pr01_Node_Alive.ewp 6 | 7 | 8 | $WS_DIR$\pr02_AmbientLight\pr02_AmbientLight.ewp 9 | 10 | 11 | $WS_DIR$\pr03_PressHumTemp\pr03_PressHumTemp.ewp 12 | 13 | 14 | $WS_DIR$\pr04_LightBroadcast\pr04_LightBroadcast.ewp 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /firmware_rf_sensors_node/debug.txt: -------------------------------------------------------------------------------- 1 | * wait 100 ms on startup should not be there 2 | * flush and reas status before write has changed 3 | 4 | __________________________________________________________ 5 | * TODO test BME 280 6 | 7 | __________________________________________________________ 8 | 9 | ?nRF_Config 10 | 11 | Config updated with : 0x70 ; reread 0x70 ; STATUS: 0x0E : No Data Ready i; No Data Sent i; No Max Ret i; Rx Fifo Empty ; Available TX Fifo Locations; 12 | STATUS: 0x0E : No Data Ready i; No Data Sent i; No Max Ret i; Rx Fifo Empty ; Available TX Fifo Locations; 13 | CONFIG: 0x70 : RX IRQ Masked; TX IRQ Masked; Max RT IRQ Masked; CRC Disabled; CRC 1 Bytes; Power Down; P TX Mode; 14 | ChipEnable Low 15 | Channel 10 selected : 2410 MHz 16 | Address Width : 5 bytes 17 | Rx Address P0: 0xE7 18 | Tx Address : 0xEnRF_Config 19 | __________________________________________________________ 20 | 350 us for 4x 100 us delay 21 | 4.35 ms for 5 ms delay 22 | 23 | 8x SPI --- delay --- 14th fail 24 | 25 | 2 SPI - 6 SPI ------- 6 SPI - 7 SPI 26 | 27 | nRF_Transmit_Wait_Down() 28 | nRF_Transmit() 29 | SPI_Write_Register() (2 SPI) 30 | nRF_SetMode_TX() 31 | SPI_Read_Register() 2 SPI 32 | nRF_SetMode_Standby_I() 33 | SPI_Read_Register 2 SPI 34 | SPI_Write_Register 2 SPI 35 | 36 | delay 5 ms 37 | 38 | SPI_Read_Register() 2 SPI 39 | SPI_Write_Register() 2 SPI 40 | SPI_Read_Register() 2 SPI 41 | SPI_Write_Buf() (7 SPI) 42 | CE_PULSE 43 | nRF_Wait_Transmit() 44 | nRF_SetMode_PowerDown() 45 | 46 | __________________________________________________________ 47 | STM8L dies 70 us after setting CE pulse 48 | 49 | I2C not set configures the pio to output which consumes current floating consumption 50 | 51 | -------------------------------------------------------------------------------- /firmware_rf_sensors_node/measures.txt: -------------------------------------------------------------------------------- 1 | - Mobile node v2 2 | 3 | =>power down RF on halt, send from main 4 | 5 | => 250 Kbps, Tx alive 4B 6 | awake RF prep RF Tx 7 | 11.3 ms 72 us 380 us 8 | 4.2 mA 10.7 mA 28.8 mA 9 | 10 | => 250 Kbps, Tx alive ! 32B ! 11 | awake RF prep RF Tx 12 | 18.4 ms 72 us 1.28 ms 13 | 4.3 mA 10.7 mA 28.7 mA 14 | 15 | => ! 2 Mbps !, Tx alive 32B 16 | awake RF prep RF Tx start RF after 17 | 17.5 ms 72 us 202 us 15.7 ms 18 | 4.3 mA 10.7 mA 28.7 mA 19 | 20 | 21 | => 2 Mbps, Tx alive !4B! 22 | awake RF prep RF Tx start RF after 23 | 11.3 ms 72 us 91 us 9.5 ms 24 | 4.3 mA 10.7 mA 28.7 mA 25 | 26 | 27 | 32 - 4 => 28 Bytes : 111 us 28 | 29 | 51 Bytes - 32 = 19 30 | 31 | Preamble: 1 B 32 | Address : 5 B 33 | 34 | -------------------------------------------------------------------------------- /firmware_rf_sensors_node/pr01_Node_Alive/.gitignore: -------------------------------------------------------------------------------- 1 | Debug/ 2 | Settings/ 3 | -------------------------------------------------------------------------------- /firmware_rf_sensors_node/pr01_Node_Alive/deviceType.h: -------------------------------------------------------------------------------- 1 | #define DEVICE_STM8L 1 2 | -------------------------------------------------------------------------------- /firmware_rf_sensors_node/pr01_Node_Alive/uart_config.h: -------------------------------------------------------------------------------- 1 | /** @file uart_config.h 2 | * 3 | * @author Wassim FILALI 4 | * 5 | * 6 | * 7 | * $Date: 12.11.2016 8 | * $Revision: 9 | * 10 | */ 11 | #ifndef _UART_CONFIG_ 12 | #define _UART_CONFIG_ 13 | 14 | //----------------------------------- UART Disable Enable --------------------------------------- 15 | 16 | #define UART_ENABLE 0 17 | 18 | //----------------------------------- Interruptions --------------------------------------- 19 | //Flag: UART_USE_RX_INETRRUPT 20 | // 1 : Enabled 21 | // declares the IRQ and requires teh user to declare a uart_callback() function 22 | 23 | #define UART_USE_RX_INETRRUPT 0 24 | 25 | //Flag: UART_CALLBACK_POLLING 26 | // 1 : Enabled => 'uart_rx_user_callback_pending' has to be polled 27 | // consume 'uart_BUFFER' with 'uart_index', 28 | // acknowledge with 'uart_rx_user_callback_performed' 29 | // 0 : INTERRUPT => The 'uart_rx_user_callback()' will be called from the uart interrupt context 30 | // Flags dependencies 31 | // '#define UART_USE_RX_INETRRUPT 1' has to be set to 1 32 | #define UART_CALLBACK_POLLING 0 33 | 34 | 35 | #define UART_FRAME_SIZE 31 36 | 37 | //the terminal sends 13 38 | #define UART_EOL_C 13 39 | 40 | //Flag: UART_Through_RF_Delay 41 | //1 : Enabled this delay is added after every end of line to allow proper transmission of messages through radio 42 | //0 : Disabled, normal behaviour 43 | #define UART_Through_RF_Delay 0 44 | 45 | #endif /*_UART_CONFIG_*/ 46 | -------------------------------------------------------------------------------- /firmware_rf_sensors_node/pr01_Node_Alive/working_rom.hex: -------------------------------------------------------------------------------- 1 | :201000000E00000000000000000000000000000001010100000000000000000000000000BF 2 | :201020000500000A00000000000000000000000000000000000000000000000000000000A1 3 | :20104000000000000000000000000000000000000000000000000000000000000000000090 4 | :20106000000000000000000000000000000000000000000000000000000000000000000070 5 | :20108000000000000000000000000000000000000000000000000000000000000000000050 6 | :2010A000000000000000000000000000000000000000000000000000000000000000000030 7 | :2010C000000000000000000000000000000000000000000000000000000000000000000010 8 | :2010E0000000000000000000000000000000000000000000000000000000000000000000F0 9 | :00000001FF 10 | -------------------------------------------------------------------------------- /firmware_rf_sensors_node/pr02_AmbientLight/deviceType.h: -------------------------------------------------------------------------------- 1 | #define DEVICE_STM8L 1 2 | -------------------------------------------------------------------------------- /firmware_rf_sensors_node/pr02_AmbientLight/pr02_AmbientLight.dep: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2 5 | 2475527451 6 | 7 | Debug 8 | 9 | 10 | [MULTI_TOOL] 11 | ILINK 12 | 13 | 14 | 15 | Release 16 | 17 | 18 | [MULTI_TOOL] 19 | ILINK 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /firmware_rf_sensors_node/pr02_AmbientLight/pr02_AmbientLight.ewt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2 5 | 6 | Debug 7 | 8 | STM8 9 | 10 | 1 11 | 12 | 13 | Release 14 | 15 | STM8 16 | 17 | 0 18 | 19 | 20 | libs 21 | 22 | $PROJ_DIR$\..\..\..\libs\clock_led.c 23 | 24 | 25 | $PROJ_DIR$\..\..\..\libs\clock_led.h 26 | 27 | 28 | $PROJ_DIR$\..\..\..\libs\commonTypes.h 29 | 30 | 31 | $PROJ_DIR$\..\..\..\libs\i2c_stm8x.c 32 | 33 | 34 | $PROJ_DIR$\..\..\..\libs\i2c_stm8x.h 35 | 36 | 37 | $PROJ_DIR$\..\..\..\libs\nRF.c 38 | 39 | 40 | $PROJ_DIR$\..\..\..\libs\nRF.h 41 | 42 | 43 | $PROJ_DIR$\..\..\..\libs\nRF_IRQ_stm8x.c 44 | 45 | 46 | $PROJ_DIR$\..\..\..\libs\nRF_IRQ_stm8x.h 47 | 48 | 49 | $PROJ_DIR$\..\..\..\libs\nRF_RegText.c 50 | 51 | 52 | $PROJ_DIR$\..\..\..\libs\nRF_RegText.h 53 | 54 | 55 | $PROJ_DIR$\..\..\..\libs\nRF_SPI.c 56 | 57 | 58 | $PROJ_DIR$\..\..\..\libs\nRF_SPI.h 59 | 60 | 61 | $PROJ_DIR$\..\..\..\libs\nRF_Tx.c 62 | 63 | 64 | $PROJ_DIR$\..\..\..\libs\nRF_Tx.h 65 | 66 | 67 | $PROJ_DIR$\..\..\..\libs\spi_stm8x.c 68 | 69 | 70 | $PROJ_DIR$\..\..\..\libs\spi_stm8x.h 71 | 72 | 73 | $PROJ_DIR$\..\..\..\libs\uart.c 74 | 75 | 76 | $PROJ_DIR$\..\..\..\libs\uart.h 77 | 78 | 79 | $PROJ_DIR$\..\..\..\libs\uart_stm8x.c 80 | 81 | 82 | $PROJ_DIR$\..\..\..\libs\uart_stm8x.h 83 | 84 | 85 | 86 | $PROJ_DIR$\deviceType.h 87 | 88 | 89 | $PROJ_DIR$\main.c 90 | 91 | 92 | $PROJ_DIR$\nRF_Configuration.h 93 | 94 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /firmware_rf_sensors_node/pr03_PressHumTemp/.gitignore: -------------------------------------------------------------------------------- 1 | Debug/ 2 | settings/ 3 | -------------------------------------------------------------------------------- /firmware_rf_sensors_node/pr03_PressHumTemp/deviceType.h: -------------------------------------------------------------------------------- 1 | #define DEVICE_STM8L 1 2 | -------------------------------------------------------------------------------- /firmware_rf_sensors_node/pr03_PressHumTemp/serial_log.txt: -------------------------------------------------------------------------------- 1 | sensors_logger\firmware_rf_sensors_node 2 | Node id 0x07 3 | nRF_Config 4 | 5 | Config updated with : 0x70 ; reread 0x70 ; STATUS: 0x0E : 6 | 7 | BME280 id = 0x60 8 | BME280 calib data: 9 | Reg 0x88 : 0x29 6D E4 64 32 00 79 90 AD D4 10 | Reg 0x92 : 0xD0 0B 95 1B 8B FF F9 FF AC 26 11 | Reg 0x9C : 0x0A D8 BD 10 00 4B 12 | Reg 0xE1 : 0x65 01 00 14 0C 00 1E 8F 13 | 14 | counter :0x00 15 | Measure--------------- 16 | Measure done 1 poll 17 | Reg 0xF7 : 0x53 F3 00 7E F1 00 74 3F 18 | rf_send--------------- 19 | 20 | counter :0x01 21 | Measure--------------- 22 | Measure done 1 poll 23 | Reg 0xF7 : 0x53 F6 00 7E ED 00 73 70 24 | rf_send--------------- 25 | 26 | counter :0x02 27 | Measure--------------- 28 | Measure done 1 poll 29 | Reg 0xF7 : 0x53 F5 00 7E EF 00 74 44 30 | rf_send--------------- 31 | -------------------------------------------------------------------------------- /firmware_rf_sensors_node/pr03_PressHumTemp/uart_config.h: -------------------------------------------------------------------------------- 1 | /** @file uart_config.h 2 | * 3 | * @author Wassim FILALI 4 | * 5 | * 6 | * 7 | * $Date: 12.11.2016 8 | * $Revision: 9 | * 10 | */ 11 | #ifndef _UART_CONFIG_ 12 | #define _UART_CONFIG_ 13 | 14 | //----------------------------------- UART Disable Enable --------------------------------------- 15 | 16 | #define UART_ENABLE 0 17 | 18 | //----------------------------------- Interruptions --------------------------------------- 19 | //Flag: UART_USE_RX_INETRRUPT 20 | // 1 : Enabled 21 | // declares the IRQ and requires teh user to declare a uart_callback() function 22 | 23 | #define UART_USE_RX_INETRRUPT 0 24 | 25 | //Flag: UART_CALLBACK_POLLING 26 | // 1 : Enabled => 'uart_rx_user_callback_pending' has to be polled 27 | // consume 'uart_BUFFER' with 'uart_index', 28 | // acknowledge with 'uart_rx_user_callback_performed' 29 | // 0 : INTERRUPT => The 'uart_rx_user_callback()' will be called from the uart interrupt context 30 | // Flags dependencies 31 | // '#define UART_USE_RX_INETRRUPT 1' has to be set to 1 32 | #define UART_CALLBACK_POLLING 0 33 | 34 | 35 | #define UART_FRAME_SIZE 31 36 | 37 | //the terminal sends 13 38 | #define UART_EOL_C 13 39 | 40 | //Flag: UART_Through_RF_Delay 41 | //1 : Enabled this delay is added after every end of line to allow proper transmission of messages through radio 42 | //0 : Disabled, normal behaviour 43 | #define UART_Through_RF_Delay 0 44 | 45 | #endif /*_UART_CONFIG_*/ 46 | -------------------------------------------------------------------------------- /firmware_rf_sensors_node/pr03_PressHumTemp/working_rom.hex: -------------------------------------------------------------------------------- 1 | :201000001000000000000000000000000000000000000000010000000000000000000000BF 2 | :201020001E0000000000000000000000000000000000000000000000000000000000000092 3 | :20104000000000000000000000000000000000000000000000000000000000000000000090 4 | :20106000000000000000000000000000000000000000000000000000000000000000000070 5 | :20108000000000000000000000000000000000000000000000000000000000000000000050 6 | :2010A000000000000000000000000000000000000000000000000000000000000000000030 7 | :2010C000000000000000000000000000000000000000000000000000000000000000000010 8 | :2010E0000000000000000000000000000000000000000000000000000000000000000000F0 9 | :00000001FF 10 | -------------------------------------------------------------------------------- /firmware_rf_sensors_node/pr04_LightBroadcast/.gitignore: -------------------------------------------------------------------------------- 1 | Debug/ 2 | settings/ 3 | -------------------------------------------------------------------------------- /firmware_rf_sensors_node/pr04_LightBroadcast/deviceType.h: -------------------------------------------------------------------------------- 1 | #define DEVICE_STM8L 1 2 | -------------------------------------------------------------------------------- /firmware_rf_sensors_node/pr04_LightBroadcast/pr04_LightBroadcast.dep: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2 5 | 2237568980 6 | 7 | Debug 8 | 9 | 10 | [MULTI_TOOL] 11 | ILINK 12 | 13 | 14 | 15 | Release 16 | 17 | 18 | [MULTI_TOOL] 19 | ILINK 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /firmware_rf_sensors_node/pr04_LightBroadcast/pr04_LightBroadcast.ewt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2 5 | 6 | Debug 7 | 8 | STM8 9 | 10 | 1 11 | 12 | 13 | Release 14 | 15 | STM8 16 | 17 | 0 18 | 19 | 20 | libs 21 | 22 | $PROJ_DIR$\..\..\..\libs\clock_led.c 23 | 24 | 25 | $PROJ_DIR$\..\..\..\libs\clock_led.h 26 | 27 | 28 | $PROJ_DIR$\..\..\..\libs\commonTypes.h 29 | 30 | 31 | $PROJ_DIR$\..\..\..\libs\i2c_stm8x.c 32 | 33 | 34 | $PROJ_DIR$\..\..\..\libs\i2c_stm8x.h 35 | 36 | 37 | $PROJ_DIR$\..\..\..\libs\irq_debug.c 38 | 39 | 40 | $PROJ_DIR$\..\..\..\libs\max44009.c 41 | 42 | 43 | $PROJ_DIR$\..\..\..\libs\max44009.h 44 | 45 | 46 | $PROJ_DIR$\..\..\..\libs\nRF.c 47 | 48 | 49 | $PROJ_DIR$\..\..\..\libs\nRF.h 50 | 51 | 52 | $PROJ_DIR$\..\..\..\libs\nRF_IRQ_stm8x.c 53 | 54 | 55 | $PROJ_DIR$\..\..\..\libs\nRF_IRQ_stm8x.h 56 | 57 | 58 | $PROJ_DIR$\..\..\..\libs\nRF_RegText.c 59 | 60 | 61 | $PROJ_DIR$\..\..\..\libs\nRF_RegText.h 62 | 63 | 64 | $PROJ_DIR$\..\..\..\libs\nRF_SPI.c 65 | 66 | 67 | $PROJ_DIR$\..\..\..\libs\nRF_SPI.h 68 | 69 | 70 | $PROJ_DIR$\..\..\..\libs\nRF_Tx.c 71 | 72 | 73 | $PROJ_DIR$\..\..\..\libs\nRF_Tx.h 74 | 75 | 76 | $PROJ_DIR$\..\..\..\libs\spi_stm8x.c 77 | 78 | 79 | $PROJ_DIR$\..\..\..\libs\spi_stm8x.h 80 | 81 | 82 | $PROJ_DIR$\..\..\..\libs\uart.c 83 | 84 | 85 | $PROJ_DIR$\..\..\..\libs\uart.h 86 | 87 | 88 | $PROJ_DIR$\..\..\..\libs\uart_stm8x.c 89 | 90 | 91 | $PROJ_DIR$\..\..\..\libs\uart_stm8x.h 92 | 93 | 94 | 95 | $PROJ_DIR$\deviceType.h 96 | 97 | 98 | $PROJ_DIR$\main.c 99 | 100 | 101 | $PROJ_DIR$\nRF_Configuration.h 102 | 103 | 104 | 105 | 106 | -------------------------------------------------------------------------------- /firmware_rf_sensors_node/pr04_LightBroadcast/uart_config.h: -------------------------------------------------------------------------------- 1 | /** @file uart_config.h 2 | * 3 | * @author Wassim FILALI 4 | * 5 | * 6 | * 7 | * $Date: 12.11.2016 8 | * $Revision: 9 | * 10 | */ 11 | #ifndef _UART_CONFIG_ 12 | #define _UART_CONFIG_ 13 | 14 | 15 | //----------------------------------- Interruptions --------------------------------------- 16 | //Flag: UART_USE_RX_INETRRUPT 17 | // 1 : Enabled 18 | // declares the IRQ and requires teh user to declare a uart_callback() function 19 | 20 | #define UART_USE_RX_INETRRUPT 0 21 | 22 | //Flag: UART_CALLBACK_POLLING 23 | // 1 : Enabled => 'uart_rx_user_callback_pending' has to be polled 24 | // consume 'uart_BUFFER' with 'uart_index', 25 | // acknowledge with 'uart_rx_user_callback_performed' 26 | // 0 : INTERRUPT => The 'uart_rx_user_callback()' will be called from the uart interrupt context 27 | // Flags dependencies 28 | // '#define UART_USE_RX_INETRRUPT 1' has to be set to 1 29 | #define UART_CALLBACK_POLLING 0 30 | 31 | 32 | #define UART_FRAME_SIZE 31 33 | 34 | //the terminal sends 13 35 | #define UART_EOL_C 13 36 | 37 | //Flag: UART_Through_RF_Delay 38 | //1 : Enabled this delay is added after every end of line to allow proper transmission of messages through radio 39 | //0 : Disabled, normal behaviour 40 | #define UART_Through_RF_Delay 0 41 | 42 | #endif /*_UART_CONFIG_*/ 43 | -------------------------------------------------------------------------------- /firmware_rf_sensors_node/settings/IoT_Mobile_Node.wspos: -------------------------------------------------------------------------------- 1 | [MainWindow] 2 | WindowPlacement=_ 120 154 1680 1405 1 3 | -------------------------------------------------------------------------------- /libs/WS2812B.h: -------------------------------------------------------------------------------- 1 | /** @file WS2812B.h 2 | * 3 | * @author Wassim FILALI 4 | * Inferred from the Datasheet 5 | * 6 | * 7 | * @compiler IAR STM8 8 | * 9 | * 10 | * started on local project on 10.10.2015 11 | * this file was created for refactoring on 03.01.2016 12 | * $Date: 13 | * $Revision: 14 | * 15 | */ 16 | 17 | #include "commonTypes.h" 18 | 19 | 20 | extern const RGBColor_t RED; 21 | extern const RGBColor_t GREEN; 22 | extern const RGBColor_t BLUE; 23 | extern const RGBColor_t BLACK; 24 | extern const RGBColor_t WHITE; 25 | 26 | 27 | // user configuration 28 | 29 | #define rgb_SwitchOff(); rgb_SendColor(0, 0, 0); 30 | 31 | // shared variables 32 | 33 | void rgb_PIO_Init(); 34 | 35 | //These functions only update the LED colors memory without sending the data 36 | void rgb_SetColor(BYTE LedId, BYTE R, BYTE G, BYTE B); 37 | void rgb_SetColors(BYTE LedId,RGBColor_t Color); 38 | 39 | void rgb_SetColors_range(BYTE first,BYTE NbLeds,RGBColor_t Color); 40 | void rgb_SetColor_range(BYTE first,BYTE NbLeds,BYTE R,BYTE G,BYTE B); 41 | 42 | //The Function that serialises the RGB bit values from memory into pulses for the LED WS2812B 43 | //this is used manually by the user in case of complex combination of partial shading of the array 44 | //the sending the complete LED sequence together. 45 | void rgb_SendArray(); 46 | 47 | //----------------- Functions with direct impact ------------------------ 48 | void rgb_SwitchOff_Range(BYTE first,BYTE NbLeds); 49 | 50 | 51 | void rgb_SendColor(BYTE R, BYTE G, BYTE B); // 1st LED Function 52 | void rgb_SendColors(RGBColor_t Color); // 1st LED Function 53 | 54 | //delay : x255 meas 10 => 2.55 sec for cycle completion 55 | //XUp : 0 = unmodified, 1 = Up, 2 = Down 56 | //RGB : used when XUp = 0; unmodified stays at any user provided value 57 | void rgb_RampColors(BYTE delay,BYTE RUp,BYTE GUp,BYTE BUp,BYTE R,BYTE G,BYTE B); 58 | void rgb_RampColors_range(BYTE delay,BYTE nbLED,BYTE RUp,BYTE GUp,BYTE BUp,BYTE R,BYTE G,BYTE B); 59 | 60 | void rgb_BlinkColors(BYTE R, BYTE G, BYTE B); 61 | 62 | void rgb_FlashColors(BYTE delay, RGBColor_t Color); 63 | 64 | //--------------------- Functions for Colors Memory update only -------------------- 65 | RGBColor_t rgb_ColorScale(int iCount,int nbCount,RGBColor_t ColorStart,RGBColor_t ColorEnd); 66 | 67 | void rgb_Shade(BYTE LedStart, BYTE LedEnd, RGBColor_t ColorStart, RGBColor_t ColorEnd); 68 | 69 | //--------------------- Demo functions with animation sequence ---------------------- 70 | void rgb_TestColors(); 71 | 72 | void rgb_Loop_BlueRedBlue(BYTE nbLeds,BYTE delay); 73 | 74 | //--------------------- RF Protocol handling ---------------------------------------- 75 | void rgb_decode_rf(BYTE *rxData,BYTE rx_DataSize); 76 | void rgb_encode_rf(RGBColor_t ColorRx,BYTE *rxPayload,BYTE *p_rxPayloadSize); 77 | 78 | 79 | void rgb_rf_get_tx_Color_6B(BYTE Target_NodeId,BYTE *txData,RGBColor_t Color); 80 | -------------------------------------------------------------------------------- /libs/adc.h: -------------------------------------------------------------------------------- 1 | /** @file adc.h 2 | 3 | @author Wassim FILALI STM8 S 4 | 5 | @compiler IAR STM8 6 | 7 | 8 | $Date: 06.11.2016 9 | $Revision: 10 | 11 | */ 12 | 13 | #ifndef __ADC__ 14 | #define __ADC__ 15 | 16 | #include "commonTypes.h" 17 | #include "deviceType.h" 18 | 19 | #if DEVICE_STM8S != 1 20 | #error this adc with 'deviceType.h'currently only supports STM8S 21 | #endif 22 | 23 | typedef BYTE ADC_Channel_t; 24 | extern const ADC_Channel_t AIN3_PD2; 25 | extern const ADC_Channel_t AIN4_PD3; 26 | extern const ADC_Channel_t AIN5_PD5; 27 | extern const ADC_Channel_t AIN6_PD6; 28 | 29 | typedef BYTE ADC_Mode_t; 30 | extern const ADC_Mode_t ADC_SINGLE_SHOT; 31 | extern const ADC_Mode_t ADC_TIMER2; 32 | 33 | typedef struct 34 | { 35 | uint16_t c1s_min; 36 | uint16_t c1s_max; 37 | uint16_t c1s_avg; 38 | }adv_user_vals_t; 39 | 40 | //channel is the Analog input AIN3 41 | void adc_init(ADC_Channel_t channel, ADC_Mode_t mode); 42 | void adc_start(); 43 | adv_user_vals_t adc_get_vals(); 44 | void adc_print_vals(); 45 | uint16_t adc_read(); 46 | void adc_acs712_print_current(); 47 | 48 | #endif /*__ADC__*/ 49 | -------------------------------------------------------------------------------- /libs/bme280.h: -------------------------------------------------------------------------------- 1 | /** @file bme280.h 2 | * 3 | * @author Wassim FILALI 4 | * 5 | * @compiler IAR STM8 6 | * 7 | * 8 | * $Date: 29.10.2016 - creation 9 | * $Revision: 1 10 | * 11 | */ 12 | 13 | 14 | BYTE bme280_read_reg(BYTE address); 15 | 16 | void bme280_read_registers(BYTE Start, BYTE Number,BYTE *data); 17 | 18 | void bme280_print_registers(BYTE Start, BYTE Number); 19 | 20 | void bme280_print_CalibData(); 21 | 22 | void bme280_check_id(); 23 | 24 | void bme280_force_OneMeasure(BYTE Press,BYTE Temp,BYTE Hum); 25 | 26 | BYTE bme280_wait_measures(); 27 | 28 | void bme280_print_status(); 29 | 30 | void bme280_print_measures(); 31 | 32 | //void bme280_get_measures(BYTE *measures); 33 | 34 | //get the measures from the sensor and format them for tx 35 | //make sure the payload is a pre allocated 8 bytes buffer 36 | void bme280_get_tx_payload_8B(BYTE *payload); 37 | 38 | void bme280_rx_measures(BYTE src_NodeId,BYTE *rxPayload,BYTE rx_PayloadSize);//Rx 11 Bytes 39 | -------------------------------------------------------------------------------- /libs/clock_led.h: -------------------------------------------------------------------------------- 1 | /** @file clock_led.h 2 | * 3 | * @author Wassim FILALI 4 | * 5 | * @compiler IAR STM8 6 | * 7 | * 8 | * $Date: 20.09.2015 9 | * $Revision: 10 | * 11 | */ 12 | 13 | #include "commonTypes.h" 14 | 15 | #define delay_1us(); delay(0); 16 | 17 | #define delay_10us(); delay(18); 18 | 19 | #define delay_50us(); delay(98); 20 | 21 | #define delay_100us(); delay(198); 22 | 23 | #define delay_1ms(); delay(1998); 24 | 25 | #define delay_10ms(); delay(19998); 26 | 27 | void delay(unsigned int n); 28 | 29 | void delay_ms(unsigned int n); 30 | 31 | void InitialiseSystemClock(); 32 | 33 | // L E D 34 | void Initialise_TestLed_GPIO_B5(); 35 | void Test_Led_On(); 36 | void Test_Led_Off(); 37 | 38 | 39 | #if DEVICE_STM8L == 1 40 | void Initialise_STM8L_Clock(); 41 | BYTE Initialise_STM8L_RTC_LowPower(uint16_t times_sec); 42 | void sleep(); 43 | #endif 44 | 45 | -------------------------------------------------------------------------------- /libs/cmdutils.h: -------------------------------------------------------------------------------- 1 | /** @file cmdutils.h 2 | 3 | @author Wassim FILALI STM8 S 4 | 5 | @compiler IAR STM8 6 | 7 | 8 | $Date: 18.11.2016 9 | $Revision: 10 | 11 | */ 12 | 13 | #ifndef __CMDUTILS__ 14 | #define __CMDUTILS__ 15 | 16 | //for BYTE 17 | #include "commonTypes.h" 18 | 19 | BYTE strcmp(BYTE * s1, const char * s2); 20 | 21 | BYTE strbegins(BYTE * s1, const char * s2); 22 | 23 | BYTE get_hex_char(BYTE c); 24 | 25 | BYTE get_hex(BYTE* buffer,BYTE pos); 26 | 27 | BYTE line_length(BYTE*rxData,BYTE max_size); 28 | 29 | 30 | //for this handle_command() must be instanciated 31 | void run_eeprom_script(); 32 | 33 | #define crc_size 2 34 | 35 | void crc_set(uint8_t *data); 36 | // size(size+data) : data : crc 37 | BYTE crc_check(uint8_t const *data); 38 | 39 | uint16_t crc_Fletcher16( uint8_t const *data, uint8_t count ); 40 | 41 | #endif /*__CMDUTILS__*/ 42 | -------------------------------------------------------------------------------- /libs/commonTypes.h: -------------------------------------------------------------------------------- 1 | /** @file commonTypes.h 2 | * 3 | * @author Wassim FILALI 4 | * 5 | * 6 | * @compiler IAR STM8 7 | * 8 | * 9 | * $Date: 13.12.2015 10 | * $Revision: 11 | * 12 | */ 13 | 14 | // UINT type definition 15 | #ifndef _COMMON_TYPES_ 16 | #define _COMMON_TYPES_ 17 | 18 | 19 | typedef void* NULL; 20 | typedef unsigned int UINT; 21 | typedef unsigned char BYTE; 22 | 23 | typedef unsigned char U8_t; 24 | typedef signed char S8_t; 25 | typedef unsigned short U16_t; 26 | typedef signed int S16_t; 27 | typedef unsigned long U32_t; 28 | typedef signed long S32_t; 29 | 30 | typedef unsigned char uint8_t; 31 | typedef signed char int8_t; 32 | typedef unsigned short uint16_t; 33 | typedef signed int int16_t; 34 | typedef unsigned long uint32_t; 35 | typedef signed long int32_t; 36 | 37 | typedef struct 38 | { 39 | BYTE R; 40 | BYTE G; 41 | BYTE B; 42 | }RGBColor_t; 43 | 44 | 45 | #define E_OK 0x00 46 | 47 | #define E_Already_Initialised 0x01 48 | 49 | #endif /*_COMMON_TYPES_*/ 50 | -------------------------------------------------------------------------------- /libs/eeprom.h: -------------------------------------------------------------------------------- 1 | /** @file eeprom.h 2 | * 3 | * @author Wassim FILALI 4 | * 5 | * @compiler IAR STM8 6 | * 7 | * 8 | * $Date: 12.11.2016 9 | * $Revision: 10 | * 11 | */ 12 | 13 | #include "deviceType.h" 14 | 15 | #define EEPROM_Line 32 16 | 17 | #if DEVICE_STM8L == 1 18 | #define EEPROM_Offset 0x1000 19 | #define EEPROM_Size 256 20 | #elif DEVICE_STM8S == 1 21 | #define EEPROM_Offset 0x4000 22 | #define EEPROM_Size 640 23 | #else 24 | #error needs a file deviceType.h with DEVICE_STM8L 1 or S 1 defined 25 | #endif 26 | 27 | #define NODE_ID (char *) EEPROM_Offset; 28 | -------------------------------------------------------------------------------- /libs/i2c_stm8x.h: -------------------------------------------------------------------------------- 1 | /** @file i2c_stm8x.h 2 | * 3 | * @author Wassim FILALI 4 | * 5 | * 6 | * @compiler IAR STM8 7 | * 8 | * 9 | * $Date: 04.01.2016 10 | * $Date: 27.10.2016 - i2c_stm8x.h 11 | * $Revision: 12 | * 13 | */ 14 | 15 | #include "commonTypes.h" 16 | 17 | #include "uart.h" 18 | //------------------------------------------------------------------------------------------------------------------ 19 | // User configuration 20 | //------------------------------------------------------------------------------------------------------------------ 21 | #define Enable_Debug_I2C_IRQ 1 22 | 23 | 24 | //------------------------------------------------------------------------------------------------------------------ 25 | 26 | //configuration application section, not to be edited 27 | //--------------------------------------------------------------------------------------------- 28 | #if (Enable_Debug_I2C_IRQ == 1) 29 | #define I2C_IRQ_Printf(x) printf_ln(x) 30 | #define I2C_IRQ_PrintfHex(x) UARTPrintfHex(x) 31 | #define I2C_IRQ_PrintStatus(x) nRF_PrintStatus(x) 32 | #else 33 | #define I2C_IRQ_Printf(x) (void)0 34 | #define I2C_IRQ_PrintfHex(x) (void)0 35 | #define I2C_IRQ_PrintStatus(x) (void)0 36 | #endif 37 | 38 | //--------------------------------------------------------------------------------------------- 39 | 40 | 41 | //------------------------------------------------------------------------------------------------------------------ 42 | // I2C Registers 43 | //------------------------------------------------------------------------------------------------------------------ 44 | // I2C_CR1 Control Register 1 45 | // I2C_CR2 Control Register 2 46 | // I2C_FREQR Frequency Register 47 | // I2C_OARL Own Address Register LSB 48 | // I2C_OARH Own Address Register MSB 49 | // I2C_DR Data Register 50 | // I2C_SR1 Status Register 1 51 | // I2C_SR2 Status Register 2 52 | // I2C_SR3 Status Register 3 53 | // I2C_ITR Interrupt Register 54 | // I2C_CCRL Clock Control Register Low 55 | // I2C_CCRH Clock Control Register High 56 | // I2C_TRISER Tristate Enable register 57 | // funny the I2C_PECR is documented in STM8S103F3 specification while the Packet Error Checking is not part of the S family 58 | // 59 | //all reset to 0 60 | //------------------------------------------------------------------------------------------------------------------ 61 | 62 | // 63 | // STM8 I2C system. 64 | // default is slave, goes to master on Start and back to slave on stop 65 | // Addresses are 7/10 bits (one or two bytes), a Genral Call address can be enabled or disabled 66 | // 9th bit is acknowledge from the slave 67 | void I2C_Init(); 68 | 69 | void I2C_Transaction(BYTE read,BYTE slave_7msb_Address, BYTE* buffer,BYTE count); 70 | 71 | void I2C_Read(BYTE slave_7msb_Address, BYTE* buffer,BYTE count); 72 | 73 | void I2C_Write(BYTE slave_7msb_Address, BYTE* buffer,BYTE count); 74 | 75 | void I2C_Scan(); 76 | 77 | void i2c_user_Rx_Callback(BYTE *userdata,BYTE size); 78 | 79 | void i2c_user_Tx_Callback(BYTE *userdata,BYTE size); 80 | 81 | 82 | void i2c_user_Error_Callback(BYTE l_sr2); 83 | -------------------------------------------------------------------------------- /libs/light_dimmer_krida.h: -------------------------------------------------------------------------------- 1 | /** @file light_dimmer_krida.h 2 | * 3 | * @author Wassim FILALI 4 | * 5 | * @compiler IAR STM8S 6 | * 7 | * 8 | * $Date: 05.11.2015 9 | * $Revision: 10 | * 11 | */ 12 | 13 | //---------- Light Dimmer with servo Board Layout ---------- 14 | 15 | //------------------------------ PIO ------------------------------ 16 | // DIMMER_SYNC -> Pin C3 17 | // CURRENT_SENSE -> Pin D2 18 | // DIMMER_CH1 -> Pin C4 19 | // DIMMER_CH2 -> Pin C5 20 | // DIMMER_CH3 -> Pin C6 21 | // DIMMER_CH4 -> Pin C7 22 | //------------------------------ Interrupts ------------------------------ 23 | // Sync Interrupt -> PortC IRQ 24 | // Channel Triggers -> Timer1 CAPCOM IRQ 25 | // Channel Triggers -> Timer1 OVERFLOW IRQ 26 | //---------------------------------------------------------------------------- 27 | 28 | #define DIMMER_SYNC_IN PC_IDR_IDR3 29 | 30 | #define DIMMER_CH1_OUT PC_ODR_ODR4 31 | #define DIMMER_CH2_OUT PC_ODR_ODR5 32 | #define DIMMER_CH3_OUT PC_ODR_ODR6 33 | #define DIMMER_CH4_OUT PC_ODR_ODR7 34 | 35 | #define CURRENT_SENSE PD_IDR_IDR2 36 | 37 | void dimmer_init(); 38 | int get_int_count(); 39 | 40 | //the level is suggested, a 0 starting level, the returned delay is calculated with the Timer calibration period 41 | uint16_t dimmer_set_level(BYTE channel, uint16_t level); 42 | 43 | -------------------------------------------------------------------------------- /libs/max44009.c: -------------------------------------------------------------------------------- 1 | /** @file max44009.c 2 | * 3 | * @author Wassim FILALI 4 | * 5 | * @compiler IAR STM8 6 | * 7 | * 8 | * $Date: 29.10.2016 - creation out of refactoring 9 | * $Revision: 1 10 | * 11 | */ 12 | 13 | #include "i2c_stm8x.h" 14 | #include "commonTypes.h" 15 | 16 | #include "clock_led.h" 17 | #include "uart.h" 18 | 19 | //to construct the tx frame 20 | #include "rf_protocol.h" 21 | 22 | BYTE max44009_read_reg(BYTE address) 23 | { 24 | BYTE result; 25 | 26 | I2C_Write(0x4A, &address,1); 27 | delay_100us(); 28 | I2C_Read(0x4A, &result,1); 29 | delay_100us();//wait to complete before writing into unallocated variable 30 | 31 | return result; 32 | } 33 | 34 | uint16_t max44009_read_light() 35 | { 36 | BYTE sensorData[2]; 37 | sensorData[0] = max44009_read_reg(0x03); 38 | sensorData[1] = max44009_read_reg(0x04); 39 | uint16_t Val = sensorData[0]; 40 | Val <<= 4;//shift to make place for the 4 LSB 41 | Val = Val + (0x0F & sensorData[1]); 42 | return Val; 43 | } 44 | 45 | void max44009_get_tx_payload_2B(uint16_t light, BYTE *payload) 46 | { 47 | payload[0]= light>>4; 48 | payload[1]= light&0x0F; 49 | } -------------------------------------------------------------------------------- /libs/max44009.h: -------------------------------------------------------------------------------- 1 | /** @file max44009.h 2 | * 3 | * @author Wassim FILALI 4 | * 5 | * @compiler IAR STM8 6 | * 7 | * 8 | * $Date: 29.10.2016 - creation out of refactoring 9 | * $Revision: 1 10 | * 11 | */ 12 | 13 | #include "commonTypes.h" 14 | 15 | 16 | //still possible to develop 17 | 18 | //void max44009_inetrrupt_status(); 19 | //void max44009_interrupt_enable(); 20 | //void max44009_threshold_set(); 21 | 22 | BYTE max44009_read_reg(BYTE address); 23 | 24 | uint16_t max44009_read_light(); 25 | 26 | void max44009_get_tx_payload_2B(uint16_t light, BYTE *payload); 27 | -------------------------------------------------------------------------------- /libs/nRF.h: -------------------------------------------------------------------------------- 1 | /** @file nRF.h 2 | * 3 | * @author Wassim FILALI 4 | * Directly inferred from the Datasheet 5 | * 6 | * 7 | * @compiler IAR STM8 8 | * 9 | * 10 | * $Date: 12.12.2015 nRF_Modes.h 11 | * $Date: 29.10.2016 renamed to nRF.h 12 | * $Revision: 13 | * 14 | */ 15 | 16 | //for BYTE 17 | #include "commonTypes.h" 18 | 19 | 20 | #define nRF_Mode_Uninitialised 0x00 21 | #define nRF_Mode_PowerDown 0x01 22 | #define nRF_Mode_Standby 0x02 23 | #define nRF_Mode_Tx 0x03 24 | #define nRF_Mode_Rx 0x04 25 | 26 | BYTE nRF_Config(); 27 | 28 | BYTE nRF_Init();//Waiting power on reset and initialising SPI 29 | 30 | // The Radio control operational modes are following the description from 31 | // nRF24L01P Product Specification 1.0 page 21 32 | 33 | BYTE nRF_SetMode_PowerDown(); 34 | 35 | BYTE nRF_SetMode_Standby_I(); 36 | 37 | BYTE nRF_SetMode_RX(); 38 | 39 | BYTE nRF_SetMode_TX(); 40 | 41 | BYTE nRF_ClearStatus(); 42 | 43 | BYTE nRF_SetDataRate(BYTE dr);//1=> 1Mb, 2=> 2Mb, 250=> 250Kb 44 | BYTE nRF_SelectChannel(BYTE channel); 45 | BYTE nRF_GetChannel(); 46 | void nRF_PrintChannel(); 47 | 48 | //only LSByte set, others are default 49 | BYTE nRF_SetTxAddress(BYTE address); 50 | 51 | //only LSByte set, others are default 52 | BYTE nRF_SetRxAddress(BYTE Pipe, BYTE address); 53 | 54 | 55 | //Global variable to manage the current mode 56 | 57 | extern BYTE nRF_Mode; 58 | extern BYTE ConfigVal; 59 | 60 | BYTE nRF_GetTxAddress(); 61 | BYTE nRF_GetRxAddress(BYTE Pipe); 62 | -------------------------------------------------------------------------------- /libs/nRF_IRQ_stm8x.h: -------------------------------------------------------------------------------- 1 | /** @file nRF_IRQ.h 2 | * 3 | * @author Wassim FILALI, inspired from nRF24L01P-EK 4 | * 5 | * @compiler IAR STM8 6 | * 7 | * 8 | * $Date: 14.12.2015 9 | * $Revision: 10 | * 11 | */ 12 | 13 | //nRF24L01P module IRQ on D2 14 | 15 | void nRF_IRQ_Config(); 16 | -------------------------------------------------------------------------------- /libs/nRF_RegText.h: -------------------------------------------------------------------------------- 1 | /** @file nRF_RegText.h 2 | * 3 | * @author Wassim FILALI 4 | * 5 | * @compiler IAR STM8 6 | * 7 | * $Date: 13.12.2015 8 | * $Revision: 9 | * 10 | */ 11 | 12 | #include "commonTypes.h" 13 | 14 | void nRF_PrintStatus(BYTE status); 15 | void nRF_PrintConfig(BYTE config); 16 | 17 | void nRF_PrintInfo(); 18 | -------------------------------------------------------------------------------- /libs/nRF_Tx.c: -------------------------------------------------------------------------------- 1 | /** @file nRF_Tx.c 2 | * 3 | * @author Wassim FILALI 4 | * Inferred from the Datasheet 5 | * 6 | * 7 | * @compiler IAR STM8 8 | * 9 | * 10 | * $Date: 12.12.2015 11 | * $Revision: 12 | * 13 | */ 14 | #include 15 | #include 16 | 17 | //----------------------- config includes ----------------------- 18 | #include "nRF_Configuration.h" 19 | //-------------------------- includes --------------------------- 20 | #include "nRF_Tx.h" 21 | //for nRF_Mode 22 | #include "nRF.h" 23 | //for SPI_Write_Buf 24 | #include "nRF_SPI.h" 25 | #include "clock_led.h" 26 | #include "spi_stm8x.h" 27 | 28 | //#define DEBUG_PIO PA_ODR_bit.ODR2 29 | 30 | //returns the status byte 31 | BYTE nRF_Transmit(BYTE* payload, BYTE size) 32 | { 33 | BYTE status; 34 | //as per definition in http://www.technolab.ddns.net/display/SSN/RF-UART 35 | //as long as the length cannot be explicitely retreived 36 | //it will be available at the 32nd and last location 37 | if(size>RF_MAX_DATASIZE)//size byte is included in the length 38 | { 39 | //non supported size, do nothing 40 | return 0; 41 | } 42 | 43 | //this will intrrupt any previously on going or blocked Tx (lost link) 44 | //This Flush is dubtfull, not necessary 45 | //and breaking quick successive transmissions 46 | //status = SPI_Command(FLUSH_TX); 47 | 48 | //Assert Data Sent before new transmission to poll TX status 49 | //status |= bit_TX_DS; 50 | //no need to use setbit with status, as two read, and others act on write one only 51 | SPI_Write_Register(STATUS,bit_TX_DS); 52 | 53 | if(nRF_Mode != nRF_Mode_Tx) 54 | { 55 | nRF_SetMode_TX(); 56 | } 57 | 58 | status = SPI_Write_Buf(WR_TX_PLOAD,payload,size); 59 | 60 | //This pin setting do not support multiple successive transmissions 61 | //that fill tx data in multiple buffers 62 | //because once first buffer is sent, a check is made on CE 63 | //to see if second continues 64 | //the bad case is write two buffers and give two pulses while 65 | //the first tx is still ongoing, then it stops as CE is low 66 | 67 | CE_Pin_HighEnable();//pulse for more than 10 us 68 | delay_10us(); 69 | delay_10us(); 70 | CE_Pin_LowDisable(); 71 | 72 | //DEBUG_PIO = 0; 73 | 74 | return status; 75 | } 76 | 77 | BYTE nRF_Transmit_Wait_Down(BYTE* payload, BYTE size) 78 | { 79 | BYTE status; 80 | status = nRF_Transmit(payload,size); 81 | 82 | //from here would die within 60 us and restart in main() 83 | 84 | nRF_Wait_Transmit(); 85 | 86 | nRF_SetMode_PowerDown(); 87 | 88 | return status; 89 | } 90 | 91 | BYTE nRF_Transmit_Wait_Rx(BYTE* payload, BYTE size) 92 | { 93 | BYTE status; 94 | status = nRF_Transmit(payload,size); 95 | nRF_Wait_Transmit(); 96 | nRF_SetMode_RX(); 97 | 98 | return status; 99 | } 100 | 101 | //waits for Tx by polling STATUS bit TX_DS, counts till 255 then comes back 102 | BYTE nRF_Wait_Transmit() 103 | { 104 | BYTE cycles = 0; 105 | BYTE status; 106 | do 107 | { 108 | status = SPI_Read_Register(STATUS); 109 | cycles++; 110 | delay_10us(); 111 | }while(((status &bit_TX_DS) == 0)&(cycles<10)); 112 | 113 | return cycles; 114 | } 115 | -------------------------------------------------------------------------------- /libs/nRF_Tx.h: -------------------------------------------------------------------------------- 1 | /** @file nRF_Tx.h 2 | * 3 | * @author Wassim FILALI 4 | * Inferred from the Datasheet 5 | * 6 | * 7 | * @compiler IAR STM8 8 | * 9 | * 10 | * $Date: 12.12.2015 11 | * $Revision: 12 | * 13 | */ 14 | 15 | //for BYTE 16 | #include "commonTypes.h" 17 | 18 | BYTE nRF_Transmit(BYTE* payload, BYTE size); 19 | //Sends, wait transmission to complete, then goes in power down 20 | BYTE nRF_Transmit_Wait_Down(BYTE* payload, BYTE size); 21 | //Sends, wait transmission to complete, then goes in Rx mode 22 | BYTE nRF_Transmit_Wait_Rx(BYTE* payload, BYTE size); 23 | 24 | //waits for Tx by polling STATUS bit TX_DS, counts till 255 then comes back 25 | //usually returns after 2 cycles for 2Mbps 26 | BYTE nRF_Wait_Transmit(); 27 | 28 | -------------------------------------------------------------------------------- /libs/pwm.h: -------------------------------------------------------------------------------- 1 | /** @file pwm.h 2 | * 3 | * @author Wassim FILALI 4 | * 5 | * @compiler IAR STM8S 6 | * 7 | * 8 | * $Date: 19.02.2017 9 | * $Revision: 10 | * 11 | */ 12 | 13 | //------------------------------ pwm ------------------------------ 14 | #include "commonTypes.h" 15 | //----------------------- SMARTIO Board Layout -------------------- 16 | // -> Pin D3 => TMR2 CH2 17 | // -> Pin D2 => TMR2 CH3 18 | // -> Pin D1 19 | // -> Pin C7 => TMR1 CH2 Used 20 | // -> Pin C6 => TMR1 CH1 Used 21 | // -> Pin C5 => TMR2 CH1 22 | // -> Pin C4 => TMR1 CH4 Used 23 | // -> Pin C3 => TMR1 CH3 Used 24 | //------------------------------ Interrupts ------------------------------ 25 | // -> Timer1 OVERFLOW IRQ 26 | //---------------------------------------------------------------------------- 27 | 28 | #define PWM_CH1_OUT PC_ODR_ODR4 29 | #define PWM_CH2_OUT PC_ODR_ODR5 30 | #define PWM_CH3_OUT PC_ODR_ODR6 31 | #define PWM_CH4_OUT PC_ODR_ODR7 32 | 33 | void pwm_init(); 34 | 35 | //output function 36 | void pwm_set_level(BYTE channel, uint16_t level); 37 | 38 | -------------------------------------------------------------------------------- /libs/rf_messages.h: -------------------------------------------------------------------------------- 1 | /** @file rf_messages.h 2 | * 3 | * @author Wassim FILALI 4 | * 5 | * @compiler IAR STM8 6 | * 7 | * 8 | * $Date: 12.03.2017 9 | 25.03.2017 - renamed from nRF_P2P.h to rf_messages.h 10 | * $Revision: 11 | * 12 | */ 13 | //When using the Higher level p2p RF Functions, 14 | //userRxCallBack() must not be instantiated, as it is handled here 15 | //if the user needs to receive from RF, he has to chose one of 16 | // - requests 17 | // - broadcasts 18 | 19 | #include "commonTypes.h" 20 | 21 | #define P2P_HEADER_BITS_MASK 0xE0 22 | 23 | //bit 7 Broadcast or Directed Message 24 | #define P2P_BROADCAST_MASK 0x80 25 | 26 | #define P2P_BIT7_BROADCAST 0x80 27 | #define P2P_BIT7_DIRECTED 0x00 28 | //bit 6 msgAck or ReqResp 29 | #define P2P_PKT_TYPE_MASK 0x40 30 | #define P2P_PKT_TYPE_MSQ_ACK 0x40 31 | #define P2P_MSGACK_NEG ~0x40 32 | 33 | //if bit 7 is Directed : 34 | #define P2P_BIT6_MSGACK 0x40 35 | #define P2P_BIT6_REQRESP 0x00 36 | 37 | //bit 5 msg or ack 38 | #define P2P_REQUEST_MASK 0x20 39 | #define P2P_MESSAGE_MASK 0x20 40 | #define P2P_ACK_NEG ~0x20 41 | 42 | //if bit 6 is MSGACK: 43 | #define P2P_MESSAGE 0x20 44 | #define P2P_ACK 0x00 45 | //if bit 6 is REQRESP: 46 | #define P2P_BIT5_MESSAGE 0x20 47 | #define P2P_BIT5_ACK 0x00 48 | 49 | //acknowledge transmission 50 | BYTE p2p_send(BYTE payload_size); 51 | 52 | BYTE rf_ping(BYTE Dest); 53 | 54 | BYTE rf_rgb_set(BYTE Dest,RGBColor_t Color); 55 | 56 | 57 | //------------ configuration functions ------------ 58 | void rf_set_retries(BYTE nb_retries); 59 | void rf_set_ack_delay(uint16_t delay); 60 | -------------------------------------------------------------------------------- /libs/rf_protocol.c: -------------------------------------------------------------------------------- 1 | /** @file rf_protocol.c 2 | * 3 | * @author Wassim FILALI STM8L 4 | * 5 | * @compiler IAR STM8 6 | * 7 | * 8 | * $Date: 29.10.2016 - creation 9 | * $Revision: 10 | * 11 | */ 12 | 13 | #include "rf_protocol.h" 14 | 15 | //for printf 16 | #include "uart.h" 17 | 18 | 19 | 20 | void rf_get_tx_alive_3B(BYTE NodeId, BYTE* tx_data) 21 | { 22 | tx_data[0]= rf_pid_alive; 23 | tx_data[1]= NodeId; 24 | tx_data[2]= tx_data[0] ^ NodeId; 25 | } 26 | 27 | //Rx 3 Bytes 28 | void rx_alive(BYTE src_NodeId) 29 | { 30 | printf("NodeId:"); 31 | UARTPrintf_uint(src_NodeId); 32 | printf_ln(";is:Alive"); 33 | } 34 | 35 | // Reset 36 | void rf_get_tx_reset_3B(BYTE NodeId, BYTE* tx_data) 37 | { 38 | tx_data[0]= rf_pid_reset; 39 | tx_data[1]= NodeId; 40 | tx_data[2]= tx_data[0] ^ NodeId; 41 | } 42 | void rx_reset(BYTE src_NodeId) 43 | { 44 | printf("NodeId:"); 45 | UARTPrintf_uint(src_NodeId); 46 | printf_ln(";was:Reset"); 47 | } 48 | 49 | //Rx 5 Bytes 50 | void rx_light(BYTE src_NodeId,BYTE *rxPayload,BYTE rx_PayloadSize) 51 | { 52 | unsigned int SensorVal; 53 | printf("NodeId:"); 54 | printf_uint(src_NodeId); 55 | printf(";Light:"); 56 | SensorVal = rxPayload[0]; 57 | SensorVal <<= 4;//shift to make place for the 4 LSB 58 | SensorVal = SensorVal + (0x0F & rxPayload[1]); 59 | printf_uint(SensorVal); 60 | printf_eol(); 61 | } 62 | 63 | //Rx 4 Bytes 64 | void rx_magnet(BYTE src_NodeId,BYTE *rxPayload,BYTE rx_PayloadSize) 65 | { 66 | printf("NodeId:"); 67 | printf_uint(src_NodeId); 68 | printf(";Magnet:"); 69 | if(rxPayload[0] == 0) 70 | { 71 | printf_ln("Low"); 72 | } 73 | else 74 | { 75 | printf_ln("High"); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /libs/rf_protocol.h: -------------------------------------------------------------------------------- 1 | /** @file rf_protocol.h 2 | * 3 | * @author Wassim FILALI 4 | * 5 | * @compiler IAR STM8 6 | * 7 | * 8 | * $Date: 29.10.2016 - creation 9 | * $Date: 18.11.2017 - update to Mesh Protocol 2.0 10 | * $Revision: 2 11 | * 12 | */ 13 | 14 | #include "commonTypes.h" 15 | 16 | 17 | #define rfi_size 0x00 18 | #define rfi_ctr 0x01 19 | #define rfi_pid 0x02 20 | #define rfi_src 0x03 21 | #define rfi_dst 0x04 22 | #define rfi_broadcast_header_size 0x04 23 | #define rfi_broadcast_payload_offset 0x04 24 | #define rfi_p2p_header_size 0x05 25 | #define rfi_p2p_payload_offset 0x05 26 | 27 | //bit 7 28 | #define rf_ctr_Broadcast 0x80 29 | #define rf_ctr_Peer2Peer 0x00 30 | //bit 6 31 | #define rf_ctr_Msg_Ack 0x40 32 | #define rf_ctr_ReqResp 0x00 33 | //bit 5 34 | #define rf_ctr_Message 0x20 35 | #define rf_ctr_Acknowledge 0x00 36 | #define rf_ctr_Request 0x20 37 | #define rf_ctr_Response 0x00 38 | //bit 4 39 | #define rf_ctr_Send_Ack 0x10 40 | #define rf_ctr_No_Ack 0x00 41 | //bits 3-0 42 | #define rf_ctr_ttl_mask 0x0F 43 | #define rf_ctr_ttl_clear 0xF0 44 | 45 | 46 | #define rf_pid_ping 0x01 47 | #define rf_pid_switchChan 0x03 48 | #define rf_pid_reset 0x04 49 | #define rf_pid_alive 0x05 50 | #define rf_pid_temperature 0x08 51 | #define rf_pid_light 0x07 52 | #define rf_pid_bme280 0x0A 53 | #define rf_pid_rgb 0x0B 54 | #define rf_pid_magnet 0x0C 55 | 56 | 57 | // Alive RF ping 58 | void rf_get_tx_alive_3B(BYTE NodeId, BYTE* tx_data); 59 | void rx_alive(BYTE src_NodeId);//Rx 3 Bytes 60 | 61 | // Reset 62 | void rf_get_tx_reset_3B(BYTE NodeId, BYTE* tx_data); 63 | void rx_reset(BYTE src_NodeId); 64 | 65 | //should move to max44009 lib 66 | void rx_light(BYTE src_NodeId,BYTE *rxPayload,BYTE rx_PayloadSize); 67 | 68 | //should move to magnet lib 69 | void rx_magnet(BYTE src_NodeId,BYTE *rxPayload,BYTE rx_PayloadSize); 70 | 71 | -------------------------------------------------------------------------------- /libs/spi_stm8x.h: -------------------------------------------------------------------------------- 1 | /** @file nRF_LowLevel.h 2 | * 3 | * @author Wassim FILALI, inspired from nRF24L01P-EK 4 | * 5 | * @compiler IAR STM8 6 | * 7 | * This low level is applied on the STM8103F3 so this should be the only file 8 | * to modify when porting this to another MCU 9 | * 10 | * $Date: 20.09.2015 11 | * $Revision: 12 | * 13 | */ 14 | 15 | //for BYTE 16 | #include "commonTypes.h" 17 | 18 | //------------------------Low Level API------------------------ 19 | 20 | void SPI_Init_ChipEnable_Pin(); 21 | 22 | BYTE CE_Pin_getstate(); 23 | 24 | void CE_Pin_LowDisable(); 25 | 26 | void CE_Pin_HighEnable(); 27 | 28 | void SPI_Init_ChipSelect_Pin(); 29 | 30 | void CSN_Pin_LowSelect(); 31 | 32 | void CSN_Pin_HighDisable(); 33 | 34 | void SPI_Init_SCK_MOSI_MISO_Pins(); 35 | 36 | void SPI_Init_Peripheral(); 37 | 38 | BYTE SPI_WriteRead(BYTE Data); 39 | -------------------------------------------------------------------------------- /libs/temp_ds18b20.h: -------------------------------------------------------------------------------- 1 | /** @file temp_ds18b20.h 2 | * 3 | * @author Wassim FILALI 4 | * Inferred from the Datasheet 5 | * 6 | * 7 | * @compiler IAR STM8 8 | * 9 | * 10 | * started on local project on 12.10.2015 11 | * this file was created for refactoring on 26.12.2015 12 | * $Date: 26.12.2015 13 | * $Revision: 14 | * 15 | */ 16 | 17 | #include "commonTypes.h" 18 | 19 | void Initialise_OneWire_Pin_A2(); 20 | 21 | void OneWire_Reset(); 22 | 23 | BYTE OneWire_CheckPresence(); 24 | 25 | BYTE OneWire_Init(); 26 | 27 | BYTE OneWire_ReadBit(); 28 | 29 | void OneWire_WriteByte(BYTE byte); 30 | 31 | BYTE OneWire_ReadByte(); 32 | 33 | BYTE DS18B20_Single_ReadRom(BYTE * rom); 34 | 35 | BYTE DS18B20_Single_ReadScratchPad(BYTE * sp,BYTE length); 36 | 37 | BYTE DS18B20_Single_ReadTemperature(BYTE * data); 38 | 39 | void rx_temperature_ds18b20(BYTE src_NodeId,BYTE *rxPayload,BYTE rx_PayloadSize); 40 | 41 | void UARTPrint_DS18B20_Temperature(BYTE * data); 42 | -------------------------------------------------------------------------------- /libs/timer2_pwm.h: -------------------------------------------------------------------------------- 1 | /** @file timer2_pwm.h 2 | * 3 | * @author Wassim FILALI 4 | * 5 | * @compiler IAR STM8S 6 | * 7 | * 8 | * $Date: 25.02.2017 9 | * $Revision: 10 | * 11 | */ 12 | 13 | //------------------------------ pwm ------------------------------ 14 | #include "commonTypes.h" 15 | //----------------------- SMARTIO Board Layout -------------------- 16 | // -> Pin D3 => Timer2 Chan 0 17 | // -> Pin D2 => Timer2 Chan 1 18 | // -> Pin D1 => Timer2 Chan 2 19 | // -> Pin C7 => Timer2 Chan 3 20 | // -> Pin C6 => Timer2 Chan 4 21 | // -> Pin C5 => Timer2 Chan 5 22 | // -> Pin C4 => Timer2 Chan 6 23 | // -> Pin C3 => Timer2 Chan 7 24 | //------------------------------ Interrupts ------------------------------ 25 | // -> Timer1 OVERFLOW IRQ 26 | //---------------------------------------------------------------------------- 27 | 28 | #define TIMER2_PWM_CH0 PD_ODR_ODR3 29 | #define TIMER2_PWM_CH1 PD_ODR_ODR2 30 | #define TIMER2_PWM_CH2 PD_ODR_ODR1 31 | #define TIMER2_PWM_CH3 PC_ODR_ODR7 32 | #define TIMER2_PWM_CH4 PC_ODR_ODR6 33 | #define TIMER2_PWM_CH5 PC_ODR_ODR5 34 | #define TIMER2_PWM_CH6 PC_ODR_ODR4 35 | #define TIMER2_PWM_CH7 PC_ODR_ODR3 36 | 37 | void timer2_pwm_init(); 38 | 39 | //output function 40 | void timer2_pwm_set_level(BYTE channel, uint16_t level); 41 | 42 | -------------------------------------------------------------------------------- /libs/uart.h: -------------------------------------------------------------------------------- 1 | /** @file uart.h 2 | * 3 | * @author Wassim FILALI 4 | * 5 | * @compiler IAR STM8 6 | * 7 | * 8 | * $Date: 20.09.2015 9 | * $Revision: 10 | * 11 | */ 12 | 13 | #include "commonTypes.h" 14 | 15 | //First configure, important that this file is included before the other headers that will conditionally declare the extern variables 16 | //#include "uart_config.h" for flags,...,UART_CALLBACK_POLLING 17 | #include "uart_config.h" 18 | 19 | 20 | //for InitialiseUART(); putc(char c); printf(char const *message); 21 | #include "uart_stm8x.h" 22 | 23 | #define printf_byte UARTPrintfHex 24 | #define printf_hex UARTPrintfHex 25 | #define printf_uint UARTPrintf_uint 26 | #define printf_tab UARTPrintfHexTable 27 | #define printf_eol(); UARTPrintfLn(""); 28 | #define printf_ln(X); UARTPrintfLn(X); 29 | 30 | void UARTPrintfLn(char const *message); 31 | 32 | void UARTPrintfHex(unsigned char val); 33 | 34 | void UARTPrintfHexTable(unsigned char *pval,unsigned char length); 35 | 36 | void UARTPrintfHexLn(unsigned char val); 37 | 38 | void UARTPrintf_sint(signed int num); 39 | 40 | void UARTPrintf_uint(U16_t num); 41 | 42 | void print_data_tab(unsigned char *pval,unsigned char length); 43 | 44 | #if UART_CALLBACK_POLLING == 1 45 | void uart_rx_user_poll(); 46 | #endif 47 | -------------------------------------------------------------------------------- /libs/uart_stm8x.h: -------------------------------------------------------------------------------- 1 | /** @file uart_stm8x.h 2 | * 3 | * @author Wassim FILALI 4 | * 5 | * @compiler IAR STM8 6 | * 7 | * 8 | * $Date: 26.10.2016 9 | * $Revision: 10 | * 11 | */ 12 | 13 | #include "uart_config.h" 14 | 15 | #if UART_ENABLE == 1 16 | #define uart_init uart_init_impl 17 | #define putc putc_impl 18 | #define printf printf_impl 19 | 20 | void uart_init(); 21 | void putc(char c); 22 | void printf(char const *message); 23 | #else 24 | #define uart_init(X) 25 | #define putc(X) 26 | #define printf(X) 27 | #endif /*UART_ENABLE == 1*/ 28 | 29 | 30 | //if interrupt mode, otherwise not declared 31 | #if UART_USE_RX_INETRRUPT == 1 32 | extern BYTE uart_echo; 33 | //published externally only if the user needs to be polling himself 34 | //#include "uart_config.h" for UART_CALLBACK_POLLING and then conditionally for UART_FRAME_SIZE 35 | #if UART_CALLBACK_POLLING == 1 36 | extern BYTE uart_rx_user_callback_pending; 37 | extern BYTE uart_rx_user_callback_performed; 38 | extern BYTE uart_BUFFER[UART_FRAME_SIZE]; 39 | extern BYTE uart_index; 40 | #endif 41 | #endif 42 | -------------------------------------------------------------------------------- /light_dimmer/README.md: -------------------------------------------------------------------------------- 1 | # Light Dimmer 2 | ## Used Boards 3 | - [ServoMotors Controller PCB](https://github.com/wassfila/STM8_IoT_Boards) 4 | 5 | 6 | 7 | - [4CH AC Light Dimmer Triac](https://www.facebook.com/krida.electronics) 8 | 9 | 10 | 11 | # Servo Board Modif 12 | - STM8S module modified : 3.3V regulator removed, joined 3.3 to 5V 13 | 14 | # Sync Signal 15 | 16 | 17 | 18 | 19 | # Program Flow 20 | ## Dimming Triggers Control 21 | - Sync Pulse Interrupt : starts the Timer1 22 | - Timer 1 step : 1 us 23 | - Timer 1 with 4 Channels Output compare Interrupts generation 24 | - Pulse of 10 us Trigger generated during the interrupt 25 | 26 | ## Current sensing 27 | - ACS712 ELCTR-05B-T => 185 mV/A 28 | - 0A => 2.5 V => ADC_VAL = 512 29 | - 1A => 2.685 V => ADC_VAL = 550 30 | 31 | # Consumption 32 | - total Boards consumption (Servo Boards + Dimmer Logic 5V part + ASC712) : 27 mA 33 | 34 | # Current signal 35 | - Noisiny sensor ACS712 : with no current => min_c = -17 ; max_c = 14 ; 37u => 1A 36 | -------------------------------------------------------------------------------- /light_dimmer/firmware/current_watch/current_watch.ewt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2 5 | 6 | Debug 7 | 8 | STM8 9 | 10 | 1 11 | 12 | 13 | Release 14 | 15 | STM8 16 | 17 | 0 18 | 19 | 20 | libs 21 | 22 | $PROJ_DIR$\..\..\..\libs\adc.c 23 | 24 | 25 | $PROJ_DIR$\..\..\..\libs\adc.h 26 | 27 | 28 | $PROJ_DIR$\..\..\..\libs\clock_led.c 29 | 30 | 31 | $PROJ_DIR$\..\..\..\libs\clock_led.h 32 | 33 | 34 | $PROJ_DIR$\..\..\..\libs\commonTypes.h 35 | 36 | 37 | $PROJ_DIR$\..\..\..\libs\light_dimmer_krida.c 38 | 39 | 40 | $PROJ_DIR$\..\..\..\libs\light_dimmer_krida.h 41 | 42 | 43 | $PROJ_DIR$\..\..\..\libs\uart.c 44 | 45 | 46 | $PROJ_DIR$\..\..\..\libs\uart.h 47 | 48 | 49 | $PROJ_DIR$\..\..\..\libs\uart_stm8x.c 50 | 51 | 52 | $PROJ_DIR$\..\..\..\libs\uart_stm8x.h 53 | 54 | 55 | 56 | $PROJ_DIR$\deviceType.h 57 | 58 | 59 | $PROJ_DIR$\main.c 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /light_dimmer/firmware/current_watch/deviceType.h: -------------------------------------------------------------------------------- 1 | #define DEVICE_STM8S 1 2 | -------------------------------------------------------------------------------- /light_dimmer/firmware/current_watch/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | main.c for 4 | IoT_Frameworks 5 | \light_dimmer 6 | \simple_monitor 7 | 8 | started 05.11.2016 9 | 10 | */ 11 | 12 | //---------- Light Dimmer with servo Board Layout ---------- 13 | 14 | //------------------------------ PIO ------------------------------ 15 | // Test Led -> Pin B5 16 | // DIMMER_SYNC -> Pin C3 17 | // CURRENT_SENSE -> Pin D2 18 | // DIMMER_CH1 -> Pin C4 19 | // DIMMER_CH2 -> Pin C5 20 | // DIMMER_CH3 -> Pin C6 21 | // DIMMER_CH4 -> Pin C7 22 | //------------------------------ Interrupts ------------------------------ 23 | // Sync Interrupt -> PortC IRQ 24 | // Channel Triggers On -> Timer1 CAPCOM IRQ 25 | // Channel Triggers Reset -> Timer1 OVERFLOW IRQ 26 | // ADC Measures -> Timer2 OVERFLOW IRQ 27 | //---------------------------------------------------------------------------- 28 | 29 | 30 | 31 | #include "uart.h" 32 | #include "clock_led.h" 33 | 34 | #include "light_dimmer_krida.h" 35 | #include 36 | 37 | #include "adc.h" 38 | 39 | int main( void ) 40 | { 41 | 42 | dimmer_init();//fast config - enables the PB4 interrupt 43 | 44 | BYTE AliveActiveCounter = 0; 45 | 46 | InitialiseSystemClock(); 47 | 48 | 49 | Initialise_TestLed_GPIO_B5(); 50 | Test_Led_Off(); 51 | 52 | uart_init(); 53 | 54 | printf_eol(); 55 | printf_ln("__________________________________________________"); 56 | printf_ln("IoT_Frameworks\\light_dimmer\\simple_monitor\\"); 57 | 58 | dimmer_set_level(0,1800);//60us is the Sync shift + 10 to be in the positive section 59 | dimmer_set_level(1,2200);//60us is the Sync shift 60 | dimmer_set_level(2,2600);//60us is the Sync shift 61 | dimmer_set_level(3,3000);//60us is the Sync shift 62 | 63 | //adc 64 | #define DEF_ADC_TIMER2 65 | #ifdef DEF_ADC_TIMER2 66 | adc_init(AIN3_PD2,ADC_TIMER2); 67 | #else 68 | adc_init(AIN3_PD2,ADC_SINGLE_SHOT); 69 | #endif 70 | 71 | __enable_interrupt(); 72 | 73 | 74 | #ifdef DEF_ADC_TIMER2 75 | adc_start(); 76 | #endif 77 | 78 | 79 | 80 | U16_t last_count = get_int_count(); 81 | while (1) 82 | { 83 | 84 | printf("int count: "); 85 | U16_t count = get_int_count(); 86 | printf_uint(count - last_count); 87 | last_count = count; 88 | printf_eol(); 89 | 90 | #ifdef DEF_ADC_TIMER2 91 | adc_print_vals(); 92 | adc_acs712_print_current(); 93 | #else 94 | printf("adc_read() = "); 95 | uint16_t val = adc_read(); 96 | printf_uint(val); 97 | printf_eol(); 98 | #endif 99 | 100 | AliveActiveCounter++;//Why are you counting ? 101 | 102 | Test_Led_Off(); 103 | delay_ms(4900); 104 | 105 | Test_Led_On(); 106 | delay_ms(100); 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /light_dimmer/firmware/dimmer_solo/deviceType.h: -------------------------------------------------------------------------------- 1 | #define DEVICE_STM8S 1 2 | -------------------------------------------------------------------------------- /light_dimmer/firmware/dimmer_solo/dimmer_solo.ewt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2 5 | 6 | Debug 7 | 8 | STM8 9 | 10 | 1 11 | 12 | 13 | Release 14 | 15 | STM8 16 | 17 | 0 18 | 19 | 20 | libs 21 | 22 | $PROJ_DIR$\..\..\..\libs\clock_led.c 23 | 24 | 25 | $PROJ_DIR$\..\..\..\libs\clock_led.h 26 | 27 | 28 | $PROJ_DIR$\..\..\..\libs\light_dimmer_krida.c 29 | 30 | 31 | $PROJ_DIR$\..\..\..\libs\light_dimmer_krida.h 32 | 33 | 34 | $PROJ_DIR$\..\..\..\libs\uart.c 35 | 36 | 37 | $PROJ_DIR$\..\..\..\libs\uart.h 38 | 39 | 40 | $PROJ_DIR$\..\..\..\libs\uart_stm8x.c 41 | 42 | 43 | $PROJ_DIR$\..\..\..\libs\uart_stm8x.h 44 | 45 | 46 | 47 | $PROJ_DIR$\deviceType.h 48 | 49 | 50 | $PROJ_DIR$\main.c 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /light_dimmer/firmware/dimmer_solo/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | main.c for 4 | IoT_Frameworks 5 | \light_dimmer 6 | \simple_monitor 7 | 8 | started 05.11.2016 9 | 10 | */ 11 | 12 | //Test Led is Port B Pin 5 13 | 14 | 15 | #include "uart.h" 16 | #include "clock_led.h" 17 | 18 | #include "light_dimmer_krida.h" 19 | 20 | #include 21 | 22 | int main( void ) 23 | { 24 | 25 | dimmer_init();//fast config - enables the PB4 interrupt 26 | 27 | BYTE AliveActiveCounter = 0; 28 | 29 | InitialiseSystemClock(); 30 | 31 | 32 | Initialise_TestLed_GPIO_B5(); 33 | Test_Led_Off(); 34 | 35 | uart_init(); 36 | 37 | printf_eol(); 38 | printf_ln("__________________________________________________"); 39 | printf_ln("IoT_Frameworks\\light_dimmer\\simple_monitor\\"); 40 | 41 | dimmer_set_level(0,1800);//60us is the Sync shift + 10 to be in the positive section 42 | dimmer_set_level(1,2200);//60us is the Sync shift 43 | dimmer_set_level(2,2600);//60us is the Sync shift 44 | dimmer_set_level(3,3000);//60us is the Sync shift 45 | 46 | __enable_interrupt(); 47 | U16_t last_count = get_int_count(); 48 | while (1) 49 | { 50 | 51 | printf("int count: "); 52 | U16_t count = get_int_count(); 53 | printf_uint(count - last_count); 54 | last_count = count; 55 | printf_eol(); 56 | 57 | AliveActiveCounter++;//Why are you counting ? 58 | 59 | Test_Led_Off(); 60 | delay_ms(4900); 61 | 62 | Test_Led_On(); 63 | delay_ms(100); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /light_dimmer/firmware/dimmer_solo/settings/dimmer_solo.Debug.cspy.bat: -------------------------------------------------------------------------------- 1 | @REM This batch file has been generated by the IAR Embedded Workbench 2 | @REM C-SPY Debugger, as an aid to preparing a command line for running 3 | @REM the cspybat command line utility using the appropriate settings. 4 | @REM 5 | @REM Note that this file is generated every time a new debug session 6 | @REM is initialized, so you may want to move or rename the file before 7 | @REM making changes. 8 | @REM 9 | @REM You can launch cspybat by typing the name of this batch file followed 10 | @REM by the name of the debug file (usually an ELF/DWARF or UBROF file). 11 | @REM 12 | @REM Read about available command line parameters in the C-SPY Debugging 13 | @REM Guide. Hints about additional command line parameters that may be 14 | @REM useful in specific cases: 15 | @REM --download_only Downloads a code image without starting a debug 16 | @REM session afterwards. 17 | @REM --silent Omits the sign-on message. 18 | @REM --timeout Limits the maximum allowed execution time. 19 | @REM 20 | 21 | 22 | "C:\Program Files (x86)\IAR Systems\Embedded Workbench 7.0\common\bin\cspybat" "C:\Program Files (x86)\IAR Systems\Embedded Workbench 7.0\stm8\bin\stm8proc.dll" "C:\Program Files (x86)\IAR Systems\Embedded Workbench 7.0\stm8\bin\stm8stlink.dll" %1 --plugin "C:\Program Files (x86)\IAR Systems\Embedded Workbench 7.0\stm8\bin\stm8bat.dll" --backend -B "-p" "C:\Program Files (x86)\IAR Systems\Embedded Workbench 7.0\stm8\config\ddf\iostm8s103f3.ddf" "-d" "stlink" "--mcuname" "STM8S103F3P" 23 | 24 | 25 | -------------------------------------------------------------------------------- /light_dimmer/firmware/light_dimmer.eww: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | $WS_DIR$\current_watch\current_watch.ewp 6 | 7 | 8 | $WS_DIR$\dimmer_solo\dimmer_solo.ewp 9 | 10 | 11 | $WS_DIR$\light_server\light_server.ewp 12 | 13 | 14 | $WS_DIR$\sync_counter\sync_counter.ewp 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /light_dimmer/firmware/light_server/deviceType.h: -------------------------------------------------------------------------------- 1 | #define DEVICE_STM8S 1 2 | -------------------------------------------------------------------------------- /light_dimmer/firmware/light_server/light_server.ewt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2 5 | 6 | Debug 7 | 8 | STM8 9 | 10 | 1 11 | 12 | 13 | Release 14 | 15 | STM8 16 | 17 | 0 18 | 19 | 20 | libs 21 | 22 | $PROJ_DIR$\..\..\..\libs\adc.c 23 | 24 | 25 | $PROJ_DIR$\..\..\..\libs\adc.h 26 | 27 | 28 | $PROJ_DIR$\..\..\..\libs\clock_led.c 29 | 30 | 31 | $PROJ_DIR$\..\..\..\libs\clock_led.h 32 | 33 | 34 | $PROJ_DIR$\..\..\..\libs\cmdutils.c 35 | 36 | 37 | $PROJ_DIR$\..\..\..\libs\cmdutils.h 38 | 39 | 40 | $PROJ_DIR$\..\..\..\libs\commonTypes.h 41 | 42 | 43 | $PROJ_DIR$\..\..\..\libs\light_dimmer_krida.c 44 | 45 | 46 | $PROJ_DIR$\..\..\..\libs\light_dimmer_krida.h 47 | 48 | 49 | $PROJ_DIR$\..\..\..\libs\uart.c 50 | 51 | 52 | $PROJ_DIR$\..\..\..\libs\uart.h 53 | 54 | 55 | $PROJ_DIR$\..\..\..\libs\uart_stm8x.c 56 | 57 | 58 | $PROJ_DIR$\..\..\..\libs\uart_stm8x.h 59 | 60 | 61 | 62 | $PROJ_DIR$\deviceType.h 63 | 64 | 65 | $PROJ_DIR$\main.c 66 | 67 | 68 | $PROJ_DIR$\uart_config.h 69 | 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /light_dimmer/firmware/light_server/script.txt: -------------------------------------------------------------------------------- 1 | //the loop log 2 | logon 3 | logoff 4 | 5 | //dimes one channel 6 | dimm 0x00 0x08 0x98 7 | 8 | //dimms all channels together 9 | //very low value 10 | alldimm 0x08 0x98 11 | 12 | //Max Power 13 | alldimm 0x26 14 | 15 | 16 | //off 17 | adc_min = 495 18 | adc_avg = 509 19 | adc_max = 525 20 | 21 | //low 22 | adc_min = 460 23 | adc_avg = 509 24 | adc_max = 560 25 | min_c = -52 26 | max_c = 48 ; 37u => 1A 27 | 28 | //Max 29 | adc_min = 469 30 | adc_avg = 509 31 | adc_max = 552 32 | min_c = -43 33 | max_c = 40 ; 37u => 1A 34 | -------------------------------------------------------------------------------- /light_dimmer/firmware/light_server/timers_config.h: -------------------------------------------------------------------------------- 1 | /** @file timers_config.h 2 | * 3 | * @author Wassim FILALI 4 | * 5 | * 6 | * 7 | * $Date: 18.11.2016 8 | * $Revision: 9 | * 10 | */ 11 | 12 | 13 | //----------------------------------- FLAGS --------------------------------------- 14 | 15 | //TIMER2_USER_CALLBACK 16 | // 0 not used 17 | // 1 used 18 | #define TIMER2_USER_CALLBACK 1 19 | 20 | -------------------------------------------------------------------------------- /light_dimmer/firmware/light_server/uart_config.h: -------------------------------------------------------------------------------- 1 | /** @file uart_config.h 2 | * 3 | * @author Wassim FILALI 4 | * 5 | * 6 | * 7 | * $Date: 12.11.2016 8 | * $Revision: 9 | * 10 | */ 11 | #ifndef _UART_CONFIG_ 12 | #define _UART_CONFIG_ 13 | 14 | 15 | //----------------------------------- Interruptions --------------------------------------- 16 | //Flag: UART_USE_RX_INETRRUPT 17 | // 1 : Enabled 18 | // declares the IRQ and requires teh user to declare a uart_callback() function 19 | 20 | #define UART_USE_RX_INETRRUPT 1 21 | 22 | //Flag: UART_CALLBACK_POLLING 23 | // 1 : Enabled => 'uart_rx_user_callback_pending' has to be polled 24 | // consume 'uart_BUFFER' with 'uart_index', 25 | // acknowledge with 'uart_rx_user_callback_performed' 26 | // 0 : INTERRUPT => The 'uart_rx_user_callback()' will be called from the uart interrupt context 27 | // Flags dependencies 28 | // '#define UART_USE_RX_INETRRUPT 1' has to be set to 1 29 | #define UART_CALLBACK_POLLING 1 30 | 31 | 32 | #define UART_FRAME_SIZE 31 33 | 34 | //the terminal sends 13 35 | #define UART_EOL_C 13 36 | 37 | //Flag: UART_Through_RF_Delay 38 | //1 : Enabled this delay is added after every end of line to allow proper transmission of messages through radio 39 | //0 : Disabled, normal behaviour 40 | #define UART_Through_RF_Delay 1 41 | 42 | #endif /*_UART_CONFIG_*/ 43 | -------------------------------------------------------------------------------- /light_dimmer/firmware/sync_counter/deviceType.h: -------------------------------------------------------------------------------- 1 | #define DEVICE_STM8S 1 2 | -------------------------------------------------------------------------------- /light_dimmer/firmware/sync_counter/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | main.c for 4 | IoT_Frameworks 5 | \light_dimmer 6 | \simple_monitor 7 | 8 | started 05.11.2016 9 | 10 | */ 11 | 12 | //Test Led is Port B Pin 5 13 | 14 | 15 | #include "uart.h" 16 | #include "clock_led.h" 17 | 18 | #include "light_dimmer_krida.h" 19 | 20 | #include 21 | 22 | int main( void ) 23 | { 24 | 25 | dimmer_init();//fast config to keep triggers low - enables the PB4 interrupt 26 | 27 | BYTE AliveActiveCounter = 0; 28 | 29 | InitialiseSystemClock(); 30 | 31 | adc_inti(ADC_Channel_t::AIN3_PD2); 32 | 33 | Initialise_TestLed_GPIO_B5(); 34 | Test_Led_Off(); 35 | 36 | uart_init(); 37 | 38 | printf_eol(); 39 | printf_ln("__________________________________________________"); 40 | printf_ln("IoT_Frameworks\\light_dimmer\\simple_monitor\\"); 41 | 42 | __enable_interrupt(); 43 | 44 | while (1) 45 | { 46 | 47 | printf("int count: "); 48 | printf_uint(get_int_count()); 49 | printf_eol(); 50 | 51 | AliveActiveCounter++;//Why are you counting ? 52 | 53 | Test_Led_Off(); 54 | delay_ms(4900); 55 | 56 | Test_Led_On(); 57 | delay_ms(100); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /light_dimmer/firmware/sync_counter/sync_counter.ewt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2 5 | 6 | Debug 7 | 8 | STM8 9 | 10 | 1 11 | 12 | 13 | Release 14 | 15 | STM8 16 | 17 | 0 18 | 19 | 20 | libs 21 | 22 | $PROJ_DIR$\..\..\..\libs\clock_led.c 23 | 24 | 25 | $PROJ_DIR$\..\..\..\libs\clock_led.h 26 | 27 | 28 | $PROJ_DIR$\..\..\..\libs\commonTypes.h 29 | 30 | 31 | $PROJ_DIR$\..\..\..\libs\light_dimmer_krida.c 32 | 33 | 34 | $PROJ_DIR$\..\..\..\libs\light_dimmer_krida.h 35 | 36 | 37 | $PROJ_DIR$\..\..\..\libs\uart.c 38 | 39 | 40 | $PROJ_DIR$\..\..\..\libs\uart.h 41 | 42 | 43 | $PROJ_DIR$\..\..\..\libs\uart_stm8x.c 44 | 45 | 46 | $PROJ_DIR$\..\..\..\libs\uart_stm8x.h 47 | 48 | 49 | 50 | $PROJ_DIR$\deviceType.h 51 | 52 | 53 | $PROJ_DIR$\main.c 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /mesh_controller_interface/mesh_controller_interface.eww: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | $WS_DIR$\rf_p2p_tester\rf_p2p_tester.ewp 6 | 7 | 8 | $WS_DIR$\rf_tester\rf_tester.ewp 9 | 10 | 11 | $WS_DIR$\rfmaster\rfmaster.ewp 12 | 13 | 14 | $WS_DIR$\uarttester\uarttester.ewp 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /mesh_controller_interface/rf_p2p_tester/.gitignore: -------------------------------------------------------------------------------- 1 | Debug/ 2 | settings/ 3 | -------------------------------------------------------------------------------- /mesh_controller_interface/rf_p2p_tester/deviceType.h: -------------------------------------------------------------------------------- 1 | #define DEVICE_STM8S 1 2 | -------------------------------------------------------------------------------- /mesh_controller_interface/rf_p2p_tester/rgb_config.h: -------------------------------------------------------------------------------- 1 | /** @file rgb_config.h 2 | * 3 | * @author Wassim FILALI 4 | * 5 | * 6 | * 7 | * $Date: 27.02.2017 8 | * $Revision: 9 | * 10 | */ 11 | #ifndef _RGB_CONFIG_ 12 | #define _RGB_CONFIG_ 13 | 14 | //NB_LEDS : Number of LED to be supported which would derive the size of the memory 15 | // to be allocated Table[NB_LEDS*3] as that table will contain {R,G,B} Bytes per LED 16 | //1 - 255 : this parameter has for limit the size of the RAM and the 8bit counter => 255 17 | //the value of 256 == 0 was not tested 18 | //255 => 75% of RAM 19 | //#define NB_LEDS 216 20 | #define NB_LEDS 1 21 | 22 | //reverse the polarity of the PIO when going through a level shifter inverter 23 | // 1 : invert 24 | // 0 : do not invert 25 | #define RGB_IO_NEG 0 26 | 27 | 28 | //RGBLedPIN_A : the Port A pin number to be used, supported values for the Fixed Node v2 Target Board : 29 | // 2 => Not recommended as not High speed 30 | // 3 => Recommend with High speed setting 3.3 V driving 5V TTL input 31 | // recommended settings Vin min = 0.7Vdd ; 5V => 3.5V so 3.3 is not enough, not recommended but working 32 | #define RGBLedPIN_A 3 33 | 34 | #endif /*_RGB_CONFIG_*/ 35 | -------------------------------------------------------------------------------- /mesh_controller_interface/rf_p2p_tester/serial_log.txt: -------------------------------------------------------------------------------- 1 | rfId:0xE2;Error:dataSize not 11 but 10 2 | rfId:0xE2;Error:CRC 3 | __________________________________________________ 4 | 5 | sensors_logger\firmware_rf_dongle\rf_receiver_logger\ 6 | 7 | 8 | __________________________________________________ 9 | 10 | sensors_logger\firmware_rf_dongle\rf_receiver_logger\ 11 | 12 | rfId:0xE2;Error:CRC 13 | NodeId:6,is:Alive 14 | 15 | __________________________________________________ 16 | 17 | sensors_logger\firmware_rf_dongle\rf_receiver_logger\ 18 | 19 | NodeId:4,is:Alive 20 | NodeId:7;BME280: 0x07 53 F5 00 7E F6 00 73 EB 21 | NodeId:7;BME280: 0x07 53 F7 00 7E F7 00 73 07 22 | NodeId:7;BME280: 0x07 53 F9 00 7E F5 00 73 BB 23 | NodeId:6,is:Alive 24 | NodeId:6,Light: 1701 25 | NodeId:4,is:Alive 26 | NodeId:7;BME280: 0x07 53 F7 00 7E F7 00 73 6C 27 | NodeId:7;BME280: 0x07 53 F3 00 7E F1 00 74 3F 28 | NodeId:6,is:Alive 29 | NodeId:6,Light: 1700 30 | NodeId:7;BME280: 0x07 53 F6 00 7E ED 00 73 70 31 | NodeId:4,is:Alive 32 | NodeId:7;BME280: 0x07 53 F5 00 7E EF 00 74 44 33 | -------------------------------------------------------------------------------- /mesh_controller_interface/rf_p2p_tester/uart_config.h: -------------------------------------------------------------------------------- 1 | /** @file uart_config.h 2 | * 3 | * @author Wassim FILALI 4 | * 5 | * 6 | * 7 | * $Date: 12.11.2016 8 | * $Revision: 9 | * 10 | */ 11 | #ifndef _UART_CONFIG_ 12 | #define _UART_CONFIG_ 13 | 14 | //UART_BAUD_RATE possible values 115200 9600 15 | #define UART_BAUD_RATE 115200 16 | 17 | //----------------------------------- Interruptions --------------------------------------- 18 | //Flag: UART_USE_RX_INETRRUPT 19 | // 1 : Enabled 20 | // declares the IRQ and requires teh user to declare a uart_callback() function 21 | 22 | #define UART_USE_RX_INETRRUPT 1 23 | 24 | #if UART_USE_RX_INETRRUPT == 1 25 | #define UART_ECHO 1 26 | #endif 27 | //Flag: UART_CALLBACK_POLLING 28 | // 1 : Enabled => simplified to just calling uart_rx_user_poll() 29 | // which will if necessary call the uart_rx_user_callback() 30 | // The work behind is : 31 | // 'uart_rx_user_callback_pending' will be polled 32 | // consume 'uart_BUFFER' with 'uart_index', 33 | // acknowledge with 'uart_rx_user_callback_performed' 34 | // 0 : INTERRUPT => The 'uart_rx_user_callback()' will be called from the uart interrupt context 35 | // Flags dependencies 36 | // '#define UART_USE_RX_INETRRUPT 1' has to be set to 1 37 | #define UART_CALLBACK_POLLING 0 38 | 39 | 40 | #define UART_FRAME_SIZE 31 41 | 42 | //the terminal sends 13 43 | #define UART_EOL_C 13 44 | 45 | //Flag: UART_Through_RF_Delay 46 | //1 : Enabled this delay is added after every end of line to allow proper transmission of messages through radio 47 | //0 : Disabled, normal behaviour 48 | #define UART_Through_RF_Delay 0 49 | 50 | #endif /*_UART_CONFIG_*/ 51 | -------------------------------------------------------------------------------- /mesh_controller_interface/rf_tester/.gitignore: -------------------------------------------------------------------------------- 1 | Debug/ 2 | settings/ 3 | -------------------------------------------------------------------------------- /mesh_controller_interface/rf_tester/deviceType.h: -------------------------------------------------------------------------------- 1 | #define DEVICE_STM8S 1 2 | -------------------------------------------------------------------------------- /mesh_controller_interface/rf_tester/rf_tester.ewt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2 5 | 6 | Debug 7 | 8 | STM8 9 | 10 | 1 11 | 12 | 13 | Release 14 | 15 | STM8 16 | 17 | 0 18 | 19 | 20 | libs 21 | 22 | $PROJ_DIR$\..\..\libs\clock_led.c 23 | 24 | 25 | $PROJ_DIR$\..\..\libs\clock_led.h 26 | 27 | 28 | $PROJ_DIR$\..\..\libs\cmdutils.c 29 | 30 | 31 | $PROJ_DIR$\..\..\libs\cmdutils.h 32 | 33 | 34 | $PROJ_DIR$\..\..\libs\nRF.c 35 | 36 | 37 | $PROJ_DIR$\..\..\libs\nRF.h 38 | 39 | 40 | $PROJ_DIR$\..\..\libs\nRF_IRQ_stm8x.c 41 | 42 | 43 | $PROJ_DIR$\..\..\libs\nRF_IRQ_stm8x.h 44 | 45 | 46 | $PROJ_DIR$\..\..\libs\nRF_RegText.c 47 | 48 | 49 | $PROJ_DIR$\..\..\libs\nRF_RegText.h 50 | 51 | 52 | $PROJ_DIR$\..\..\libs\nRF_SPI.c 53 | 54 | 55 | $PROJ_DIR$\..\..\libs\nRF_SPI.h 56 | 57 | 58 | $PROJ_DIR$\..\..\libs\nRF_Tx.c 59 | 60 | 61 | $PROJ_DIR$\..\..\libs\nRF_Tx.h 62 | 63 | 64 | $PROJ_DIR$\..\..\libs\rf_protocol.c 65 | 66 | 67 | $PROJ_DIR$\..\..\libs\rf_protocol.h 68 | 69 | 70 | $PROJ_DIR$\..\..\libs\spi_stm8x.c 71 | 72 | 73 | $PROJ_DIR$\..\..\libs\spi_stm8x.h 74 | 75 | 76 | $PROJ_DIR$\..\..\libs\uart.c 77 | 78 | 79 | $PROJ_DIR$\..\..\libs\uart.h 80 | 81 | 82 | $PROJ_DIR$\..\..\libs\uart_stm8x.c 83 | 84 | 85 | $PROJ_DIR$\..\..\libs\uart_stm8x.h 86 | 87 | 88 | 89 | $PROJ_DIR$\deviceType.h 90 | 91 | 92 | $PROJ_DIR$\main_rfTester.c 93 | 94 | 95 | $PROJ_DIR$\nRF_Configuration.h 96 | 97 | 98 | $PROJ_DIR$\uart_config.h 99 | 100 | 101 | 102 | 103 | -------------------------------------------------------------------------------- /mesh_controller_interface/rf_tester/serial_log.txt: -------------------------------------------------------------------------------- 1 | rfId:0xE2;Error:dataSize not 11 but 10 2 | rfId:0xE2;Error:CRC 3 | __________________________________________________ 4 | 5 | sensors_logger\firmware_rf_dongle\rf_receiver_logger\ 6 | 7 | 8 | __________________________________________________ 9 | 10 | sensors_logger\firmware_rf_dongle\rf_receiver_logger\ 11 | 12 | rfId:0xE2;Error:CRC 13 | NodeId:6,is:Alive 14 | 15 | __________________________________________________ 16 | 17 | sensors_logger\firmware_rf_dongle\rf_receiver_logger\ 18 | 19 | NodeId:4,is:Alive 20 | NodeId:7;BME280: 0x07 53 F5 00 7E F6 00 73 EB 21 | NodeId:7;BME280: 0x07 53 F7 00 7E F7 00 73 07 22 | NodeId:7;BME280: 0x07 53 F9 00 7E F5 00 73 BB 23 | NodeId:6,is:Alive 24 | NodeId:6,Light: 1701 25 | NodeId:4,is:Alive 26 | NodeId:7;BME280: 0x07 53 F7 00 7E F7 00 73 6C 27 | NodeId:7;BME280: 0x07 53 F3 00 7E F1 00 74 3F 28 | NodeId:6,is:Alive 29 | NodeId:6,Light: 1700 30 | NodeId:7;BME280: 0x07 53 F6 00 7E ED 00 73 70 31 | NodeId:4,is:Alive 32 | NodeId:7;BME280: 0x07 53 F5 00 7E EF 00 74 44 33 | -------------------------------------------------------------------------------- /mesh_controller_interface/rf_tester/test_logs/Node0x09.txt: -------------------------------------------------------------------------------- 1 | ------------ output log 1 ------------ 2 | 3 | Rx Pings : 100 4 | 5 | ------------ output log 3 OK ------------ 6 | 7 | __________________________________________________ 8 | sensors_logger\firmware_rf_dongle\rf_tester\ 9 | Node Id: 9 10 | nRF_Config 11 | 12 | Config updated with : 0x31 ; reread 0x31 ; STATUS: 0x0E : No Data Ready i; No Data Sent i; No Max Ret i; Rx Fifo Empty ; Available TX Fifo Locations; 13 | __________________________________________________ 14 | 15 | STATUS: 0x0E : No Data Ready i; No Data Sent i; No Max Ret i; Rx Fifo Empty ; Available TX Fifo Locations; 16 | CONFIG: 0x31 : RX IRQ Active; TX IRQ Masked; Max RT IRQ Masked; CRC Disabled; CRC 1 Bytes; Power Down; P RX Mode; 17 | ChipEnable Low 18 | Channel 2 selected : 2402 MHz 19 | Address Width : 5 bytes 20 | Rx Address P0: 0xE7 21 | Tx Address : 0xE7 22 | __________________________________________________ 23 | 24 | Rx Pings : 100 25 | Switched Channel:Channel 5 selected : 2405 MHz 26 | Rx Pings : 100 27 | Switched Channel:Channel 96 selected : 2496 MHz 28 | Rx Pings : 100 29 | Switched Channel:Channel 96 selected : 2496 MHz 30 | Switched Channel:Channel 2 selected : 2402 MHz 31 | -------------------------------------------------------------------------------- /mesh_controller_interface/rf_tester/test_logs/Node0x0C.txt: -------------------------------------------------------------------------------- 1 | ------------ test commands ------------ 2 | 3 | //Set the Host RF Channel, to the tested channel 4 | stch 0x02 5 | //test with 100 pings 6 | ping 0x09 0x64 7 | //request from Node 0x09 to switch to RF channel 5 8 | rfch 0x09 0x05 9 | //ping 100 on this new channel 5 10 | ping 0x09 0x64 11 | //switch to channel 96 12 | rfch 0x09 0x60 13 | //ping another 100 times 14 | ping 0x09 0x64 15 | //switch back to channel 2 16 | rfch 0x09 0x60 17 | rfch 0x09 0x02 18 | 19 | ------------ output log 1 ------------ 20 | 21 | ping 0x09 0x64 22 | Node0x0C> 23 | Many Pings : 100/100 24 | chan 0x09 0x05 25 | Node0x0C> 26 | Channel Switch fail, have to ping now 27 | XXXX BUG XXXX => infinite loop found in "rf_ping_retries()" 28 | XXXX ISSUE XXXX => cannot change host channel, added stch, and renamed rfch 29 | 30 | ------------ output log 2 ------------ 31 | 32 | stch 0x02 33 | Channel 2 selected : 2402 MHz 34 | Node0x0C> 35 | ping 0x09 0x64 36 | Node0x0C> 37 | Many Pings : 94/100 38 | rfch 0x09 0x05 39 | Node0x0C> 40 | Channel Switch attempt failed, have to find the Target now : 41 | Channel Switch canceled: Channel 2 selected : 2402 MHz 42 | XXXX BUG XXXX => forgotten NodeId in rf switch channel request 43 | XXXX IMPROVEMENT XXXX => NodeId should be printed 44 | 45 | ------------ output log 3 OK ------------ 46 | 47 | sensors_logger\firmware_rf_dongle\rf_tester\ 48 | Node Id: 12 49 | nRF_Config 50 | 51 | Config updated with : 0x31 ; reread 0x31 ; STATUS: 0x0E : No Data Ready i; No Data Sent i; No Max Ret i; Rx Fifo Empty ; Available TX Fifo Locations; 52 | __________________________________________________ 53 | 54 | STATUS: 0x0E : No Data Ready i; No Data Sent i; No Max Ret i; Rx Fifo Empty ; Available TX Fifo Locations; 55 | CONFIG: 0x31 : RX IRQ Active; TX IRQ Masked; Max RT IRQ Masked; CRC Disabled; CRC 1 Bytes; Power Down; P RX Mode; 56 | ChipEnable Low 57 | Channel 2 selected : 2402 MHz 58 | Address Width : 5 bytes 59 | Rx Address P0: 0xE7 60 | Tx Address : 0xE7 61 | __________________________________________________ 62 | 63 | stch 0x02 64 | Channel 2 selected : 2402 MHz 65 | Node0x0C> 66 | ping 0x09 0x64 67 | Node0x0C> 68 | Many Pings : 100/100 69 | rfch 0x09 0x05 70 | Node0x0C> 71 | Channel Switched to : 5 72 | ping 0x09 0x64 73 | Node0x0C> 74 | Many Pings : 100/100 75 | rfch 0x09 0x60 76 | Node0x0C> 77 | Channel Switched to : 96 78 | ping 0x09 0x64 79 | Node0x0C> 80 | Many Pings : 100/100 81 | rfch 0x09 0x60 82 | Node0x0C> 83 | Channel Switched to : 96 84 | rfch 0x09 0x02 85 | Node0x0C> 86 | Channel Switched to : 2 87 | -------------------------------------------------------------------------------- /mesh_controller_interface/rf_tester/uart_config.h: -------------------------------------------------------------------------------- 1 | /** @file uart_config.h 2 | * 3 | * @author Wassim FILALI 4 | * 5 | * 6 | * 7 | * $Date: 12.11.2016 8 | * $Revision: 9 | * 10 | */ 11 | #ifndef _UART_CONFIG_ 12 | #define _UART_CONFIG_ 13 | 14 | //UART_BAUD_RATE possible values 115200 9600 15 | #define UART_BAUD_RATE 115200 16 | 17 | //----------------------------------- Interruptions --------------------------------------- 18 | //Flag: UART_USE_RX_INETRRUPT 19 | // 1 : Enabled 20 | // declares the IRQ and requires teh user to declare a uart_callback() function 21 | 22 | #define UART_USE_RX_INETRRUPT 1 23 | 24 | #if UART_USE_RX_INETRRUPT == 1 25 | #define UART_ECHO 1 26 | #endif 27 | //Flag: UART_CALLBACK_POLLING 28 | // 1 : Enabled => simplified to just calling uart_rx_user_poll() 29 | // which will if necessary call the uart_rx_user_callback() 30 | // The work behind is : 31 | // 'uart_rx_user_callback_pending' will be polled 32 | // consume 'uart_BUFFER' with 'uart_index', 33 | // acknowledge with 'uart_rx_user_callback_performed' 34 | // 0 : INTERRUPT => The 'uart_rx_user_callback()' will be called from the uart interrupt context 35 | // Flags dependencies 36 | // '#define UART_USE_RX_INETRRUPT 1' has to be set to 1 37 | #define UART_CALLBACK_POLLING 0 38 | 39 | 40 | #define UART_FRAME_SIZE 31 41 | 42 | //the terminal sends 13 43 | #define UART_EOL_C 13 44 | 45 | //Flag: UART_Through_RF_Delay 46 | //1 : Enabled this delay is added after every end of line to allow proper transmission of messages through radio 47 | //0 : Disabled, normal behaviour 48 | #define UART_Through_RF_Delay 0 49 | 50 | #endif /*_UART_CONFIG_*/ 51 | -------------------------------------------------------------------------------- /mesh_controller_interface/rfmaster/.gitignore: -------------------------------------------------------------------------------- 1 | Debug/ 2 | settings/ 3 | -------------------------------------------------------------------------------- /mesh_controller_interface/rfmaster/deviceType.h: -------------------------------------------------------------------------------- 1 | #define DEVICE_STM8S 1 2 | -------------------------------------------------------------------------------- /mesh_controller_interface/rfmaster/main_config.h: -------------------------------------------------------------------------------- 1 | /** @file main_config.h 2 | * 3 | * @author Wassim FILALI 4 | * 5 | * 6 | * 7 | * $Date: 18.11.2016 8 | * 9 | */ 10 | 11 | //Flag : RUN_EEPROM_SCRIPT 12 | // 1 : can use run_eeprom_script() with handle_command() instanciated 13 | // 0 : do not need to instanciate handle_command() 14 | 15 | #define RUN_EEPROM_SCRIPT 1 16 | -------------------------------------------------------------------------------- /mesh_controller_interface/rfmaster/rfmaster.ewt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2 5 | 6 | Debug 7 | 8 | STM8 9 | 10 | 1 11 | 12 | 13 | Release 14 | 15 | STM8 16 | 17 | 0 18 | 19 | 20 | libs 21 | 22 | $PROJ_DIR$\..\..\libs\clock_led.c 23 | 24 | 25 | $PROJ_DIR$\..\..\libs\clock_led.h 26 | 27 | 28 | $PROJ_DIR$\..\..\libs\cmdutils.c 29 | 30 | 31 | $PROJ_DIR$\..\..\libs\cmdutils.h 32 | 33 | 34 | $PROJ_DIR$\..\..\libs\commonTypes.h 35 | 36 | 37 | $PROJ_DIR$\..\..\libs\nRF.c 38 | 39 | 40 | $PROJ_DIR$\..\..\libs\nRF.h 41 | 42 | 43 | $PROJ_DIR$\..\..\libs\nRF_IRQ_stm8x.c 44 | 45 | 46 | $PROJ_DIR$\..\..\libs\nRF_IRQ_stm8x.h 47 | 48 | 49 | $PROJ_DIR$\..\..\libs\nRF_RegText.c 50 | 51 | 52 | $PROJ_DIR$\..\..\libs\nRF_RegText.h 53 | 54 | 55 | $PROJ_DIR$\..\..\libs\nRF_SPI.c 56 | 57 | 58 | $PROJ_DIR$\..\..\libs\nRF_SPI.h 59 | 60 | 61 | $PROJ_DIR$\..\..\libs\nRF_Tx.c 62 | 63 | 64 | $PROJ_DIR$\..\..\libs\nRF_Tx.h 65 | 66 | 67 | $PROJ_DIR$\..\..\libs\spi_stm8x.c 68 | 69 | 70 | $PROJ_DIR$\..\..\libs\spi_stm8x.h 71 | 72 | 73 | $PROJ_DIR$\..\..\libs\uart.c 74 | 75 | 76 | $PROJ_DIR$\..\..\libs\uart.h 77 | 78 | 79 | $PROJ_DIR$\..\..\libs\uart_stm8x.c 80 | 81 | 82 | $PROJ_DIR$\..\..\libs\uart_stm8x.h 83 | 84 | 85 | 86 | $PROJ_DIR$\deviceType.h 87 | 88 | 89 | $PROJ_DIR$\main.c 90 | 91 | 92 | $PROJ_DIR$\nRF_Configuration.h 93 | 94 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /mesh_controller_interface/rfmaster/script.txt: -------------------------------------------------------------------------------- 1 | node 0x0A 2 | rfcmdon 3 | rfcmdoff 4 | logon 5 | logoff 6 | logtext 7 | logdata 8 | rfwritereg 0x05 0x04 9 | rfreadreg 0x05 10 | connectrf 11 | 12 | //Enable RX Addresses 13 | rfreadreg 0x02 14 | 15 | //select channel 0x04 16 | rfwritereg 0x05 0x04 17 | 18 | //RF_SETUP 19 | rfreadreg 0x06 20 | 21 | //STATUS 22 | rfreadreg 0x07 23 | 24 | //RX_ADD_P0 25 | rfreadreg 0x0A 26 | 27 | //RX_PW_P0 : Number of Bytes in RX payload in data pipe 0 (1 to 32 bytes) 28 | rfreadreg 0x11 29 | 30 | //FIFO_STATUS 0x11 : Tx Empty, Rx Empty 31 | rfreadreg 0x17 32 | 33 | //DYNPD 34 | rfreadreg 0x1C 35 | 36 | //nRF_SetMode_Standby_I(); 37 | rfstandby 38 | 39 | //nRF_SetMode_RX(); 40 | listen 41 | 42 | //Dynamic payload enable in Feature 43 | writereg 0x1d 0x04 44 | 45 | //Enable AutoAchnowledge in pipe0 46 | writereg 0x01 0x01 47 | 48 | //Payload Length is in Pipe0 49 | readreg 0x11 50 | _______________________________________________________________ 51 | >>>>Node1 52 | channel 0x04 53 | connectrf 54 | 55 | >>>>Node2 56 | channel 0x04 57 | logon 58 | logdata 59 | listen 60 | 61 | >>>>>Node2 take orders 62 | channel 0x04 63 | listen 64 | rfcmdon 65 | _______________________________________________________________ 66 | 67 | 68 | //max received length 31 chars 69 | 0123456789012345678901234567890 70 | _______________________________________________________________ 71 | >>>>Node2 72 | rfcmdon 73 | 74 | >>>>Node1 75 | connectrf 76 | channel 0x04 77 | node 0x0B logon 78 | node 0x0B logdata 79 | _______________________________________________________________ 80 | //forward, retransmits and decrements time to live, with a random delay jitter 81 | //the node 0x0A is targeted to switch the log on 82 | fw 0x02 node 0x0A logon 83 | //forwards happens before executing the command on self 84 | //Broadcast : everyone switches to channel 0x04 85 | fw 0x02 channel 0x04 86 | 87 | -------------------------------------------------------------------------------- /mesh_controller_interface/rfmaster/uart_config.h: -------------------------------------------------------------------------------- 1 | /** @file uart_config.h 2 | * 3 | * @author Wassim FILALI 4 | * 5 | * 6 | * 7 | * $Date: 12.11.2016 8 | * $Revision: 9 | * 10 | */ 11 | 12 | 13 | //----------------------------------- Interruptions --------------------------------------- 14 | //Flag: UART_USE_RX_INETRRUPT 15 | // 1 : Enabled 16 | // declares the IRQ and requires teh user to declare a uart_callback() function 17 | 18 | #define UART_USE_RX_INETRRUPT 1 19 | 20 | #define UART_FRAME_SIZE 31 21 | 22 | //the terminal sends 13 23 | #define UART_EOL_C 13 24 | 25 | //Flag: UART_Through_RF_Delay 26 | //1 : Enabled this delay is added after every end of line to allow proper transmission of messages through radio 27 | //0 : Disabled, normal behaviour 28 | #define UART_Through_RF_Delay 0 29 | -------------------------------------------------------------------------------- /mesh_controller_interface/settings/mesh_controller_interface.wspos: -------------------------------------------------------------------------------- 1 | [MainWindow] 2 | WindowPlacement=_ 51 186 1790 1388 1 3 | -------------------------------------------------------------------------------- /mesh_controller_interface/uarttester/deviceType.h: -------------------------------------------------------------------------------- 1 | #define DEVICE_STM8S 1 2 | -------------------------------------------------------------------------------- /mesh_controller_interface/uarttester/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | main.c for 3 | IoT_Frameworks 4 | \rfuart 5 | \uarttester 6 | 7 | started 20.11.2016 8 | 9 | */ 10 | 11 | //Test Led is Port B Pin 5 12 | 13 | 14 | #include "uart.h" 15 | 16 | #include "clock_led.h" 17 | 18 | #include "eeprom.h" 19 | 20 | #include "light_dimmer_krida.h" 21 | 22 | BYTE NodeId; 23 | 24 | 25 | //UART Rx Callback 26 | void uart_rx_user_callback(BYTE *buffer,BYTE size) 27 | { 28 | //convert UART Text Terminal Format to String commands 29 | buffer[size-1] = '\0';//replace UART_EOL_C with string EoL 30 | } 31 | 32 | BYTE Dimmer_logon; 33 | 34 | int main( void ) 35 | { 36 | BYTE AliveActiveCounter = 0; 37 | NodeId = *NODE_ID; 38 | dimmer_init();//fast config - enables the PB4 interrupt 39 | 40 | //command interface parameters 41 | Dimmer_logon = 0; 42 | 43 | InitialiseSystemClock(); 44 | 45 | 46 | Initialise_TestLed_GPIO_B5(); 47 | Test_Led_Off(); 48 | 49 | uart_init(); 50 | 51 | /*NodeId = *NODE_ID; 52 | 53 | InitialiseSystemClock(); 54 | 55 | Initialise_TestLed_GPIO_B5(); 56 | 57 | Test_Led_Off(); 58 | 59 | uart_init();*/ 60 | 61 | delay_ms(1000); 62 | printf_ln("____________________________"); 63 | printf_ln("IoT_Frameworks/light_dimmer/"); 64 | printf_ln("light_server/"); 65 | delay_ms(1000); 66 | 67 | delay_ms(1000); 68 | printf_ln("_____________________"); 69 | printf_ln("IoTFrameworks/rfuart/"); 70 | printf_ln("uarttester"); 71 | 72 | delay_ms(200); 73 | //the overflow is completely discarded from RF connection 74 | //as not enough time to handle the Overflow section, no delay between characters 75 | printf_ln("012345678901234567890123456789_Overflow"); 76 | printf_ln("012345678901234567890123456789_OverflowMore"); 77 | delay_ms(200); 78 | 79 | 80 | while (1) 81 | { 82 | 83 | AliveActiveCounter++;//Why are you counting ? 84 | printf("Counter "); 85 | printf_uint(AliveActiveCounter); 86 | printf_eol(); 87 | Test_Led_Off(); 88 | delay_ms(4900); 89 | 90 | Test_Led_On(); 91 | delay_ms(100); 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /mesh_controller_interface/uarttester/timers_config.h: -------------------------------------------------------------------------------- 1 | /** @file timers_config.h 2 | * 3 | * @author Wassim FILALI 4 | * 5 | * 6 | * 7 | * $Date: 18.11.2016 8 | * $Revision: 9 | * 10 | */ 11 | 12 | 13 | //----------------------------------- FLAGS --------------------------------------- 14 | 15 | //TIMER2_USER_CALLBACK 16 | // 0 not used 17 | // 1 used 18 | #define TIMER2_USER_CALLBACK 1 19 | 20 | -------------------------------------------------------------------------------- /mesh_controller_interface/uarttester/uart_config.h: -------------------------------------------------------------------------------- 1 | /** @file uart_config.h 2 | * 3 | * @author Wassim FILALI 4 | * 5 | * 6 | * 7 | * $Date: 12.11.2016 8 | * $Revision: 9 | * 10 | */ 11 | #ifndef _UART_CONFIG_ 12 | #define _UART_CONFIG_ 13 | 14 | 15 | //----------------------------------- Interruptions --------------------------------------- 16 | //Flag: UART_USE_RX_INETRRUPT 17 | // 1 : Enabled 18 | // declares the IRQ and requires teh user to declare a uart_callback() function 19 | 20 | #define UART_USE_RX_INETRRUPT 1 21 | 22 | //Flag: UART_CALLBACK_POLLING 23 | // 1 : Enabled => 'uart_rx_user_callback_pending' has to be polled 24 | // consume 'uart_BUFFER' with 'uart_index', 25 | // acknowledge with 'uart_rx_user_callback_performed' 26 | // 0 : INTERRUPT => The 'uart_rx_user_callback()' will be called from the uart interrupt context 27 | // Flags dependencies 28 | // '#define UART_USE_RX_INETRRUPT 1' has to be set to 1 29 | #define UART_CALLBACK_POLLING 1 30 | 31 | 32 | #define UART_FRAME_SIZE 31 33 | 34 | //the terminal sends 13 35 | #define UART_EOL_C 13 36 | 37 | //Flag: UART_Through_RF_Delay 38 | //1 : Enabled this delay is added after every end of line to allow proper transmission of messages through radio 39 | //0 : Disabled, normal behaviour 40 | #define UART_Through_RF_Delay 1 41 | 42 | #endif /*_UART_CONFIG_*/ 43 | -------------------------------------------------------------------------------- /mesh_controller_interface/uarttester/uarttester.dep: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2 5 | 3557485131 6 | 7 | Debug 8 | 9 | $PROJ_DIR$\timers_config.h 10 | $PROJ_DIR$\main.c 11 | $PROJ_DIR$\main_config.h 12 | $PROJ_DIR$\uart_config.h 13 | $PROJ_DIR$\deviceType.h 14 | 15 | 16 | [MULTI_TOOL] 17 | ILINK 18 | 19 | 20 | 21 | Release 22 | 23 | 24 | [MULTI_TOOL] 25 | ILINK 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /mesh_controller_interface/uarttester/uarttester.ewt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2 5 | 6 | Debug 7 | 8 | STM8 9 | 10 | 1 11 | 12 | 13 | Release 14 | 15 | STM8 16 | 17 | 0 18 | 19 | 20 | libs 21 | 22 | $PROJ_DIR$\..\..\libs\clock_led.c 23 | 24 | 25 | $PROJ_DIR$\..\..\libs\clock_led.h 26 | 27 | 28 | $PROJ_DIR$\..\..\libs\commonTypes.h 29 | 30 | 31 | $PROJ_DIR$\..\..\libs\light_dimmer_krida.c 32 | 33 | 34 | $PROJ_DIR$\..\..\libs\light_dimmer_krida.h 35 | 36 | 37 | $PROJ_DIR$\..\..\libs\uart.c 38 | 39 | 40 | $PROJ_DIR$\..\..\libs\uart.h 41 | 42 | 43 | $PROJ_DIR$\..\..\libs\uart_stm8x.c 44 | 45 | 46 | $PROJ_DIR$\..\..\libs\uart_stm8x.h 47 | 48 | 49 | 50 | $PROJ_DIR$\deviceType.h 51 | 52 | 53 | $PROJ_DIR$\main.c 54 | 55 | 56 | $PROJ_DIR$\main_config.h 57 | 58 | 59 | $PROJ_DIR$\timers_config.h 60 | 61 | 62 | $PROJ_DIR$\uart_config.h 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /rgb_leds/hello_rgb/.gitignore: -------------------------------------------------------------------------------- 1 | Debug/ 2 | settings/ 3 | -------------------------------------------------------------------------------- /rgb_leds/hello_rgb/deviceType.h: -------------------------------------------------------------------------------- 1 | #define DEVICE_STM8S 1 2 | -------------------------------------------------------------------------------- /rgb_leds/hello_rgb/hello_rgb.ewt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2 5 | 6 | Debug 7 | 8 | STM8 9 | 10 | 1 11 | 12 | 13 | Release 14 | 15 | STM8 16 | 17 | 0 18 | 19 | 20 | libs 21 | 22 | $PROJ_DIR$\..\..\libs\clock_led.c 23 | 24 | 25 | $PROJ_DIR$\..\..\libs\clock_led.h 26 | 27 | 28 | $PROJ_DIR$\..\..\libs\commonTypes.h 29 | 30 | 31 | $PROJ_DIR$\..\..\libs\uart.c 32 | 33 | 34 | $PROJ_DIR$\..\..\libs\uart.h 35 | 36 | 37 | $PROJ_DIR$\..\..\libs\uart_stm8x.c 38 | 39 | 40 | $PROJ_DIR$\..\..\libs\uart_stm8x.h 41 | 42 | 43 | $PROJ_DIR$\..\..\libs\WS2812B.c 44 | 45 | 46 | $PROJ_DIR$\..\..\libs\WS2812B.h 47 | 48 | 49 | 50 | $PROJ_DIR$\deviceType.h 51 | 52 | 53 | $PROJ_DIR$\mainRGB.c 54 | 55 | 56 | $PROJ_DIR$\rgb_config.h 57 | 58 | 59 | $PROJ_DIR$\uart_config.h 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /rgb_leds/hello_rgb/mainRGB.c: -------------------------------------------------------------------------------- 1 | /* 2 | mainRGB.c for 3 | IoT_Frameworks 4 | \rg_leds 5 | \hello_rgb 6 | 7 | started 27.02.2017 8 | 9 | */ 10 | 11 | //------------------Target Board-------------- 12 | // Fixed Node v2 13 | // Port B Pin 5 => Test Led is 14 | // SPI => nRF 15 | // UART 16 | // Port A Pin 3 => RGB WS2812B 17 | 18 | #include "clock_led.h" 19 | 20 | #include "uart.h" 21 | 22 | #include "WS2812B.h" 23 | 24 | int main( void ) 25 | { 26 | BYTE AliveActiveCounter = 0; 27 | 28 | InitialiseSystemClock(); 29 | 30 | Initialise_TestLed_GPIO_B5(); 31 | Test_Led_Off(); 32 | 33 | rgb_PIO_Init(); 34 | rgb_SwitchOff_Range(0,1);//(First led, one led) 35 | 36 | uart_init(); 37 | 38 | printf_eol(); 39 | printf_ln("__________________________________________________"); 40 | printf_ln("rgb_leds\\hello_rgb\\"); 41 | 42 | printf_ln("Color Flashed R:40, G:200, B:160"); 43 | while (1) 44 | { 45 | Test_Led_On(); 46 | delay_ms(100); 47 | Test_Led_Off(); 48 | 49 | rgb_TestColors(); 50 | 51 | printf("Cycle:"); 52 | printf_uint(AliveActiveCounter); 53 | printf_eol(); 54 | 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /rgb_leds/hello_rgb/rgb_config.h: -------------------------------------------------------------------------------- 1 | /** @file rgb_config.h 2 | * 3 | * @author Wassim FILALI 4 | * 5 | * 6 | * 7 | * $Date: 27.02.2017 8 | * $Revision: 9 | * 10 | */ 11 | #ifndef _RGB_CONFIG_ 12 | #define _RGB_CONFIG_ 13 | 14 | //NB_LEDS : Number of LED to be supported which would derive the size of the memory 15 | // to be allocated Table[NB_LEDS*3] as that table will contain {R,G,B} Bytes per LED 16 | //1 - 255 : this parameter has for limit the size of the RAM and the 8bit counter => 255 17 | //the value of 256 == 0 was not tested 18 | //255 => 75% of RAM 19 | #define NB_LEDS 1 20 | 21 | 22 | 23 | //RGBLedPIN_A : the Port A pin number to be used, supported values for the Fixed Node v2 Target Board : 24 | // 2 => Not recommended as not High speed 25 | // 3 => Recommend with High speed setting 3.3 V driving 5V TTL input 26 | // recommended settings Vin min = 0.7Vdd ; 5V => 3.5V so 3.3 is not enough, not recommended but working 27 | #define RGBLedPIN_A 3 28 | 29 | #endif /*_RGB_CONFIG_*/ 30 | -------------------------------------------------------------------------------- /rgb_leds/hello_rgb/uart_config.h: -------------------------------------------------------------------------------- 1 | /** @file uart_config.h 2 | * 3 | * @author Wassim FILALI 4 | * 5 | * 6 | * 7 | * $Date: 27.02.2017 8 | * $Revision: 9 | * 10 | */ 11 | #ifndef _UART_CONFIG_ 12 | #define _UART_CONFIG_ 13 | 14 | //UART_BAUD_RATE possible values 115200 9600 15 | #define UART_BAUD_RATE 115200 16 | 17 | //----------------------------------- Interruptions --------------------------------------- 18 | //Flag: UART_USE_RX_INETRRUPT 19 | // 1 : Enabled 20 | // declares the IRQ and requires teh user to declare a uart_callback() function 21 | 22 | #define UART_USE_RX_INETRRUPT 0 23 | 24 | //Flag: UART_CALLBACK_POLLING 25 | // 1 : Enabled => 'uart_rx_user_callback_pending' has to be polled 26 | // consume 'uart_BUFFER' with 'uart_index', 27 | // acknowledge with 'uart_rx_user_callback_performed' 28 | // 0 : INTERRUPT => The 'uart_rx_user_callback()' will be called from the uart interrupt context 29 | // Flags dependencies 30 | // '#define UART_USE_RX_INETRRUPT 1' has to be set to 1 31 | #define UART_CALLBACK_POLLING 0 32 | 33 | 34 | #define UART_FRAME_SIZE 31 35 | 36 | //the terminal sends 13 37 | #define UART_EOL_C 13 38 | 39 | //Flag: UART_Through_RF_Delay 40 | //1 : Enabled this delay is added after every end of line to allow proper transmission of messages through radio 41 | //0 : Disabled, normal behaviour 42 | #define UART_Through_RF_Delay 0 43 | 44 | #endif /*_UART_CONFIG_*/ 45 | -------------------------------------------------------------------------------- /rgb_leds/rgb_led_bar/.gitignore: -------------------------------------------------------------------------------- 1 | Debug/ 2 | settings/ 3 | -------------------------------------------------------------------------------- /rgb_leds/rgb_led_bar/deviceType.h: -------------------------------------------------------------------------------- 1 | #define DEVICE_STM8S 1 2 | -------------------------------------------------------------------------------- /rgb_leds/rgb_led_bar/mainBAR.c: -------------------------------------------------------------------------------- 1 | /* 2 | mainRGB.c for 3 | IoT_Frameworks 4 | \rg_leds 5 | \hello_rgb 6 | 7 | started 27.02.2017 8 | 9 | */ 10 | 11 | // ----------------------- Target Board --------------------- 12 | // Fixed Node v2 13 | // Port B Pin 5 => Test Led is 14 | // SPI => nRF 15 | // UART 16 | // Port A Pin 3 => RGB WS2812B 17 | // ---------------- Test with 60 RGB LED Bar ---------------- 18 | 19 | #include "clock_led.h" 20 | 21 | #include "uart.h" 22 | 23 | #include "WS2812B.h" 24 | //for NB_LEDS 25 | #include "rgb_config.h" 26 | 27 | int main( void ) 28 | { 29 | BYTE AliveActiveCounter = 0; 30 | 31 | InitialiseSystemClock(); 32 | 33 | Initialise_TestLed_GPIO_B5(); 34 | Test_Led_Off(); 35 | 36 | rgb_PIO_Init(); 37 | rgb_SwitchOff_Range(0,NB_LEDS);//(From led id 0, NB_LEDS leds) 38 | 39 | uart_init(); 40 | 41 | printf_eol(); 42 | printf_ln("__________________________________________________"); 43 | printf_ln("rgb_leds\\hello_rgb\\"); 44 | 45 | printf_ln("Color Flashed R:40, G:200, B:160"); 46 | while (1) 47 | { 48 | Test_Led_On(); 49 | delay_ms(100); 50 | Test_Led_Off(); 51 | 52 | //cycle a shading color from Blue to Red and Back to Blue over NB_LEDS RGB LED Bar 53 | printf("Color Loop. "); 54 | printf_uint(NB_LEDS); 55 | printf_ln(" Leds GREEN to BLUE then to RED"); 56 | rgb_Loop_BlueRedBlue(NB_LEDS,200); 57 | 58 | printf("Cycle:"); 59 | printf_uint(AliveActiveCounter); 60 | printf_eol(); 61 | 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /rgb_leds/rgb_led_bar/rgb_config.h: -------------------------------------------------------------------------------- 1 | /** @file rgb_config.h 2 | * 3 | * @author Wassim FILALI 4 | * 5 | * 6 | * 7 | * $Date: 27.02.2017 8 | * $Revision: 9 | * 10 | */ 11 | #ifndef _RGB_CONFIG_ 12 | #define _RGB_CONFIG_ 13 | 14 | //NB_LEDS : Number of LED to be supported which would derive the size of the memory 15 | // to be allocated Table[NB_LEDS*3] as that table will contain {R,G,B} Bytes per LED 16 | //1 - 255 : this parameter has for limit the size of the RAM and the 8bit counter => 255 17 | //the value of 256 == 0 was not tested 18 | //255 => 75% of RAM 19 | #define NB_LEDS 60 20 | 21 | 22 | 23 | //RGBLedPIN_A : the Port A pin number to be used, supported values for the Fixed Node v2 Target Board : 24 | // 2 => Not recommended as not High speed 25 | // 3 => Recommend with High speed setting 3.3 V driving 5V TTL input 26 | // recommended settings Vin min = 0.7Vdd ; 5V => 3.5V so 3.3 is not enough, not recommended but working 27 | #define RGBLedPIN_A 3 28 | 29 | #endif /*_RGB_CONFIG_*/ 30 | -------------------------------------------------------------------------------- /rgb_leds/rgb_led_bar/rgb_led_bar.ewt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2 5 | 6 | Debug 7 | 8 | STM8 9 | 10 | 1 11 | 12 | 13 | Release 14 | 15 | STM8 16 | 17 | 0 18 | 19 | 20 | libs 21 | 22 | $PROJ_DIR$\..\..\libs\clock_led.c 23 | 24 | 25 | $PROJ_DIR$\..\..\libs\clock_led.h 26 | 27 | 28 | $PROJ_DIR$\..\..\libs\commonTypes.h 29 | 30 | 31 | $PROJ_DIR$\..\..\libs\uart.c 32 | 33 | 34 | $PROJ_DIR$\..\..\libs\uart.h 35 | 36 | 37 | $PROJ_DIR$\..\..\libs\uart_stm8x.c 38 | 39 | 40 | $PROJ_DIR$\..\..\libs\uart_stm8x.h 41 | 42 | 43 | $PROJ_DIR$\..\..\libs\WS2812B.c 44 | 45 | 46 | $PROJ_DIR$\..\..\libs\WS2812B.h 47 | 48 | 49 | 50 | $PROJ_DIR$\deviceType.h 51 | 52 | 53 | $PROJ_DIR$\mainBAR.c 54 | 55 | 56 | $PROJ_DIR$\rgb_config.h 57 | 58 | 59 | $PROJ_DIR$\uart_config.h 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /rgb_leds/rgb_led_bar/uart_config.h: -------------------------------------------------------------------------------- 1 | /** @file uart_config.h 2 | * 3 | * @author Wassim FILALI 4 | * 5 | * 6 | * 7 | * $Date: 27.02.2017 8 | * $Revision: 9 | * 10 | */ 11 | #ifndef _UART_CONFIG_ 12 | #define _UART_CONFIG_ 13 | 14 | //UART_BAUD_RATE possible values 115200 9600 15 | #define UART_BAUD_RATE 115200 16 | 17 | //----------------------------------- Interruptions --------------------------------------- 18 | //Flag: UART_USE_RX_INETRRUPT 19 | // 1 : Enabled 20 | // declares the IRQ and requires teh user to declare a uart_callback() function 21 | 22 | #define UART_USE_RX_INETRRUPT 0 23 | 24 | //Flag: UART_CALLBACK_POLLING 25 | // 1 : Enabled => 'uart_rx_user_callback_pending' has to be polled 26 | // consume 'uart_BUFFER' with 'uart_index', 27 | // acknowledge with 'uart_rx_user_callback_performed' 28 | // 0 : INTERRUPT => The 'uart_rx_user_callback()' will be called from the uart interrupt context 29 | // Flags dependencies 30 | // '#define UART_USE_RX_INETRRUPT 1' has to be set to 1 31 | #define UART_CALLBACK_POLLING 0 32 | 33 | 34 | #define UART_FRAME_SIZE 31 35 | 36 | //the terminal sends 13 37 | #define UART_EOL_C 13 38 | 39 | //Flag: UART_Through_RF_Delay 40 | //1 : Enabled this delay is added after every end of line to allow proper transmission of messages through radio 41 | //0 : Disabled, normal behaviour 42 | #define UART_Through_RF_Delay 0 43 | 44 | #endif /*_UART_CONFIG_*/ 45 | -------------------------------------------------------------------------------- /rgb_leds/rgb_leds.eww: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | $WS_DIR$\hello_rgb\hello_rgb.ewp 6 | 7 | 8 | $WS_DIR$\rgb_led_bar\rgb_led_bar.ewp 9 | 10 | 11 | $WS_DIR$\rgb_leds_rf\rgb_leds_rf.ewp 12 | 13 | 14 | $WS_DIR$\rgb_rf_commander\rgb_rf_commander.ewp 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /rgb_leds/rgb_leds_rf/.gitignore: -------------------------------------------------------------------------------- 1 | Debug/ 2 | settings/ 3 | -------------------------------------------------------------------------------- /rgb_leds/rgb_leds_rf/build.bat: -------------------------------------------------------------------------------- 1 | IarBuild.exe rgb_leds_rf.ewp Debug -------------------------------------------------------------------------------- /rgb_leds/rgb_leds_rf/deviceType.h: -------------------------------------------------------------------------------- 1 | #define DEVICE_STM8S 1 2 | -------------------------------------------------------------------------------- /rgb_leds/rgb_leds_rf/iar.bat: -------------------------------------------------------------------------------- 1 | IarIdePm.exe -------------------------------------------------------------------------------- /rgb_leds/rgb_leds_rf/main_LedRf.c: -------------------------------------------------------------------------------- 1 | /* 2 | mainLedRf.c for 3 | IoT_Frameworks 4 | \rg_leds 5 | \rgb_leds_rf 6 | 7 | started 27.02.2017 8 | 9 | */ 10 | 11 | // ----------------------- Target Board --------------------- 12 | // Fixed Node v2 13 | // Port B Pin 5 => Test Led is 14 | // SPI => nRF 15 | // UART 16 | // Port A Pin 3 => RGB WS2812B 17 | // ---------------- Test with 60 RGB LED Bar ---------------- 18 | 19 | #include "uart.h" 20 | #include "clock_led.h" 21 | 22 | //for nRF_Config() nRF_SetMode_RX() 23 | #include "nRF.h" 24 | 25 | #include "WS2812B.h" 26 | //for NB_LEDS 27 | #include "rgb_config.h" 28 | 29 | //for rx_pids and callbacks 30 | #include "rf_protocol.h" 31 | 32 | #include "rf_messages.h" 33 | 34 | 35 | #define EEPROM_Offset 0x4000 36 | #define EE_NODE_ID (char *) EEPROM_Offset; 37 | unsigned char NodeId; 38 | 39 | BYTE Led_Extend = 0; 40 | 41 | void rf_Message_CallBack(BYTE* rxHeader,BYTE *rxPayload,BYTE rx_PayloadSize) 42 | { 43 | Led_Extend = 2;//signal retransmission 44 | switch(rxHeader[rfi_pid]) 45 | { 46 | case rf_pid_rgb: 47 | { 48 | rgb_decode_rf(rxPayload,rx_PayloadSize); 49 | } 50 | break; 51 | default : 52 | { 53 | //do nothing, not concerned, all other RF signals are just noise 54 | Led_Extend = 1;//shorten the signal 55 | } 56 | break; 57 | } 58 | } 59 | 60 | 61 | int main( void ) 62 | { 63 | BYTE AliveActiveCounter = 0; 64 | NodeId = *EE_NODE_ID; 65 | 66 | InitialiseSystemClock(); 67 | 68 | Initialise_TestLed_GPIO_B5(); 69 | Test_Led_Off(); 70 | 71 | rgb_PIO_Init(); 72 | //rgb_SwitchOff_Range(0,NB_LEDS);//(From led id 0, NB_LEDS leds) 73 | //rgb_SetColor_range(0,NB_LEDS,3,0,10);//first values sent are 0, last are 255 74 | //rgb_SendArray(); 75 | rgb_RampColors_range(0,NB_LEDS,1,1,1,0,0,0);//Up, Up, Up, unused,unused,unused 76 | 77 | uart_init(); 78 | 79 | printf_eol(); 80 | printf_ln("__________________________________________________"); 81 | printf_ln("rgb_leds\\rgb_leds_rf\\"); 82 | 83 | //Applies the compile time configured parameters from nRF_Configuration.h 84 | BYTE status = nRF_Config(); 85 | 86 | 87 | //The RX Mode is independently set from nRF_Config() and can be changed on run time 88 | nRF_SetMode_RX(); 89 | 90 | while (1) 91 | { 92 | AliveActiveCounter++;//Why are you counting ? 93 | if(Led_Extend != 0) 94 | { 95 | Test_Led_On(); 96 | Led_Extend--; 97 | } 98 | else 99 | { 100 | Test_Led_Off(); 101 | } 102 | delay_ms(100); 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /rgb_leds/rgb_leds_rf/rgb_config.h: -------------------------------------------------------------------------------- 1 | /** @file rgb_config.h 2 | * 3 | * @author Wassim FILALI 4 | * 5 | * 6 | * 7 | * $Date: 27.02.2017 8 | * $Revision: 9 | * 10 | */ 11 | #ifndef _RGB_CONFIG_ 12 | #define _RGB_CONFIG_ 13 | 14 | //NB_LEDS : Number of LED to be supported which would derive the size of the memory 15 | // to be allocated Table[NB_LEDS*3] as that table will contain {R,G,B} Bytes per LED 16 | //1 - 255 : this parameter has for limit the size of the RAM and the 8bit counter => 255 17 | //the value of 256 == 0 was not tested 18 | //255 => 75% of RAM 19 | #define NB_LEDS 216 20 | //#define NB_LEDS 16 21 | 22 | //reverse the polarity of the PIO when going through a level shifter inverter 23 | // 1 : invert 24 | // 0 : do not invert 25 | #define RGB_IO_NEG 0 26 | 27 | #define RGBLedPin_A3_OpenDrain 0 28 | 29 | //RGBLedPIN_A : the Port A pin number to be used, supported values for the Fixed Node v2 Target Board : 30 | // 2 => Not recommended as not High speed 31 | // 3 => Recommend with High speed setting 3.3 V driving 5V TTL input 32 | // recommended settings Vin min = 0.7Vdd ; 5V => 3.5V so 3.3 is not enough, not recommended but working 33 | #define RGBLedPIN_A 3 34 | 35 | #endif /*_RGB_CONFIG_*/ 36 | -------------------------------------------------------------------------------- /rgb_leds/rgb_leds_rf/uart_config.h: -------------------------------------------------------------------------------- 1 | /** @file uart_config.h 2 | * 3 | * @author Wassim FILALI 4 | * 5 | * 6 | * 7 | * $Date: 27.02.2017 8 | * $Revision: 9 | * 10 | */ 11 | #ifndef _UART_CONFIG_ 12 | #define _UART_CONFIG_ 13 | 14 | //UART_BAUD_RATE possible values 115200 9600 15 | #define UART_BAUD_RATE 115200 16 | 17 | //----------------------------------- Interruptions --------------------------------------- 18 | //Flag: UART_USE_RX_INETRRUPT 19 | // 1 : Enabled 20 | // declares the IRQ and requires teh user to declare a uart_callback() function 21 | 22 | #define UART_USE_RX_INETRRUPT 0 23 | 24 | //Flag: UART_CALLBACK_POLLING 25 | // 1 : Enabled => 'uart_rx_user_callback_pending' has to be polled 26 | // consume 'uart_BUFFER' with 'uart_index', 27 | // acknowledge with 'uart_rx_user_callback_performed' 28 | // 0 : INTERRUPT => The 'uart_rx_user_callback()' will be called from the uart interrupt context 29 | // Flags dependencies 30 | // '#define UART_USE_RX_INETRRUPT 1' has to be set to 1 31 | #define UART_CALLBACK_POLLING 0 32 | 33 | 34 | #define UART_FRAME_SIZE 31 35 | 36 | //the terminal sends 13 37 | #define UART_EOL_C 13 38 | 39 | //Flag: UART_Through_RF_Delay 40 | //1 : Enabled this delay is added after every end of line to allow proper transmission of messages through radio 41 | //0 : Disabled, normal behaviour 42 | #define UART_Through_RF_Delay 0 43 | 44 | #endif /*_UART_CONFIG_*/ 45 | -------------------------------------------------------------------------------- /rgb_leds/rgb_rf_commander/.gitignore: -------------------------------------------------------------------------------- 1 | Debug/ 2 | settings/ 3 | -------------------------------------------------------------------------------- /rgb_leds/rgb_rf_commander/deviceType.h: -------------------------------------------------------------------------------- 1 | #define DEVICE_STM8S 1 2 | -------------------------------------------------------------------------------- /rgb_leds/rgb_rf_commander/main_RfCommand.c: -------------------------------------------------------------------------------- 1 | /* 2 | main_RFCommand.c for 3 | IoT_Frameworks 4 | \rg_leds 5 | \rgb_leds_rf 6 | 7 | started 27.02.2017 8 | 9 | */ 10 | 11 | // ----------------------- Target Board --------------------- 12 | // Fixed Node v2 13 | // Port B Pin 5 => Test Led is 14 | // SPI => nRF 15 | // UART 16 | // Port A Pin 3 => RGB WS2812B 17 | // ---------------- Test with 60 RGB LED Bar ---------------- 18 | 19 | #include "uart.h" 20 | #include "clock_led.h" 21 | 22 | //for nRF_Config() nRF_SetMode_RX() 23 | #include "nRF.h" 24 | //for nRF_Transmit 25 | #include "nRF_Tx.h" 26 | 27 | #include "WS2812B.h" 28 | //for NB_LEDS 29 | #include "rgb_config.h" 30 | 31 | //for rx_pids and callbacks 32 | #include "rf_messages.h" 33 | 34 | #define EEPROM_Offset 0x4000 35 | #define EE_NODE_ID (char *) EEPROM_Offset; 36 | unsigned char NodeId; 37 | 38 | BYTE Led_Extend = 0; 39 | 40 | int main( void ) 41 | { 42 | BYTE AliveActiveCounter = 0; 43 | RGBColor_t MyColors[5]; 44 | NodeId = *EE_NODE_ID; 45 | 46 | MyColors[0] = BLACK; 47 | MyColors[1] = WHITE; 48 | MyColors[2].R = 7;MyColors[2].G = 10;MyColors[2].B = 5; 49 | MyColors[3] = GREEN; 50 | MyColors[4].R = 1;MyColors[4].G = 2;MyColors[4].B = 4; 51 | 52 | RGBColor_t ColorSend = BLACK; 53 | 54 | InitialiseSystemClock(); 55 | 56 | Initialise_TestLed_GPIO_B5(); 57 | Test_Led_Off(); 58 | 59 | rgb_PIO_Init(); 60 | 61 | rgb_SwitchOff_Range(0,NB_LEDS);//(From led id 0, NB_LEDS leds) 62 | 63 | uart_init(); 64 | 65 | printf_eol(); 66 | printf_ln("__________________________________________________"); 67 | printf_ln("rgb_leds\\rgb_leds_rf\\"); 68 | 69 | //Applies the compile time configured parameters from nRF_Configuration.h 70 | BYTE status = nRF_Config(); 71 | 72 | while (1) 73 | { 74 | if(AliveActiveCounter == 5) 75 | { 76 | AliveActiveCounter = 0; 77 | } 78 | ColorSend = MyColors[AliveActiveCounter]; 79 | rgb_FlashColors(0,ColorSend); 80 | BYTE TargetNodeID = 3;//3 - 18 81 | rf_rgb_set(TargetNodeID,ColorSend); 82 | 83 | Test_Led_On(); 84 | delay_ms(100); 85 | Test_Led_Off(); 86 | delay_ms(4900); 87 | AliveActiveCounter++; 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /rgb_leds/rgb_rf_commander/rgb_config.h: -------------------------------------------------------------------------------- 1 | /** @file rgb_config.h 2 | * 3 | * @author Wassim FILALI 4 | * 5 | * 6 | * 7 | * $Date: 27.02.2017 8 | * $Revision: 9 | * 10 | */ 11 | #ifndef _RGB_CONFIG_ 12 | #define _RGB_CONFIG_ 13 | 14 | //NB_LEDS : Number of LED to be supported which would derive the size of the memory 15 | // to be allocated Table[NB_LEDS*3] as that table will contain {R,G,B} Bytes per LED 16 | //1 - 255 : this parameter has for limit the size of the RAM and the 8bit counter => 255 17 | //the value of 256 == 0 was not tested 18 | //255 => 75% of RAM 19 | #define NB_LEDS 1 20 | 21 | 22 | 23 | //RGBLedPIN_A : the Port A pin number to be used, supported values for the Fixed Node v2 Target Board : 24 | // 2 => Not recommended as not High speed 25 | // 3 => Recommend with High speed setting 3.3 V driving 5V TTL input 26 | // recommended settings Vin min = 0.7Vdd ; 5V => 3.5V so 3.3 is not enough, not recommended but working 27 | #define RGBLedPIN_A 3 28 | 29 | #endif /*_RGB_CONFIG_*/ 30 | -------------------------------------------------------------------------------- /rgb_leds/rgb_rf_commander/uart_config.h: -------------------------------------------------------------------------------- 1 | /** @file uart_config.h 2 | * 3 | * @author Wassim FILALI 4 | * 5 | * 6 | * 7 | * $Date: 27.02.2017 8 | * $Revision: 9 | * 10 | */ 11 | #ifndef _UART_CONFIG_ 12 | #define _UART_CONFIG_ 13 | 14 | //UART_BAUD_RATE possible values 115200 9600 15 | #define UART_BAUD_RATE 115200 16 | 17 | //----------------------------------- Interruptions --------------------------------------- 18 | //Flag: UART_USE_RX_INETRRUPT 19 | // 1 : Enabled 20 | // declares the IRQ and requires teh user to declare a uart_callback() function 21 | 22 | #define UART_USE_RX_INETRRUPT 0 23 | 24 | //Flag: UART_CALLBACK_POLLING 25 | // 1 : Enabled => 'uart_rx_user_callback_pending' has to be polled 26 | // consume 'uart_BUFFER' with 'uart_index', 27 | // acknowledge with 'uart_rx_user_callback_performed' 28 | // 0 : INTERRUPT => The 'uart_rx_user_callback()' will be called from the uart interrupt context 29 | // Flags dependencies 30 | // '#define UART_USE_RX_INETRRUPT 1' has to be set to 1 31 | #define UART_CALLBACK_POLLING 0 32 | 33 | 34 | #define UART_FRAME_SIZE 31 35 | 36 | //the terminal sends 13 37 | #define UART_EOL_C 13 38 | 39 | //Flag: UART_Through_RF_Delay 40 | //1 : Enabled this delay is added after every end of line to allow proper transmission of messages through radio 41 | //0 : Disabled, normal behaviour 42 | #define UART_Through_RF_Delay 0 43 | 44 | #endif /*_UART_CONFIG_*/ 45 | -------------------------------------------------------------------------------- /rgb_leds/settings/rgb_leds.wspos: -------------------------------------------------------------------------------- 1 | [MainWindow] 2 | WindowPlacement=_ 28 49 1588 1300 1 3 | -------------------------------------------------------------------------------- /smartio_firmware/01_EEPROM_To_Output/ClockUartLed.h: -------------------------------------------------------------------------------- 1 | /** @file ClockUartLed.h 2 | * 3 | * @author Wassim FILALI taken over from http://blog.mark-stevens.co.uk/ 4 | * 5 | * @compiler IAR STM8 6 | * 7 | * 8 | * $Date: 20.09.2015 9 | * $Revision: 10 | * 11 | */ 12 | 13 | 14 | #define delay_1us(); delay(0); 15 | 16 | #define delay_10us(); delay(18); 17 | 18 | #define delay_50us(); delay(98); 19 | 20 | #define delay_100us(); delay(198); 21 | 22 | #define delay_1ms(); delay(1998); 23 | 24 | #define delay_10ms(); delay(19998); 25 | 26 | 27 | void InitialiseUART(); 28 | 29 | void putc(char c); 30 | 31 | void UARTPrintf(char const *message); 32 | 33 | void UARTPrintfLn(char const *message); 34 | 35 | void UARTPrintfHex(unsigned char val); 36 | 37 | void UARTPrintfHexTable(unsigned char *pval,unsigned char length); 38 | 39 | void UARTPrintfHexLn(unsigned char val); 40 | 41 | void UARTPrintf_sint(signed int num); 42 | 43 | void UARTPrintf_uint(unsigned int num); 44 | 45 | void InitialiseSystemClock(); 46 | 47 | void delay(unsigned int n); 48 | 49 | void delay_ms(unsigned int n); 50 | 51 | 52 | // L E D 53 | void Initialise_TestLed_GPIO_B5(); 54 | void Test_Led_On(); 55 | void Test_Led_Off(); 56 | 57 | -------------------------------------------------------------------------------- /smartio_firmware/02_EESeqence_Console/ClockUartLed.h: -------------------------------------------------------------------------------- 1 | /** @file ClockUartLed.h 2 | * 3 | * @author Wassim FILALI taken over from http://blog.mark-stevens.co.uk/ 4 | * 5 | * @compiler IAR STM8 6 | * 7 | * 8 | * $Date: 20.09.2015 9 | * $Revision: 10 | * 11 | */ 12 | 13 | 14 | #define delay_1us(); delay(0); 15 | 16 | #define delay_10us(); delay(18); 17 | 18 | #define delay_50us(); delay(98); 19 | 20 | #define delay_100us(); delay(198); 21 | 22 | #define delay_1ms(); delay(1998); 23 | 24 | #define delay_10ms(); delay(19998); 25 | 26 | 27 | void InitialiseUART(); 28 | 29 | void putc(char c); 30 | 31 | void UARTPrintf(char const *message); 32 | 33 | void UARTPrintfLn(char const *message); 34 | 35 | void UARTPrintfHex(unsigned char val); 36 | 37 | void UARTPrintfHexTable(unsigned char *pval,unsigned char length); 38 | 39 | void UARTPrintfHexLn(unsigned char val); 40 | 41 | void UARTPrintf_sint(signed int num); 42 | 43 | void UARTPrintf_uint(unsigned int num); 44 | 45 | void InitialiseSystemClock(); 46 | 47 | void delay(unsigned int n); 48 | 49 | void delay_ms(unsigned int n); 50 | 51 | 52 | // L E D 53 | void Initialise_TestLed_GPIO_B5(); 54 | void Test_Led_On(); 55 | void Test_Led_Off(); 56 | 57 | -------------------------------------------------------------------------------- /smartio_firmware/02_EESeqence_Console/readme.md: -------------------------------------------------------------------------------- 1 | # Smart IO Expander EEPROM and Serial console Control 2 | ## EEPROM Sequencing 3 | - reads commands from EEPROM and executes them on the output with delay 4 | ##Console Control 5 | - reads command line and sets outputs accordingly 6 | - "P" then return : Stops the EEPROM sequencing execution 7 | - "S" then return : Starts the EEPROM sequencing execution 8 | - "Se00" then return : sends hex 0x00 all outputs OFF 9 | - "SeFF" then return : sends hex 0xFF all outputs ON 10 | - "Se5A" then return : sends hex 0x5A outputs to binary 0101 1010 => OFF,ON,OFF,ON, ON,OFF,ON,OFF 11 | -------------------------------------------------------------------------------- /smartio_firmware/02_EESeqence_Console/sequenceSample.hex.txt: -------------------------------------------------------------------------------- 1 | :204000004F636D64FF005A00FFFF5A00FF551000FFAA10000000000000000000000000004F 2 | :20402000000000000000000000000000000000000000000000000000000000000000000080 3 | :20404000000000000000000000000000000000000000000000000000000000000000000060 4 | :20406000000000000000000000000000000000000000000000000000000000000000000040 5 | :20408000000000000000000000000000000000000000000000000000000000000000000020 6 | :2040A000000000000000000000000000000000000000000000000000000000000000000000 7 | :2040C0000000000000000000000000000000000000000000000000000000000000000000E0 8 | :2040E0000000000000000000000000000000000000000000000000000000000000000000C0 9 | :2041000000000000000000000000000000000000000000000000000000000000000000009F 10 | :2041200000000000000000000000000000000000000000000000000000000000000000007F 11 | :2041400000000000000000000000000000000000000000000000000000000000000000005F 12 | :2041600000000000000000000000000000000000000000000000000000000000000000003F 13 | :2041800000000000000000000000000000000000000000000000000000000000000000001F 14 | :2041A0000000000000000000000000000000000000000000000000000000000000000000FF 15 | :2041C0000000000000000000000000000000000000000000000000000000000000000000DF 16 | :2041E0000000000000000000000000000000000000000000000000000000000000000000BF 17 | :2042000000000000000000000000000000000000000000000000000000000000000000009E 18 | :2042200000000000000000000000000000000000000000000000000000000000000000007E 19 | :2042400000000000000000000000000000000000000000000000000000000000000000005E 20 | :2042600000000000000000000000000000000000000000000000000000000000000000003E 21 | :00000001FF 22 | -------------------------------------------------------------------------------- /smartio_firmware/03_io_serial_server/.gitignore: -------------------------------------------------------------------------------- 1 | Debug/ 2 | settings/ 3 | -------------------------------------------------------------------------------- /smartio_firmware/03_io_serial_server/03_io_serial_server.ewt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2 5 | 6 | Debug 7 | 8 | STM8 9 | 10 | 1 11 | 12 | 13 | Release 14 | 15 | STM8 16 | 17 | 0 18 | 19 | 20 | libs 21 | 22 | $PROJ_DIR$\..\..\..\libs\clock_led.c 23 | 24 | 25 | $PROJ_DIR$\..\..\..\libs\clock_led.h 26 | 27 | 28 | $PROJ_DIR$\..\..\..\libs\cmdutils.c 29 | 30 | 31 | $PROJ_DIR$\..\..\..\libs\cmdutils.h 32 | 33 | 34 | $PROJ_DIR$\..\..\..\libs\commonTypes.h 35 | 36 | 37 | $PROJ_DIR$\..\..\..\libs\eeprom.h 38 | 39 | 40 | $PROJ_DIR$\..\..\..\libs\timer2_pwm.c 41 | 42 | 43 | $PROJ_DIR$\..\..\..\libs\timer2_pwm.h 44 | 45 | 46 | $PROJ_DIR$\..\..\..\libs\uart.c 47 | 48 | 49 | $PROJ_DIR$\..\..\..\libs\uart.h 50 | 51 | 52 | $PROJ_DIR$\..\..\..\libs\uart_stm8x.c 53 | 54 | 55 | $PROJ_DIR$\..\..\..\libs\uart_stm8x.h 56 | 57 | 58 | 59 | $PROJ_DIR$\deviceType.h 60 | 61 | 62 | $PROJ_DIR$\main.c 63 | 64 | 65 | $PROJ_DIR$\timers_config.h 66 | 67 | 68 | $PROJ_DIR$\uart_config.h 69 | 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /smartio_firmware/03_io_serial_server/deviceType.h: -------------------------------------------------------------------------------- 1 | #define DEVICE_STM8S 1 2 | -------------------------------------------------------------------------------- /smartio_firmware/03_io_serial_server/timers_config.h: -------------------------------------------------------------------------------- 1 | /** @file timers_config.h 2 | * 3 | * @author Wassim FILALI 4 | * 5 | * 6 | * 7 | * $Date: 18.11.2016 8 | * $Revision: 9 | * 10 | */ 11 | 12 | 13 | //----------------------------------- FLAGS --------------------------------------- 14 | 15 | //TIMER2_USER_CALLBACK 16 | // 0 not used 17 | // 1 used 18 | #define TIMER2_USER_CALLBACK 1 19 | 20 | -------------------------------------------------------------------------------- /smartio_firmware/03_io_serial_server/uart_config.h: -------------------------------------------------------------------------------- 1 | /** @file uart_config.h 2 | * 3 | * @author Wassim FILALI 4 | * 5 | * 6 | * 7 | * $Date: 12.11.2016 8 | * $Revision: 9 | * 10 | */ 11 | #ifndef _UART_CONFIG_ 12 | #define _UART_CONFIG_ 13 | 14 | //UART_BAUD_RATE possible values 115200 9600 15 | #define UART_BAUD_RATE 115200 16 | //----------------------------------- Interruptions --------------------------------------- 17 | //Flag: UART_USE_RX_INETRRUPT 18 | // 1 : Enabled 19 | // declares the IRQ and requires teh user to declare a uart_callback() function 20 | 21 | #define UART_USE_RX_INETRRUPT 1 22 | 23 | //Flag: UART_CALLBACK_POLLING 24 | // 1 : Enabled => 'uart_rx_user_callback_pending' has to be polled 25 | // consume 'uart_BUFFER' with 'uart_index', 26 | // acknowledge with 'uart_rx_user_callback_performed' 27 | // 0 : INTERRUPT => The 'uart_rx_user_callback()' will be called from the uart interrupt context 28 | // Flags dependencies 29 | // '#define UART_USE_RX_INETRRUPT 1' has to be set to 1 30 | #define UART_CALLBACK_POLLING 0 31 | 32 | 33 | #define UART_FRAME_SIZE 31 34 | 35 | //the terminal sends 13 36 | #define UART_EOL_C 13 37 | 38 | //Flag: UART_Through_RF_Delay 39 | //1 : Enabled this delay is added after every end of line to allow proper transmission of messages through radio 40 | //0 : Disabled, normal behaviour 41 | #define UART_Through_RF_Delay 0 42 | 43 | #endif /*_UART_CONFIG_*/ 44 | -------------------------------------------------------------------------------- /smartio_firmware/README.md: -------------------------------------------------------------------------------- 1 | # ST Visual Programmer 2 | [STVP-STM8](http://www.st.com/content/st_com/en/products/development-tools/software-development-tools/stm8-software-development-tools/stm8-programmers/stvp-stm8.html) 3 | -------------------------------------------------------------------------------- /smartio_firmware/STM8_IO_Interface.url: -------------------------------------------------------------------------------- 1 | [{000214A0-0000-0000-C000-000000000046}] 2 | Prop3=19,11 3 | [InternetShortcut] 4 | IDList= 5 | URL=https://github.com/wassfila/STM8_IoT_Base/tree/master/ws04_IOExpander_Sequencer/02_EESeqence_Console 6 | -------------------------------------------------------------------------------- /smartio_firmware/settings/smartio.wspos: -------------------------------------------------------------------------------- 1 | [MainWindow] 2 | WindowPlacement=_ 74 136 1583 1318 1 3 | -------------------------------------------------------------------------------- /smartio_firmware/smartio.eww: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | $WS_DIR$\03_io_serial_server\03_io_serial_server.ewp 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /ws01_WeatherLogger/pr00_LibraryCommon/ClockUartLed.h: -------------------------------------------------------------------------------- 1 | /** @file ClockUartLed.h 2 | * 3 | * @author Wassim FILALI taken over from http://blog.mark-stevens.co.uk/ 4 | * 5 | * @compiler IAR STM8 6 | * 7 | * 8 | * $Date: 20.09.2015 9 | * $Revision: 10 | * 11 | */ 12 | 13 | 14 | #define delay_1us(); delay(0); 15 | 16 | #define delay_10us(); delay(18); 17 | 18 | #define delay_50us(); delay(98); 19 | 20 | #define delay_100us(); delay(198); 21 | 22 | #define delay_1ms(); delay(1998); 23 | 24 | #define delay_10ms(); delay(19998); 25 | 26 | 27 | void InitialiseUART(); 28 | 29 | void UARTPrintf(char const *message); 30 | 31 | void UARTPrintfLn(char const *message); 32 | 33 | void UARTPrintfHex(unsigned char val); 34 | 35 | void UARTPrintfHexTable(unsigned char *pval,unsigned char length); 36 | 37 | void UARTPrintfHexLn(unsigned char val); 38 | 39 | void UARTPrintf_sint(signed int num); 40 | 41 | void UARTPrintf_uint(unsigned int num); 42 | 43 | void InitialiseSystemClock(); 44 | 45 | void delay(unsigned int n); 46 | 47 | void delay_ms(unsigned int n); 48 | 49 | 50 | // L E D 51 | void Initialise_TestLed_GPIO_B5(); 52 | void Test_Led_On(); 53 | void Test_Led_Off(); 54 | 55 | -------------------------------------------------------------------------------- /ws01_WeatherLogger/pr00_LibraryCommon/commonTypes.h: -------------------------------------------------------------------------------- 1 | /** @file commonTypes.h 2 | * 3 | * @author Wassim FILALI 4 | * 5 | * 6 | * @compiler IAR STM8 7 | * 8 | * 9 | * $Date: 13.12.2015 10 | * $Revision: 11 | * 12 | */ 13 | 14 | // UINT type definition 15 | #ifndef _UINT_DEF_ 16 | #define _UINT_DEF_ 17 | typedef unsigned int UINT; 18 | #endif 19 | 20 | // BYTE type definition 21 | #ifndef _BYTE_DEF_ 22 | #define _BYTE_DEF_ 23 | typedef unsigned char BYTE; 24 | #endif 25 | 26 | 27 | #ifndef E_OK 28 | #define E_OK 0x00 29 | #endif 30 | 31 | #ifndef E_Already_Initialised 32 | #define E_Already_Initialised 0x01 33 | #endif 34 | 35 | -------------------------------------------------------------------------------- /ws01_WeatherLogger/pr00_LibraryCommon/nRF_IRQ.h: -------------------------------------------------------------------------------- 1 | /** @file nRF_IRQ.h 2 | * 3 | * @author Wassim FILALI, inspired from nRF24L01P-EK 4 | * 5 | * @compiler IAR STM8 6 | * 7 | * 8 | * $Date: 14.12.2015 9 | * $Revision: 10 | * 11 | */ 12 | 13 | //nRF24L01P module IRQ on D2 14 | 15 | void nRF_IRQ_Config(); 16 | -------------------------------------------------------------------------------- /ws01_WeatherLogger/pr00_LibraryCommon/nRF_LowLevel.c: -------------------------------------------------------------------------------- 1 | /** @file nRF_LowLevel.h 2 | * 3 | * @author Wassim FILALI, inspired from nRF24L01P-EK 4 | * 5 | * @compiler IAR STM8 6 | * 7 | * 8 | * $Date: 20.09.2015 9 | * $Revision: 10 | * 11 | */ 12 | 13 | #include 14 | 15 | #include "nRF_LowLevel.h" 16 | 17 | //---------------------------------------------------------------------------------------------------------- 18 | // PC7 SPI_MISO 19 | // PC6 SPI_MOSI 20 | // PC5 SPI_SCK 21 | // PC4 GPIO_OUT CSN Chip Select Negative 22 | // PC3 GPIO_OUT CE Chip Enable (this signal is active high and used to activate the chip in RX or TX mode) 23 | //---------------------------------------------------------------------------------------------------------- 24 | 25 | 26 | void SPI_Init_ChipEnable_Pin() 27 | { 28 | //To be disabled before configuration Low is Disable 29 | PC_ODR_ODR3 = 0; 30 | 31 | // 0: Input 1: Output 32 | PC_DDR_DDR3 = 1; 33 | 34 | // 0: Pseudo open drain 1: Push-pull 35 | PC_CR1_C13 = 1; 36 | // 0: Output speed up to 2 MHz 1: Output speed up to 10 MHz 37 | PC_CR2_C23 = 1; 38 | } 39 | void CE_Pin_LowDisable() 40 | { 41 | PC_ODR_ODR3 = 0; 42 | } 43 | 44 | void CE_Pin_HighEnable() 45 | { 46 | PC_ODR_ODR3 = 1; 47 | } 48 | 49 | void SPI_Init_ChipSelect_Pin() 50 | { 51 | //To be disabled before configuration High is Disable 52 | PC_ODR_ODR4 = 1; 53 | // 0: Input 1: Output 54 | PC_DDR_DDR4 = 1; 55 | // 0: Pseudo open drain 1: Push-pull 56 | PC_CR1_C14 = 1; 57 | // 0: Output speed up to 2 MHz 1: Output speed up to 10 MHz 58 | PC_CR2_C24 = 1; 59 | } 60 | 61 | void CSN_Pin_LowSelect() 62 | { 63 | PC_ODR_ODR4 = 0; 64 | } 65 | 66 | void CSN_Pin_HighDisable() 67 | { 68 | PC_ODR_ODR4 = 1; 69 | } 70 | 71 | //Initialise the Configuration registers 1 and 2. Also resets the polynomial to the default 72 | void SPI_Init_Peripheral() 73 | { 74 | const BYTE SPI_CR1_BR_fDiv256 = 0x07; 75 | 76 | SPI_CR1 = 0x00;//default reset value 77 | //SPI_CR1_LSBFIRST = 0; 78 | SPI_CR1_BR = SPI_CR1_BR_fDiv256; 79 | //SPI_CR1_CPOL = 0; Low when Idle 80 | //SPI_CR1_CPHA = 0; 1st edge 81 | 82 | SPI_CR2 = 0x00; 83 | //SPI_CR2_BDM = 0;// 2 lines 84 | SPI_CR2_SSM = 1;//Software Slave Management Enabled 85 | SPI_CR2_SSI = 1;//Master Mode 86 | 87 | //Set the SPI in Master Mode 88 | SPI_CR1_MSTR = 1; 89 | 90 | SPI_CRCPR = 0x07;//CRC Polynomial reset value is 0x07 91 | 92 | //Enable the SPI Peripheral 93 | SPI_CR1_SPE = 1; 94 | 95 | } 96 | 97 | //RM0016 Note : Do not use the BSY flag to handle each data transmission or reception. 98 | //It is better to use TXE and RXNE flags instead. 99 | BYTE SPI_WriteRead(BYTE Data) 100 | { 101 | //Wait while (Tx Buffer not Empty); 102 | while(SPI_SR_TXE == 0); 103 | SPI_DR = Data; 104 | //while (SPI_GetFlagStatus(SPI_FLAG_BSY)== SET);// Do not use Busy Flag in every transaction 105 | //Wait while Rx Buffer Empty 106 | while(SPI_SR_RXNE == 0); 107 | 108 | return SPI_DR; 109 | } 110 | -------------------------------------------------------------------------------- /ws01_WeatherLogger/pr00_LibraryCommon/nRF_LowLevel.h: -------------------------------------------------------------------------------- 1 | /** @file nRF_LowLevel.h 2 | * 3 | * @author Wassim FILALI, inspired from nRF24L01P-EK 4 | * 5 | * @compiler IAR STM8 6 | * 7 | * This low level is applied on the STM8103F3 so this should be the only file 8 | * to modify when porting this to another MCU 9 | * 10 | * $Date: 20.09.2015 11 | * $Revision: 12 | * 13 | */ 14 | 15 | //for BYTE 16 | #include "commonTypes.h" 17 | 18 | //------------------------Low Level API------------------------ 19 | 20 | void SPI_Init_ChipEnable_Pin(); 21 | 22 | void CE_Pin_LowDisable(); 23 | 24 | void CE_Pin_HighEnable(); 25 | 26 | void SPI_Init_ChipSelect_Pin(); 27 | 28 | void CSN_Pin_LowSelect(); 29 | 30 | void CSN_Pin_HighDisable(); 31 | 32 | void SPI_Init_Peripheral(); 33 | 34 | BYTE SPI_WriteRead(BYTE Data); 35 | -------------------------------------------------------------------------------- /ws01_WeatherLogger/pr00_LibraryCommon/nRF_Modes.h: -------------------------------------------------------------------------------- 1 | /** @file nRF_Modes.h 2 | * 3 | * @author Wassim FILALI 4 | * Directly inferred from the Datasheet 5 | * 6 | * 7 | * @compiler IAR STM8 8 | * 9 | * 10 | * $Date: 12.12.2015 11 | * $Revision: 12 | * 13 | */ 14 | 15 | //for BYTE 16 | #include "commonTypes.h" 17 | 18 | 19 | #define nRF_Mode_Uninitialised 0x00 20 | #define nRF_Mode_PowerDown 0x01 21 | #define nRF_Mode_Standby 0x02 22 | #define nRF_Mode_Tx 0x03 23 | #define nRF_Mode_Rx 0x04 24 | 25 | BYTE nRF_Config(); 26 | 27 | BYTE nRF_Init();//Waiting power on reset and initialising SPI 28 | 29 | // The Radio control operational modes are following the description from 30 | // nRF24L01P Product Specification 1.0 page 21 31 | 32 | BYTE nRF_SetMode_PowerDown(); 33 | 34 | BYTE nRF_SetMode_Standby_I(); 35 | 36 | BYTE nRF_SetMode_RX(); 37 | 38 | BYTE nRF_SetMode_TX(); 39 | 40 | BYTE nRF_ClearStatus(); 41 | 42 | 43 | 44 | //Global variable to manage the current mode 45 | 46 | extern BYTE nRF_Mode; 47 | extern BYTE ConfigVal; 48 | -------------------------------------------------------------------------------- /ws01_WeatherLogger/pr00_LibraryCommon/nRF_RegText.c: -------------------------------------------------------------------------------- 1 | /** @file nRF_RegText.c 2 | * 3 | * @author Wassim FILALI 4 | * 5 | * @compiler IAR STM8 6 | * 7 | * $Date: 13.12.2015 8 | * $Revision: 9 | * 10 | */ 11 | 12 | #include "nRF_RegText.h" 13 | #include "nRF_SPI.h" 14 | #include "ClockUartLed.h" 15 | 16 | void nRF_PrintStatus(BYTE status) 17 | { 18 | UARTPrintf("STATUS: "); 19 | UARTPrintfHex(status); 20 | UARTPrintf(" : "); 21 | 22 | if(status & bit_RX_DR) 23 | { 24 | UARTPrintf("Data Ready i; "); 25 | } 26 | if(status & bit_TX_DS) 27 | { 28 | UARTPrintf("Data Sent i; "); 29 | } 30 | if(status & bit_MAX_RT) 31 | { 32 | UARTPrintf("Max Ret i; "); 33 | } 34 | if( (status & bit_Mask_RXPNO) == bit_RXPNO_NotUsed) 35 | { 36 | UARTPrintf("Rx Pipe not used ; "); 37 | } 38 | else if( (status & bit_Mask_RXPNO) == bit_RXPNO_RxFFEmpty) 39 | { 40 | //UARTPrintf("Rx Fifo Empty ; ");// this is the default state not log for it 41 | } 42 | else 43 | { 44 | BYTE PipeNb = (status & bit_Mask_RXPNO)>>1; 45 | UARTPrintf("Rx Pipe Nb "); 46 | UARTPrintfHex(PipeNb); 47 | UARTPrintf(" ; "); 48 | } 49 | if(status & bit_TX_FULL) 50 | { 51 | UARTPrintf("TX Fifo Full;"); 52 | } 53 | UARTPrintf("\n\r"); 54 | } 55 | 56 | void nRF_PrintConfig() 57 | { 58 | 59 | } 60 | -------------------------------------------------------------------------------- /ws01_WeatherLogger/pr00_LibraryCommon/nRF_RegText.h: -------------------------------------------------------------------------------- 1 | /** @file nRF_RegText.h 2 | * 3 | * @author Wassim FILALI 4 | * 5 | * @compiler IAR STM8 6 | * 7 | * $Date: 13.12.2015 8 | * $Revision: 9 | * 10 | */ 11 | 12 | #include "commonTypes.h" 13 | 14 | void nRF_PrintStatus(BYTE status); 15 | void nRF_PrintConfig(); 16 | -------------------------------------------------------------------------------- /ws01_WeatherLogger/pr00_LibraryCommon/nRF_SPI.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HomeSmartMesh/IoT_STM8/541ae723d424edbea4a077d8590023a95d9712cb/ws01_WeatherLogger/pr00_LibraryCommon/nRF_SPI.h -------------------------------------------------------------------------------- /ws01_WeatherLogger/pr00_LibraryCommon/nRF_Tx.c: -------------------------------------------------------------------------------- 1 | /** @file nRF_Tx.c 2 | * 3 | * @author Wassim FILALI 4 | * Inferred from the Datasheet 5 | * 6 | * 7 | * @compiler IAR STM8 8 | * 9 | * 10 | * $Date: 12.12.2015 11 | * $Revision: 12 | * 13 | */ 14 | 15 | #include "nRF_Tx.h" 16 | //for nRF_Mode 17 | #include "nRF_Modes.h" 18 | //for SPI_Write_Buf 19 | #include "nRF_SPI.h" 20 | #include "ClockUartLed.h" 21 | #include "nRF_LowLevel.h" 22 | 23 | //returns the status byte 24 | BYTE nRF_Transmit(BYTE* payload, BYTE size) 25 | { 26 | BYTE status; 27 | status = SPI_Command(FLUSH_TX,0x00); 28 | //unused result status 29 | 30 | if(nRF_Mode != nRF_Mode_Tx) 31 | { 32 | nRF_SetMode_TX(); 33 | } 34 | status = SPI_Write_Buf(WR_TX_PLOAD,payload,size); 35 | 36 | CE_Pin_HighEnable();//pulse for more than 10 us 37 | delay_10us(); 38 | delay_10us(); 39 | CE_Pin_LowDisable(); 40 | 41 | return status; 42 | } 43 | -------------------------------------------------------------------------------- /ws01_WeatherLogger/pr00_LibraryCommon/nRF_Tx.h: -------------------------------------------------------------------------------- 1 | /** @file nRF_Tx.h 2 | * 3 | * @author Wassim FILALI 4 | * Inferred from the Datasheet 5 | * 6 | * 7 | * @compiler IAR STM8 8 | * 9 | * 10 | * $Date: 12.12.2015 11 | * $Revision: 12 | * 13 | */ 14 | 15 | //for BYTE 16 | #include "commonTypes.h" 17 | 18 | BYTE nRF_Transmit(BYTE* payload, BYTE size); -------------------------------------------------------------------------------- /ws01_WeatherLogger/pr00_LibraryCommon/temp_ds18b20.h: -------------------------------------------------------------------------------- 1 | /** @file temp_ds18b20.h 2 | * 3 | * @author Wassim FILALI 4 | * Inferred from the Datasheet 5 | * 6 | * 7 | * @compiler IAR STM8 8 | * 9 | * 10 | * started on local project on 12.10.2015 11 | * this file was created for refactoring on 26.12.2015 12 | * $Date: 26.12.2015 13 | * $Revision: 14 | * 15 | */ 16 | 17 | #include "commonTypes.h" 18 | 19 | void Initialise_OneWire_Pin(); 20 | 21 | void OneWire_Reset(); 22 | 23 | BYTE OneWire_CheckPresence(); 24 | 25 | BYTE OneWire_Init(); 26 | 27 | BYTE OneWire_ReadBit(); 28 | 29 | void OneWire_WriteByte(BYTE byte); 30 | 31 | BYTE OneWire_ReadByte(); 32 | 33 | BYTE DS18B20_Single_ReadRom(BYTE * rom); 34 | 35 | BYTE DS18B20_Single_ReadScratchPad(BYTE * sp,BYTE length); 36 | 37 | BYTE DS18B20_Single_ReadTemperature(BYTE * data); 38 | 39 | void UARTPrint_DS18B20_Temperature(BYTE * data); 40 | -------------------------------------------------------------------------------- /ws01_WeatherLogger/pr01_Temperature_RF_Sender/.gitignore: -------------------------------------------------------------------------------- 1 | Debug/ 2 | settings/ 3 | -------------------------------------------------------------------------------- /ws01_WeatherLogger/pr01_Temperature_RF_Sender/01_Temperature_RF_Sender.ewt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2 5 | 6 | Debug 7 | 8 | STM8 9 | 10 | 1 11 | 12 | 13 | Release 14 | 15 | STM8 16 | 17 | 0 18 | 19 | 20 | LibraryCommon 21 | 22 | $PROJ_DIR$\..\pr00_LibraryCommon\ClockUartLed.c 23 | 24 | 25 | $PROJ_DIR$\..\pr00_LibraryCommon\ClockUartLed.h 26 | 27 | 28 | $PROJ_DIR$\..\pr00_LibraryCommon\commonTypes.h 29 | 30 | 31 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_IRQ.c 32 | 33 | 34 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_IRQ.h 35 | 36 | 37 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_LowLevel.c 38 | 39 | 40 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_LowLevel.h 41 | 42 | 43 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_Modes.c 44 | 45 | 46 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_Modes.h 47 | 48 | 49 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_RegText.c 50 | 51 | 52 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_RegText.h 53 | 54 | 55 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_SPI.c 56 | 57 | 58 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_SPI.h 59 | 60 | 61 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_Tx.c 62 | 63 | 64 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_Tx.h 65 | 66 | 67 | $PROJ_DIR$\..\pr00_LibraryCommon\temp_ds18b20.c 68 | 69 | 70 | $PROJ_DIR$\..\pr00_LibraryCommon\temp_ds18b20.h 71 | 72 | 73 | 74 | $PROJ_DIR$\mainTx.c 75 | 76 | 77 | $PROJ_DIR$\nRF_Configuration.h 78 | 79 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /ws01_WeatherLogger/pr02_RF_ReceiveLogger/.gitignore: -------------------------------------------------------------------------------- 1 | Debug/ 2 | settings/ 3 | -------------------------------------------------------------------------------- /ws01_WeatherLogger/pr02_RF_ReceiveLogger/02_RF_ReceiveLogger.ewt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2 5 | 6 | Debug 7 | 8 | STM8 9 | 10 | 1 11 | 12 | 13 | Release 14 | 15 | STM8 16 | 17 | 0 18 | 19 | 20 | LibraryCommon 21 | 22 | $PROJ_DIR$\..\pr00_LibraryCommon\ClockUartLed.c 23 | 24 | 25 | $PROJ_DIR$\..\pr00_LibraryCommon\ClockUartLed.h 26 | 27 | 28 | $PROJ_DIR$\..\pr00_LibraryCommon\commonTypes.h 29 | 30 | 31 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_IRQ.c 32 | 33 | 34 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_IRQ.h 35 | 36 | 37 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_LowLevel.c 38 | 39 | 40 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_LowLevel.h 41 | 42 | 43 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_Modes.c 44 | 45 | 46 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_Modes.h 47 | 48 | 49 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_RegText.c 50 | 51 | 52 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_RegText.h 53 | 54 | 55 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_SPI.c 56 | 57 | 58 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_SPI.h 59 | 60 | 61 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_Tx.c 62 | 63 | 64 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_Tx.h 65 | 66 | 67 | $PROJ_DIR$\..\pr00_LibraryCommon\temp_ds18b20.c 68 | 69 | 70 | $PROJ_DIR$\..\pr00_LibraryCommon\temp_ds18b20.h 71 | 72 | 73 | 74 | $PROJ_DIR$\mainRx.c 75 | 76 | 77 | $PROJ_DIR$\nRF_Configuration.h 78 | 79 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /ws01_WeatherLogger/pr03_RFSender_LowPower/.gitignore: -------------------------------------------------------------------------------- 1 | Debug/ 2 | settings/ 3 | -------------------------------------------------------------------------------- /ws01_WeatherLogger/pr03_RFSender_LowPower/Batteries Log.txt: -------------------------------------------------------------------------------- 1 | manual measures 2 | 2 Bytes RF sent every 6.3 seconds 3 | Time Cell1 Two Cells Three Cells 4 | 2016-01-16 16h24 1.29 2.59 3.90 5 | 2016-01-16 20h00 1.29 2.59 3.89 6 | 2016-01-17 12h59 1.29 2.58 3.87 7 | 2016-01-19 19h46 1.28 2.56 3.85 8 | 2016-01-20 19h28 1.27 2.56 3.84 9 | 2016-01-21 18h50 1.27 2.55 3.84 10 | 2016-01-23 10h46 1.27 2.55 3.82 11 | 2016-01-30 17h30 1.26 2.54 3.81 12 | 2016-02-02 19h41 1.26 2.54 3.81 13 | 2016-02-09 21h30 1.26 2.53 3.80 14 | 2016-02-21 17h13 1.26 2.52 3.79 15 | 2016-02-28 20h44 1.26 2.52 3.79 16 | 2016-04-03 20h27 1.24 2.49 3.75 17 | 2016-04-17 13h38 1.23 2.47 3.72 18 | 2016-05-05 14h36 1.22 2.44 3.66 19 | 20 | 21 | MagnetNode : 22 | Battery 3.27 @19h52 16/04/2016 23 | Battery 2.99 @22h00 17/04/2016 24 | Battery 2.96 @19h30 18/04/2016 25 | Battery 2.96 @19h46 19/04/2016 26 | Battery 2.95 @21h28 20/04/2016 (22,5°) 27 | Battery 2.96 @19h55 21/04/2016 (25,1° temp increase ?) 28 | Battery 2.96 @20h40 22/04/2016 23.5° 29 | Battery 2.95 @20h42 23/04/2016 20.8° 30 | Battery 2.94 @21h00 25/04/2016 19.0° 31 | Battery 2.94 @21h04 26/04/2016 32 | Battery 2.95 @20h00 27/04/2016 21.5° 33 | Battery 2.96 @22h22 03/05/2016 20.5° 34 | Battery 2.97 @21h18 12/05/2016 35 | Battery 2.95 @19h58 24/05/2016 36 | Battery 2.94 @10h30 25/06/2016 => No Alive message, restarted => OK 37 | -------------------------------------------------------------------------------- /ws01_WeatherLogger/pr03_RFSender_LowPower/pr03_RFSender_LowPower.ewt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2 5 | 6 | Debug 7 | 8 | STM8 9 | 10 | 1 11 | 12 | 13 | Release 14 | 15 | STM8 16 | 17 | 0 18 | 19 | 20 | LibraryCommon 21 | 22 | $PROJ_DIR$\..\pr00_LibraryCommon\ClockUartLed.c 23 | 24 | 25 | $PROJ_DIR$\..\pr00_LibraryCommon\ClockUartLed.h 26 | 27 | 28 | $PROJ_DIR$\..\pr00_LibraryCommon\commonTypes.h 29 | 30 | 31 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_IRQ.c 32 | 33 | 34 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_IRQ.h 35 | 36 | 37 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_LowLevel.c 38 | 39 | 40 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_LowLevel.h 41 | 42 | 43 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_Modes.c 44 | 45 | 46 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_Modes.h 47 | 48 | 49 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_RegText.c 50 | 51 | 52 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_RegText.h 53 | 54 | 55 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_SPI.c 56 | 57 | 58 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_SPI.h 59 | 60 | 61 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_Tx.c 62 | 63 | 64 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_Tx.h 65 | 66 | 67 | $PROJ_DIR$\..\pr00_LibraryCommon\temp_ds18b20.c 68 | 69 | 70 | $PROJ_DIR$\..\pr00_LibraryCommon\temp_ds18b20.h 71 | 72 | 73 | 74 | $PROJ_DIR$\mainTxLP.c 75 | 76 | 77 | $PROJ_DIR$\nRF_Configuration.h 78 | 79 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /ws01_WeatherLogger/pr04_RF_Light_Temperature/.gitignore: -------------------------------------------------------------------------------- 1 | Debug/ 2 | settings/ 3 | -------------------------------------------------------------------------------- /ws01_WeatherLogger/pr04_RF_Light_Temperature/i2c_m.h: -------------------------------------------------------------------------------- 1 | /** @file i2c.h 2 | * 3 | * @author Wassim FILALI 4 | * 5 | * 6 | * @compiler IAR STM8 7 | * 8 | * 9 | * $Date: 04.01.2016 10 | * $Revision: 11 | * 12 | */ 13 | 14 | #include "commonTypes.h" 15 | 16 | //------------------------------------------------------------------------------------------------------------------ 17 | // User configuration 18 | //------------------------------------------------------------------------------------------------------------------ 19 | #define Enable_Debug_I2C_IRQ 0 20 | 21 | 22 | //------------------------------------------------------------------------------------------------------------------ 23 | 24 | //configuration application section, not to be edited 25 | //--------------------------------------------------------------------------------------------- 26 | #if (Enable_Debug_I2C_IRQ == 1) 27 | #define I2C_IRQ_Printf(x) UARTPrintf(x) 28 | #define I2C_IRQ_PrintfHex(x) UARTPrintfHex(x) 29 | #define I2C_IRQ_PrintStatus(x) nRF_PrintStatus(x) 30 | #else 31 | #define I2C_IRQ_Printf(x) (void)0 32 | #define I2C_IRQ_PrintfHex(x) (void)0 33 | #define I2C_IRQ_PrintStatus(x) (void)0 34 | #endif 35 | 36 | //--------------------------------------------------------------------------------------------- 37 | 38 | 39 | //------------------------------------------------------------------------------------------------------------------ 40 | // I2C Registers 41 | //------------------------------------------------------------------------------------------------------------------ 42 | // I2C_CR1 Control Register 1 43 | // I2C_CR2 Control Register 2 44 | // I2C_FREQR Frequency Register 45 | // I2C_OARL Own Address Register LSB 46 | // I2C_OARH Own Address Register MSB 47 | // I2C_DR Data Register 48 | // I2C_SR1 Status Register 1 49 | // I2C_SR2 Status Register 2 50 | // I2C_SR3 Status Register 3 51 | // I2C_ITR Interrupt Register 52 | // I2C_CCRL Clock Control Register Low 53 | // I2C_CCRH Clock Control Register High 54 | // I2C_TRISER Tristate Enable register 55 | // funny the I2C_PECR is documented in STM8S103F3 specification while the Packet Error Checking is not part of the S family 56 | // 57 | //all reset to 0 58 | //------------------------------------------------------------------------------------------------------------------ 59 | 60 | // 61 | // STM8 I2C system. 62 | // default is slave, goes to master on Start and back to slave on stop 63 | // Addresses are 7/10 bits (one or two bytes), a Genral Call address can be enabled or disabled 64 | // 9th bit is acknowledge from the slave 65 | void I2C_Init(); 66 | 67 | void I2C_Transaction(BYTE read,BYTE slaveAddress, BYTE* buffer,BYTE count); 68 | 69 | void I2C_Read(BYTE slaveAddress, BYTE* buffer,BYTE count); 70 | 71 | void I2C_Write(BYTE slaveAddress, BYTE* buffer,BYTE count); 72 | 73 | void i2c_user_Rx_Callback(BYTE *userdata,BYTE size); 74 | 75 | void i2c_user_Tx_Callback(BYTE *userdata,BYTE size); 76 | 77 | 78 | void i2c_user_Error_Callback(BYTE l_sr2); 79 | -------------------------------------------------------------------------------- /ws01_WeatherLogger/pr04_RF_Light_Temperature/pr04_RF_Light_Temperature.ewt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2 5 | 6 | Debug 7 | 8 | STM8 9 | 10 | 1 11 | 12 | 13 | Release 14 | 15 | STM8 16 | 17 | 0 18 | 19 | 20 | LibraryCommon 21 | 22 | $PROJ_DIR$\..\pr00_LibraryCommon\ClockUartLed.c 23 | 24 | 25 | $PROJ_DIR$\..\pr00_LibraryCommon\ClockUartLed.h 26 | 27 | 28 | $PROJ_DIR$\..\pr00_LibraryCommon\commonTypes.h 29 | 30 | 31 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_IRQ.c 32 | 33 | 34 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_IRQ.h 35 | 36 | 37 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_LowLevel.c 38 | 39 | 40 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_LowLevel.h 41 | 42 | 43 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_Modes.c 44 | 45 | 46 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_Modes.h 47 | 48 | 49 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_RegText.c 50 | 51 | 52 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_RegText.h 53 | 54 | 55 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_SPI.c 56 | 57 | 58 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_SPI.h 59 | 60 | 61 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_Tx.c 62 | 63 | 64 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_Tx.h 65 | 66 | 67 | $PROJ_DIR$\..\pr00_LibraryCommon\temp_ds18b20.c 68 | 69 | 70 | $PROJ_DIR$\..\pr00_LibraryCommon\temp_ds18b20.h 71 | 72 | 73 | 74 | $PROJ_DIR$\i2c_m.c 75 | 76 | 77 | $PROJ_DIR$\i2c_m.h 78 | 79 | 80 | $PROJ_DIR$\mainTx.c 81 | 82 | 83 | $PROJ_DIR$\nRF_Configuration.h 84 | 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /ws01_WeatherLogger/settings/ws01_WeatherLogger.wspos: -------------------------------------------------------------------------------- 1 | [MainWindow] 2 | WindowPlacement=_ 312 229 1677 1384 1 3 | -------------------------------------------------------------------------------- /ws01_WeatherLogger/ws01_WeatherLogger.eww: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | $WS_DIR$\pr01_Temperature_RF_Sender\01_Temperature_RF_Sender.ewp 6 | 7 | 8 | $WS_DIR$\pr02_RF_ReceiveLogger\02_RF_ReceiveLogger.ewp 9 | 10 | 11 | $WS_DIR$\pr04_RF_Light_Temperature\pr04_RF_Light_Temperature.ewp 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /ws03_RF_Sync/pr00_LibraryCommon/ClockUartLed.h: -------------------------------------------------------------------------------- 1 | /** @file ClockUartLed.h 2 | * 3 | * @author Wassim FILALI taken over from http://blog.mark-stevens.co.uk/ 4 | * 5 | * @compiler IAR STM8 6 | * 7 | * 8 | * $Date: 20.09.2015 9 | * $Revision: 10 | * 11 | */ 12 | 13 | 14 | #define delay_1us(); delay(0); 15 | 16 | #define delay_10us(); delay(18); 17 | 18 | #define delay_50us(); delay(98); 19 | 20 | #define delay_100us(); delay(198); 21 | 22 | #define delay_1ms(); delay(1998); 23 | 24 | #define delay_10ms(); delay(19998); 25 | 26 | 27 | void InitialiseUART(); 28 | 29 | void UARTPrintf(char const *message); 30 | 31 | void UARTPrintfLn(char const *message); 32 | 33 | void UARTPrintfHex(unsigned char val); 34 | 35 | void UARTPrintfHexTable(unsigned char *pval,unsigned char length); 36 | 37 | void UARTPrintfHexLn(unsigned char val); 38 | 39 | void UARTPrintf_sint(signed int num); 40 | 41 | void UARTPrintf_uint(unsigned int num); 42 | 43 | void InitialiseSystemClock(); 44 | 45 | void delay(unsigned int n); 46 | 47 | void delay_ms(unsigned int n); 48 | 49 | 50 | // L E D 51 | void Initialise_TestLed_GPIO_B5(); 52 | void Test_Led_On(); 53 | void Test_Led_Off(); 54 | 55 | -------------------------------------------------------------------------------- /ws03_RF_Sync/pr00_LibraryCommon/WS2812B.h: -------------------------------------------------------------------------------- 1 | /** @file WS2812B.h 2 | * 3 | * @author Wassim FILALI 4 | * Inferred from the Datasheet 5 | * 6 | * 7 | * @compiler IAR STM8 8 | * 9 | * 10 | * started on local project on 10.10.2015 11 | * this file was created for refactoring on 03.01.2016 12 | * $Date: 13 | * $Revision: 14 | * 15 | */ 16 | 17 | #define NB_LEDS 60 18 | #define RGBLedPIN_A 2 19 | 20 | #include "commonTypes.h" 21 | 22 | typedef struct 23 | { 24 | BYTE R; 25 | BYTE G; 26 | BYTE B; 27 | }RGBColor_t; 28 | 29 | 30 | extern const RGBColor_t RED; 31 | extern const RGBColor_t GREEN; 32 | extern const RGBColor_t BLUE; 33 | extern const RGBColor_t BLACK; 34 | extern const RGBColor_t WHITE; 35 | 36 | 37 | // user configuration 38 | 39 | #define SwitchOffLed(); SendLedColor(0, 0, 0); 40 | 41 | // shared variables 42 | 43 | void RGBLeds_PIO_Init(); 44 | 45 | void SetLedColor(BYTE LedId, BYTE R, BYTE G, BYTE B); 46 | void SetLedColors(BYTE LedId,RGBColor_t Color); 47 | 48 | void SendLedsArray(); 49 | 50 | void RGB_SwitchOff(BYTE first,BYTE NbLeds); 51 | 52 | void SendLedColor(BYTE R, BYTE G, BYTE B); 53 | void SendLedColors(RGBColor_t Color); 54 | 55 | 56 | void RampColors(BYTE delay,BYTE RUp,BYTE GUp,BYTE BUp,BYTE R,BYTE G,BYTE B); 57 | 58 | void BlinkColors(BYTE R, BYTE G, BYTE B); 59 | 60 | void FlashColors(BYTE delay, RGBColor_t Color); 61 | 62 | RGBColor_t ColorScale(int iCount,int nbCount,RGBColor_t ColorStart,RGBColor_t ColorEnd); 63 | 64 | void ShadeLeds(BYTE LedStart, BYTE LedEnd, RGBColor_t ColorStart, RGBColor_t ColorEnd); 65 | -------------------------------------------------------------------------------- /ws03_RF_Sync/pr00_LibraryCommon/commonTypes.h: -------------------------------------------------------------------------------- 1 | /** @file nRF_Modes.h 2 | * 3 | * @author Wassim FILALI 4 | * 5 | * 6 | * @compiler IAR STM8 7 | * 8 | * 9 | * $Date: 13.12.2015 10 | * $Revision: 11 | * 12 | */ 13 | 14 | // UINT type definition 15 | #ifndef _UINT_DEF_ 16 | #define _UINT_DEF_ 17 | typedef unsigned int UINT; 18 | #endif 19 | 20 | // BYTE type definition 21 | #ifndef _BYTE_DEF_ 22 | #define _BYTE_DEF_ 23 | typedef unsigned char BYTE; 24 | #endif 25 | 26 | 27 | #ifndef E_OK 28 | #define E_OK 0x00 29 | #endif 30 | 31 | #ifndef E_Already_Initialised 32 | #define E_Already_Initialised 0x01 33 | #endif 34 | 35 | -------------------------------------------------------------------------------- /ws03_RF_Sync/pr00_LibraryCommon/nRF_IRQ.h: -------------------------------------------------------------------------------- 1 | /** @file nRF_IRQ.h 2 | * 3 | * @author Wassim FILALI, inspired from nRF24L01P-EK 4 | * 5 | * @compiler IAR STM8 6 | * 7 | * 8 | * $Date: 14.12.2015 9 | * $Revision: 10 | * 11 | */ 12 | 13 | //nRF24L01P module IRQ on D2 14 | 15 | void nRF_IRQ_Config(); 16 | -------------------------------------------------------------------------------- /ws03_RF_Sync/pr00_LibraryCommon/nRF_LowLevel.c: -------------------------------------------------------------------------------- 1 | /** @file nRF_LowLevel.h 2 | * 3 | * @author Wassim FILALI, inspired from nRF24L01P-EK 4 | * 5 | * @compiler IAR STM8 6 | * 7 | * 8 | * $Date: 20.09.2015 9 | * $Revision: 10 | * 11 | */ 12 | 13 | #include 14 | 15 | #include "nRF_LowLevel.h" 16 | 17 | //---------------------------------------------------------------------------------------------------------- 18 | // PC7 SPI_MISO 19 | // PC6 SPI_MOSI 20 | // PC5 SPI_SCK 21 | // PC4 GPIO_OUT CSN Chip Select Negative 22 | // PC3 GPIO_OUT CE Chip Enable (this signal is active high and used to activate the chip in RX or TX mode) 23 | //---------------------------------------------------------------------------------------------------------- 24 | 25 | 26 | void SPI_Init_ChipEnable_Pin() 27 | { 28 | //To be disabled before configuration Low is Disable 29 | PC_ODR_ODR3 = 0; 30 | 31 | // 0: Input 1: Output 32 | PC_DDR_DDR3 = 1; 33 | 34 | // 0: Pseudo open drain 1: Push-pull 35 | PC_CR1_C13 = 1; 36 | // 0: Output speed up to 2 MHz 1: Output speed up to 10 MHz 37 | PC_CR2_C23 = 1; 38 | } 39 | void CE_Pin_LowDisable() 40 | { 41 | PC_ODR_ODR3 = 0; 42 | } 43 | 44 | void CE_Pin_HighEnable() 45 | { 46 | PC_ODR_ODR3 = 1; 47 | } 48 | 49 | void SPI_Init_ChipSelect_Pin() 50 | { 51 | //To be disabled before configuration High is Disable 52 | PC_ODR_ODR4 = 1; 53 | // 0: Input 1: Output 54 | PC_DDR_DDR4 = 1; 55 | // 0: Pseudo open drain 1: Push-pull 56 | PC_CR1_C14 = 1; 57 | // 0: Output speed up to 2 MHz 1: Output speed up to 10 MHz 58 | PC_CR2_C24 = 1; 59 | } 60 | 61 | void CSN_Pin_LowSelect() 62 | { 63 | PC_ODR_ODR4 = 0; 64 | } 65 | 66 | void CSN_Pin_HighDisable() 67 | { 68 | PC_ODR_ODR4 = 1; 69 | } 70 | 71 | //Initialise the Configuration registers 1 and 2. Also resets the polynomial to the default 72 | void SPI_Init_Peripheral() 73 | { 74 | //const BYTE SPI_CR1_BR_fDiv256 = 0x07; 75 | const BYTE SPI_CR1_BR_fDiv2 = 0x00;//16MHz/2 = 8Mbps 76 | 77 | SPI_CR1 = 0x00;//default reset value 78 | //SPI_CR1_LSBFIRST = 0; 79 | SPI_CR1_BR = SPI_CR1_BR_fDiv2; 80 | //SPI_CR1_CPOL = 0; Low when Idle 81 | //SPI_CR1_CPHA = 0; 1st edge 82 | 83 | SPI_CR2 = 0x00; 84 | //SPI_CR2_BDM = 0;// 2 lines 85 | SPI_CR2_SSM = 1;//Software Slave Management Enabled 86 | SPI_CR2_SSI = 1;//Master Mode 87 | 88 | //Set the SPI in Master Mode 89 | SPI_CR1_MSTR = 1; 90 | 91 | SPI_CRCPR = 0x07;//CRC Polynomial reset value is 0x07 92 | 93 | //Enable the SPI Peripheral 94 | SPI_CR1_SPE = 1; 95 | 96 | } 97 | 98 | //RM0016 Note : Do not use the BSY flag to handle each data transmission or reception. 99 | //It is better to use TXE and RXNE flags instead. 100 | BYTE SPI_WriteRead(BYTE Data) 101 | { 102 | //Wait while (Tx Buffer not Empty); 103 | while(SPI_SR_TXE == 0); 104 | SPI_DR = Data; 105 | //while (SPI_GetFlagStatus(SPI_FLAG_BSY)== SET);// Do not use Busy Flag in every transaction 106 | //Wait while Rx Buffer Empty 107 | while(SPI_SR_RXNE == 0); 108 | 109 | return SPI_DR; 110 | } 111 | -------------------------------------------------------------------------------- /ws03_RF_Sync/pr00_LibraryCommon/nRF_LowLevel.h: -------------------------------------------------------------------------------- 1 | /** @file nRF_LowLevel.h 2 | * 3 | * @author Wassim FILALI, inspired from nRF24L01P-EK 4 | * 5 | * @compiler IAR STM8 6 | * 7 | * This low level is applied on the STM8103F3 so this should be the only file 8 | * to modify when porting this to another MCU 9 | * 10 | * $Date: 20.09.2015 11 | * $Revision: 12 | * 13 | */ 14 | 15 | //for BYTE 16 | #include "commonTypes.h" 17 | 18 | //------------------------Low Level API------------------------ 19 | 20 | void SPI_Init_ChipEnable_Pin(); 21 | 22 | void CE_Pin_LowDisable(); 23 | 24 | void CE_Pin_HighEnable(); 25 | 26 | void SPI_Init_ChipSelect_Pin(); 27 | 28 | void CSN_Pin_LowSelect(); 29 | 30 | void CSN_Pin_HighDisable(); 31 | 32 | void SPI_Init_Peripheral(); 33 | 34 | BYTE SPI_WriteRead(BYTE Data); 35 | -------------------------------------------------------------------------------- /ws03_RF_Sync/pr00_LibraryCommon/nRF_Modes.h: -------------------------------------------------------------------------------- 1 | /** @file nRF_Modes.h 2 | * 3 | * @author Wassim FILALI 4 | * Directly inferred from the Datasheet 5 | * 6 | * 7 | * @compiler IAR STM8 8 | * 9 | * 10 | * $Date: 12.12.2015 11 | * $Revision: 12 | * 13 | */ 14 | 15 | //for BYTE 16 | #include "commonTypes.h" 17 | 18 | 19 | #define nRF_Mode_Uninitialised 0x00 20 | #define nRF_Mode_PowerDown 0x01 21 | #define nRF_Mode_Standby 0x02 22 | //Same Standby-I with TX configured PRIM_RX = 0 23 | #define nRF_Mode_Standby_TX 0x03 24 | #define nRF_Mode_Tx 0x04 25 | #define nRF_Mode_Rx 0x05 26 | 27 | BYTE nRF_Config(); 28 | 29 | BYTE nRF_Init();//Waiting power on reset and initialising SPI 30 | 31 | // The Radio control operational modes are following the description from 32 | // nRF24L01P Product Specification 1.0 page 21 33 | 34 | BYTE nRF_SetMode_PowerDown(); 35 | 36 | BYTE nRF_SetMode_Standby_I(); 37 | 38 | BYTE nRF_SetMode_RX(); 39 | 40 | BYTE nRF_Try_SetMode_TX(); 41 | 42 | BYTE nRF_ClearStatus(); 43 | BYTE nRF_ClearStatus_bit(BYTE bit_ToClear); 44 | 45 | 46 | 47 | //Global variable to manage the current mode 48 | 49 | extern BYTE nRF_Mode; 50 | extern BYTE ConfigVal; 51 | -------------------------------------------------------------------------------- /ws03_RF_Sync/pr00_LibraryCommon/nRF_RegText.c: -------------------------------------------------------------------------------- 1 | /** @file nRF_RegText.c 2 | * 3 | * @author Wassim FILALI 4 | * 5 | * @compiler IAR STM8 6 | * 7 | * $Date: 13.12.2015 8 | * $Revision: 9 | * 10 | */ 11 | 12 | #include "nRF_RegText.h" 13 | #include "nRF_SPI.h" 14 | #include "ClockUartLed.h" 15 | 16 | void nRF_PrintStatus(BYTE status) 17 | { 18 | UARTPrintf("STATUS: "); 19 | UARTPrintfHex(status); 20 | UARTPrintf(" : "); 21 | 22 | if(status & bit_RX_DR) 23 | { 24 | UARTPrintf("Data Ready i; "); 25 | } 26 | if(status & bit_TX_DS) 27 | { 28 | UARTPrintf("Data Sent i; "); 29 | } 30 | if(status & bit_MAX_RT) 31 | { 32 | UARTPrintf("Max Ret i; "); 33 | } 34 | if( (status & bit_Mask_RXPNO) == bit_RXPNO_NotUsed) 35 | { 36 | UARTPrintf("Rx Pipe not used ; "); 37 | } 38 | else if( (status & bit_Mask_RXPNO) == bit_RXPNO_RxFFEmpty) 39 | { 40 | //UARTPrintf("Rx Fifo Empty ; ");// this is the default state not log for it 41 | } 42 | else 43 | { 44 | BYTE PipeNb = (status & bit_Mask_RXPNO)>>1; 45 | UARTPrintf("Rx Pipe Nb "); 46 | UARTPrintfHex(PipeNb); 47 | UARTPrintf(" ; "); 48 | } 49 | if(status & bit_TX_FULL) 50 | { 51 | UARTPrintf("TX Fifo Full;"); 52 | } 53 | UARTPrintf("\n\r"); 54 | } 55 | 56 | void nRF_PrintConfig() 57 | { 58 | 59 | } 60 | -------------------------------------------------------------------------------- /ws03_RF_Sync/pr00_LibraryCommon/nRF_RegText.h: -------------------------------------------------------------------------------- 1 | /** @file nRF_RegText.h 2 | * 3 | * @author Wassim FILALI 4 | * 5 | * @compiler IAR STM8 6 | * 7 | * $Date: 13.12.2015 8 | * $Revision: 9 | * 10 | */ 11 | 12 | #include "commonTypes.h" 13 | 14 | void nRF_PrintStatus(BYTE status); 15 | void nRF_PrintConfig(); 16 | -------------------------------------------------------------------------------- /ws03_RF_Sync/pr00_LibraryCommon/nRF_SPI.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HomeSmartMesh/IoT_STM8/541ae723d424edbea4a077d8590023a95d9712cb/ws03_RF_Sync/pr00_LibraryCommon/nRF_SPI.h -------------------------------------------------------------------------------- /ws03_RF_Sync/pr00_LibraryCommon/nRF_Tx.c: -------------------------------------------------------------------------------- 1 | /** @file nRF_Tx.c 2 | * 3 | * @author Wassim FILALI 4 | * Inferred from the Datasheet 5 | * 6 | * 7 | * @compiler IAR STM8 8 | * 9 | * 10 | * $Date: 12.12.2015 11 | * $Revision: 12 | * 13 | */ 14 | 15 | #include "nRF_Tx.h" 16 | //for nRF_Mode 17 | #include "nRF_Modes.h" 18 | //for SPI_Write_Buf 19 | #include "nRF_SPI.h" 20 | #include "ClockUartLed.h" 21 | #include "nRF_LowLevel.h" 22 | 23 | //returns the status byte 24 | BYTE nRF_Transmit(BYTE* payload, BYTE size) 25 | { 26 | BYTE status; 27 | //As CE is low, will alwasy lead to Standby, while nRF_Mode could be Standby_II 28 | status = SPI_Command(FLUSH_TX,0x00); 29 | //unused result status 30 | 31 | //Write the buffer to make sure we can go in Tx Mode 32 | status = SPI_Write_Buf(WR_TX_PLOAD,payload,size); 33 | 34 | 35 | if (nRF_Mode == nRF_Mode_Rx)//To switch from Rx to TX CE should go Low 36 | { 37 | CE_Pin_LowDisable(); 38 | delay_10us();//minimal transition delay 39 | nRF_Try_SetMode_TX();//Switch to TX : PRIM_RX = 0 40 | } 41 | 42 | //Create favorable conditions for Transmitting 43 | CE_Pin_HighEnable();//pulse for more than 10 us 44 | delay_10us(); 45 | delay_10us(); 46 | 47 | //if PRIM_RX == 1 48 | if ( (nRF_Mode != nRF_Mode_Tx) && (nRF_Mode != nRF_Mode_Standby_TX) ) 49 | { 50 | //this function will wait for the 130 us as the fifo is not empty 51 | nRF_Try_SetMode_TX(); 52 | } 53 | else//as TX_Mode was deprecated any way, we just do not need TX configuration 54 | { 55 | // TX Settings 56 | 57 | delay_100us(); 58 | delay_10us(); 59 | delay_10us(); 60 | delay_10us(); 61 | nRF_Mode = nRF_Mode_Tx; 62 | 63 | } 64 | 65 | //in some time 66 | //TX finished with one packet CE == 0 -> Standby_TX 67 | 68 | CE_Pin_LowDisable(); 69 | 70 | 71 | return status; 72 | } 73 | -------------------------------------------------------------------------------- /ws03_RF_Sync/pr00_LibraryCommon/nRF_Tx.h: -------------------------------------------------------------------------------- 1 | /** @file nRF_Tx.h 2 | * 3 | * @author Wassim FILALI 4 | * Inferred from the Datasheet 5 | * 6 | * 7 | * @compiler IAR STM8 8 | * 9 | * 10 | * $Date: 12.12.2015 11 | * $Revision: 12 | * 13 | */ 14 | 15 | //for BYTE 16 | #include "commonTypes.h" 17 | 18 | BYTE nRF_Transmit(BYTE* payload, BYTE size); -------------------------------------------------------------------------------- /ws03_RF_Sync/pr00_LibraryCommon/temp_ds18b20.h: -------------------------------------------------------------------------------- 1 | /** @file temp_ds18b20.h 2 | * 3 | * @author Wassim FILALI 4 | * Inferred from the Datasheet 5 | * 6 | * 7 | * @compiler IAR STM8 8 | * 9 | * 10 | * started on local project on 12.10.2015 11 | * this file was created for refactoring on 26.12.2015 12 | * $Date: 26.12.2015 13 | * $Revision: 14 | * 15 | */ 16 | 17 | #include "commonTypes.h" 18 | 19 | void Initialise_OneWire_Pin_A2(); 20 | 21 | void OneWire_Reset(); 22 | 23 | BYTE OneWire_CheckPresence(); 24 | 25 | BYTE OneWire_Init(); 26 | 27 | BYTE OneWire_ReadBit(); 28 | 29 | void OneWire_WriteByte(BYTE byte); 30 | 31 | BYTE OneWire_ReadByte(); 32 | 33 | BYTE DS18B20_Single_ReadRom(BYTE * rom); 34 | 35 | BYTE DS18B20_Single_ReadScratchPad(BYTE * sp,BYTE length); 36 | 37 | BYTE DS18B20_Single_ReadTemperature(BYTE * data); 38 | 39 | void UARTPrint_DS18B20_Temperature(BYTE * data); 40 | -------------------------------------------------------------------------------- /ws03_RF_Sync/pr01_RF_Client/pr01_RF_Client.ewt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2 5 | 6 | Debug 7 | 8 | STM8 9 | 10 | 1 11 | 12 | 13 | Release 14 | 15 | STM8 16 | 17 | 0 18 | 19 | 20 | pr00_LibraryCommon 21 | 22 | $PROJ_DIR$\..\pr00_LibraryCommon\ClockUartLed.c 23 | 24 | 25 | $PROJ_DIR$\..\pr00_LibraryCommon\ClockUartLed.h 26 | 27 | 28 | $PROJ_DIR$\..\pr00_LibraryCommon\commonTypes.h 29 | 30 | 31 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_IRQ.c 32 | 33 | 34 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_IRQ.h 35 | 36 | 37 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_LowLevel.c 38 | 39 | 40 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_LowLevel.h 41 | 42 | 43 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_Modes.c 44 | 45 | 46 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_Modes.h 47 | 48 | 49 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_RegText.c 50 | 51 | 52 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_RegText.h 53 | 54 | 55 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_SPI.c 56 | 57 | 58 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_SPI.h 59 | 60 | 61 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_Tx.c 62 | 63 | 64 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_Tx.h 65 | 66 | 67 | $PROJ_DIR$\..\pr00_LibraryCommon\temp_ds18b20.c 68 | 69 | 70 | $PROJ_DIR$\..\pr00_LibraryCommon\temp_ds18b20.h 71 | 72 | 73 | $PROJ_DIR$\..\pr00_LibraryCommon\WS2812B.c 74 | 75 | 76 | $PROJ_DIR$\..\pr00_LibraryCommon\WS2812B.h 77 | 78 | 79 | 80 | $PROJ_DIR$\mainClient.c 81 | 82 | 83 | $PROJ_DIR$\nRF_Configuration.h 84 | 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /ws03_RF_Sync/pr01_RF_Client/settings/pr01_RF_Client.Debug.cspy.bat: -------------------------------------------------------------------------------- 1 | @REM This batch file has been generated by the IAR Embedded Workbench 2 | @REM C-SPY Debugger, as an aid to preparing a command line for running 3 | @REM the cspybat command line utility using the appropriate settings. 4 | @REM 5 | @REM Note that this file is generated every time a new debug session 6 | @REM is initialized, so you may want to move or rename the file before 7 | @REM making changes. 8 | @REM 9 | @REM You can launch cspybat by typing the name of this batch file followed 10 | @REM by the name of the debug file (usually an ELF/DWARF or UBROF file). 11 | @REM 12 | @REM Read about available command line parameters in the C-SPY Debugging 13 | @REM Guide. Hints about additional command line parameters that may be 14 | @REM useful in specific cases: 15 | @REM --download_only Downloads a code image without starting a debug 16 | @REM session afterwards. 17 | @REM --silent Omits the sign-on message. 18 | @REM --timeout Limits the maximum allowed execution time. 19 | @REM 20 | 21 | 22 | "C:\Program Files (x86)\IAR Systems\Embedded Workbench 7.0\common\bin\cspybat" "C:\Program Files (x86)\IAR Systems\Embedded Workbench 7.0\stm8\bin\stm8proc.dll" "C:\Program Files (x86)\IAR Systems\Embedded Workbench 7.0\stm8\bin\stm8stlink.dll" %1 --plugin "C:\Program Files (x86)\IAR Systems\Embedded Workbench 7.0\stm8\bin\stm8bat.dll" --backend -B "-p" "C:\Program Files (x86)\IAR Systems\Embedded Workbench 7.0\stm8\config\ddf\iostm8s103f3.ddf" "-d" "stlink" "--mcuname" "STM8S103F3P" 23 | 24 | 25 | -------------------------------------------------------------------------------- /ws03_RF_Sync/pr01_RF_Client/settings/pr01_RF_Client.dni: -------------------------------------------------------------------------------- 1 | [InterruptLog] 2 | LogEnabled=0 3 | SumEnabled=0 4 | GraphEnabled=0 5 | ShowTimeLog=1 6 | ShowTimeSum=1 7 | SumSortOrder=0 8 | [DataLog] 9 | LogEnabled=0 10 | SumEnabled=0 11 | GraphEnabled=0 12 | ShowTimeLog=1 13 | ShowTimeSum=1 14 | [Stack] 15 | FillEnabled=0 16 | OverflowWarningsEnabled=1 17 | WarningThreshold=90 18 | SpWarningsEnabled=1 19 | WarnLogOnly=1 20 | UseTrigger=1 21 | TriggerName=main 22 | LimitSize=0 23 | ByteLimit=50 24 | [Breakpoints2] 25 | Count=0 26 | [Interrupts] 27 | Enabled=1 28 | [MemoryMap] 29 | Enabled=0 30 | Base=0 31 | UseAuto=0 32 | TypeViolation=1 33 | UnspecRange=1 34 | ActionState=1 35 | [Trace1] 36 | Enabled=0 37 | ShowSource=1 38 | [Simulator] 39 | Freq=16000000 40 | [DebugChecksum] 41 | Checksum=23251100 42 | [CallStack] 43 | ShowArgs=0 44 | [Disassembly] 45 | MixedMode=1 46 | [DataSample] 47 | LogEnabled=0 48 | GraphEnabled=0 49 | ShowTimeLog=1 50 | ShowTimeSum=1 51 | [Log file] 52 | LoggingEnabled=_ 0 53 | LogFile=_ "" 54 | Category=_ 0 55 | [TermIOLog] 56 | LoggingEnabled=_ 0 57 | LogFile=_ "" 58 | [Breakpoints] 59 | Bp0=_ "STD_CODE" "{$PROJ_DIR$\..\pr00_LibraryCommon\nRF_IRQ.c}.84.7" 1 0 0 0 "" 0 "" 60 | Count=1 61 | [Aliases] 62 | Count=0 63 | SuppressDialog=0 64 | [DebuggerSettings] 65 | DisableInterruptsWhenStepping=0 66 | -------------------------------------------------------------------------------- /ws03_RF_Sync/pr02_RF_Server/pr02_RF_Server.ewt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2 5 | 6 | Debug 7 | 8 | STM8 9 | 10 | 1 11 | 12 | 13 | Release 14 | 15 | STM8 16 | 17 | 0 18 | 19 | 20 | pr00_LibraryCommon 21 | 22 | $PROJ_DIR$\..\pr00_LibraryCommon\ClockUartLed.c 23 | 24 | 25 | $PROJ_DIR$\..\pr00_LibraryCommon\ClockUartLed.h 26 | 27 | 28 | $PROJ_DIR$\..\pr00_LibraryCommon\commonTypes.h 29 | 30 | 31 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_IRQ.c 32 | 33 | 34 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_IRQ.h 35 | 36 | 37 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_LowLevel.c 38 | 39 | 40 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_LowLevel.h 41 | 42 | 43 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_Modes.c 44 | 45 | 46 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_Modes.h 47 | 48 | 49 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_RegText.c 50 | 51 | 52 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_RegText.h 53 | 54 | 55 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_SPI.c 56 | 57 | 58 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_SPI.h 59 | 60 | 61 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_Tx.c 62 | 63 | 64 | $PROJ_DIR$\..\pr00_LibraryCommon\nRF_Tx.h 65 | 66 | 67 | $PROJ_DIR$\..\pr00_LibraryCommon\temp_ds18b20.c 68 | 69 | 70 | $PROJ_DIR$\..\pr00_LibraryCommon\temp_ds18b20.h 71 | 72 | 73 | $PROJ_DIR$\..\pr00_LibraryCommon\WS2812B.c 74 | 75 | 76 | $PROJ_DIR$\..\pr00_LibraryCommon\WS2812B.h 77 | 78 | 79 | 80 | $PROJ_DIR$\mainServer.c 81 | 82 | 83 | $PROJ_DIR$\nRF_Configuration.h 84 | 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /ws03_RF_Sync/pr02_RF_Server/settings/pr02_RF_Server.Debug.cspy.bat: -------------------------------------------------------------------------------- 1 | @REM This batch file has been generated by the IAR Embedded Workbench 2 | @REM C-SPY Debugger, as an aid to preparing a command line for running 3 | @REM the cspybat command line utility using the appropriate settings. 4 | @REM 5 | @REM Note that this file is generated every time a new debug session 6 | @REM is initialized, so you may want to move or rename the file before 7 | @REM making changes. 8 | @REM 9 | @REM You can launch cspybat by typing the name of this batch file followed 10 | @REM by the name of the debug file (usually an ELF/DWARF or UBROF file). 11 | @REM 12 | @REM Read about available command line parameters in the C-SPY Debugging 13 | @REM Guide. Hints about additional command line parameters that may be 14 | @REM useful in specific cases: 15 | @REM --download_only Downloads a code image without starting a debug 16 | @REM session afterwards. 17 | @REM --silent Omits the sign-on message. 18 | @REM --timeout Limits the maximum allowed execution time. 19 | @REM 20 | 21 | 22 | "C:\Program Files (x86)\IAR Systems\Embedded Workbench 7.0\common\bin\cspybat" "C:\Program Files (x86)\IAR Systems\Embedded Workbench 7.0\stm8\bin\stm8proc.dll" "C:\Program Files (x86)\IAR Systems\Embedded Workbench 7.0\stm8\bin\stm8stlink.dll" %1 --plugin "C:\Program Files (x86)\IAR Systems\Embedded Workbench 7.0\stm8\bin\stm8bat.dll" --backend -B "-p" "C:\Program Files (x86)\IAR Systems\Embedded Workbench 7.0\stm8\config\ddf\iostm8s103f3.ddf" "-d" "stlink" "--mcuname" "STM8S103F3P" 23 | 24 | 25 | -------------------------------------------------------------------------------- /ws03_RF_Sync/pr02_RF_Server/settings/pr02_RF_Server.dni: -------------------------------------------------------------------------------- 1 | [Stack] 2 | FillEnabled=0 3 | OverflowWarningsEnabled=1 4 | WarningThreshold=90 5 | SpWarningsEnabled=1 6 | WarnLogOnly=1 7 | UseTrigger=1 8 | TriggerName=main 9 | LimitSize=0 10 | ByteLimit=50 11 | [InterruptLog] 12 | LogEnabled=0 13 | SumEnabled=0 14 | GraphEnabled=0 15 | ShowTimeLog=1 16 | ShowTimeSum=1 17 | SumSortOrder=0 18 | [DataLog] 19 | LogEnabled=0 20 | SumEnabled=0 21 | GraphEnabled=0 22 | ShowTimeLog=1 23 | ShowTimeSum=1 24 | [Breakpoints2] 25 | Count=0 26 | [Interrupts] 27 | Enabled=1 28 | [MemoryMap] 29 | Enabled=0 30 | Base=0 31 | UseAuto=0 32 | TypeViolation=1 33 | UnspecRange=1 34 | ActionState=1 35 | [Trace1] 36 | Enabled=0 37 | ShowSource=1 38 | [Simulator] 39 | Freq=16000000 40 | [DebugChecksum] 41 | Checksum=1269316708 42 | [CallStack] 43 | ShowArgs=0 44 | [Disassembly] 45 | MixedMode=1 46 | [DataSample] 47 | LogEnabled=0 48 | GraphEnabled=0 49 | ShowTimeLog=1 50 | ShowTimeSum=1 51 | [Log file] 52 | LoggingEnabled=_ 0 53 | LogFile=_ "" 54 | Category=_ 0 55 | [TermIOLog] 56 | LoggingEnabled=_ 0 57 | LogFile=_ "" 58 | [Breakpoints] 59 | Count=0 60 | [Aliases] 61 | Count=0 62 | SuppressDialog=0 63 | [DebuggerSettings] 64 | DisableInterruptsWhenStepping=0 65 | -------------------------------------------------------------------------------- /ws03_RF_Sync/pr03_RF_Alive/deviceType.h: -------------------------------------------------------------------------------- 1 | #define DEVICE_STM8S 1 2 | -------------------------------------------------------------------------------- /ws03_RF_Sync/pr03_RF_Alive/mainServer.c: -------------------------------------------------------------------------------- 1 | /* 2 | main.c for 3 | IoT_Frameworks 4 | 5 | started 6 | refactored 03.11.2016 7 | 8 | */ 9 | 10 | //Test Led is Port B Pin 5 11 | 12 | 13 | #include "uart.h" 14 | #include "clock_led.h" 15 | 16 | //for nRF_Config() nRF_SetMode_RX() 17 | #include "nRF.h" 18 | 19 | #include "nRF_Tx.h" 20 | 21 | //for rx_pids and callbacks 22 | #include "rf_protocol.h" 23 | 24 | #define EEPROM_Offset 0x4000 25 | #define EE_NODE_ID (char *) EEPROM_Offset; 26 | BYTE NodeId; 27 | 28 | //User Rx CallBack 29 | void userRxCallBack(BYTE *rxData,BYTE rx_DataSize) 30 | { 31 | } 32 | 33 | int main( void ) 34 | { 35 | 36 | BYTE Tx_Data[3]; 37 | BYTE AliveActiveCounter = 0; 38 | 39 | NodeId = *EE_NODE_ID; 40 | 41 | 42 | rf_get_tx_alive_3B(NodeId,Tx_Data); 43 | 44 | InitialiseSystemClock(); 45 | 46 | Initialise_TestLed_GPIO_B5(); 47 | 48 | Test_Led_Off(); 49 | 50 | uart_init(); 51 | 52 | printf("\r\n__________________________________________________\n\r"); 53 | printf("IoT_Framworks\\ws03_RF_Sync\\pr03_RF_Alive\\\n\r"); 54 | 55 | //Applies the compile time configured parameters from nRF_Configuration.h 56 | BYTE status = nRF_Config(); 57 | 58 | while (1) 59 | { 60 | 61 | AliveActiveCounter++;//Why are you counting ? 62 | 63 | Test_Led_Off(); 64 | delay_ms(4900); 65 | 66 | nRF_Transmit(Tx_Data,3); 67 | Test_Led_On(); 68 | delay_ms(100); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /ws03_RF_Sync/pr03_RF_Alive/pr03_RF_Alive.ewt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2 5 | 6 | Debug 7 | 8 | STM8 9 | 10 | 1 11 | 12 | 13 | Release 14 | 15 | STM8 16 | 17 | 0 18 | 19 | 20 | libs 21 | 22 | $PROJ_DIR$\..\..\libs\clock_led.c 23 | 24 | 25 | $PROJ_DIR$\..\..\libs\clock_led.h 26 | 27 | 28 | $PROJ_DIR$\..\..\libs\commonTypes.h 29 | 30 | 31 | $PROJ_DIR$\..\..\libs\nRF.c 32 | 33 | 34 | $PROJ_DIR$\..\..\libs\nRF.h 35 | 36 | 37 | $PROJ_DIR$\..\..\libs\nRF_IRQ_stm8x.c 38 | 39 | 40 | $PROJ_DIR$\..\..\libs\nRF_IRQ_stm8x.h 41 | 42 | 43 | $PROJ_DIR$\..\..\libs\nRF_RegText.c 44 | 45 | 46 | $PROJ_DIR$\..\..\libs\nRF_RegText.h 47 | 48 | 49 | $PROJ_DIR$\..\..\libs\nRF_SPI.c 50 | 51 | 52 | $PROJ_DIR$\..\..\libs\nRF_SPI.h 53 | 54 | 55 | $PROJ_DIR$\..\..\libs\nRF_Tx.c 56 | 57 | 58 | $PROJ_DIR$\..\..\libs\nRF_Tx.h 59 | 60 | 61 | $PROJ_DIR$\..\..\libs\rf_protocol.c 62 | 63 | 64 | $PROJ_DIR$\..\..\libs\rf_protocol.h 65 | 66 | 67 | $PROJ_DIR$\..\..\libs\spi_stm8x.c 68 | 69 | 70 | $PROJ_DIR$\..\..\libs\spi_stm8x.h 71 | 72 | 73 | $PROJ_DIR$\..\..\libs\uart.c 74 | 75 | 76 | $PROJ_DIR$\..\..\libs\uart.h 77 | 78 | 79 | $PROJ_DIR$\..\..\libs\uart_stm8x.c 80 | 81 | 82 | $PROJ_DIR$\..\..\libs\uart_stm8x.h 83 | 84 | 85 | 86 | $PROJ_DIR$\deviceType.h 87 | 88 | 89 | $PROJ_DIR$\mainServer.c 90 | 91 | 92 | $PROJ_DIR$\nRF_Configuration.h 93 | 94 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /ws03_RF_Sync/ws03_RF_Sync.eww: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | $WS_DIR$\pr01_RF_Client\pr01_RF_Client.ewp 6 | 7 | 8 | $WS_DIR$\pr02_RF_Server\pr02_RF_Server.ewp 9 | 10 | 11 | $WS_DIR$\pr03_RF_Alive\pr03_RF_Alive.ewp 12 | 13 | 14 | 15 | 16 | 17 | --------------------------------------------------------------------------------