We need to develop a firmware + bootloader code for a tag device based on the STM8L051F3. The code needs to be in C, not assembler. I work with Atmel devices and need to make the transition to ST but I miss time to do it and I need help to make this code fast.
The tag device will be monitoring some environmental conditions and send its state (switches, ADC reading, bat voltage etc…) to a reader by a radio link.
The device will be powered by batteries and must last as long as possible. So the sleep modes and minimum processing time is required. This is very critical since there will be a big population of tags in the same area. We need to make sure we have a reliable code to avoid problems on so many units. Too much power sink would mean very long time to change the batteries on such a large population (+ cost of the batteries).
We have a reader to manage the population of tags. This reader will poll each device evry day at a precise time to make sure it is still there and functional. The tag will then communicate with to the reader and go back to sleep as soon as possible. So the tag’s rtc needs to wake up the uc on time for polling communication.
Also, the tag has 2 switches. At any time when sleeping between two polling events, if a tag have its state changed (switch state changed), it will wake up immediately (external interrupt) and establish communication.
Also, the reader will send every day at midnight a new firmware by broadcast. The tag may need to update its firmware. So the tag needs to jump to the bootloader and bootload the new application.
What I need now is to get all the mechanics done, I need the pieces of code or routines so I can embed it fast in my project. I don’t have time to make this even if I know there is a library with pieces of code available. I will code the communication layer and details of the application. What I need is to get those pieces of code (routines) fast, so I can start in the next days:
- Init code for the uc
- Set RTC time, read RTC time, Calibrate RTC
- Set all the timers (init) available in the chip to different (any) configuration so that I can then just re configure it to my needs.
- Wake up the uc with an alarm from the RTC at a precise time of the day from sleep mode
- Wake the device on pin change (external interrupt)
- Important note: When we put the uc to deep sleep mode, the uc can be waked up by either the RTC or the pin change (both can wake it up). So each time we put the uc in deeps sleep mode, it needs the 2 wake up source for the same sleep mode.
- Write/read to EEPROM: byte, word, block, float etc…
- Set the SPI (will be needed for the radio IC) as a Master
- Jump to the bootloader
- Set the 2 types of watch dog (there is one independent) with the reset timer instruction
- Turn off the 2 watch dog timers
- The necesseray routine to program block and pages in the bootloader. I will need to reprogram the main app once in a while.
- Jump back to the main application
- Need all of this tested and functional as fast as possible.
Please, I needs someone who already has some of this code and knows the ST uc really well. I need it fast so I can't wait for someone to lean the uc and then make the code.