Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include "drivers/event.h"
- #include "drivers/task.h"
- #include "drivers/rf.h"
- #include "myTask.h"
- /*** local struct definitions ***/
- typedef struct sensorData{
- uint32_t address;
- uint32_t totalPacketsReceived;
- }
- // Standard format of data from sensors [sourceAddress][data]
- typedef struct sensorPacket{
- uint32_t sourceAddress;
- uint16_t data;
- }
- /*** Global variable declarations ***/
- static sensorPacket latestPacket; // A global variable to store the more recently received packet
- /************************************/
- /*** Initialise our task and event ***/
- void myTask_init(void){
- // Create a new event and event handle
- event_create(&myEvent)
- myEventHandle = event_handle(&myEvent);
- // Create a new task which will start immediately at 'myTaskFunction()'
- task_create(&myTask, myTaskFunction);
- }
- /*** This is our main task function ***/
- static void myTask_function(void){
- // ...
- sensorData sensorList[8];
- while(1){
- // ...
- uint32_t events = event_pend(myEventHandle);
- if(events == EVENT_NEW_STANDARD_DATA_PACKET){}
- // Create a function to update the sensorList table with the new packet receieved count
- // - Assume there is already data from that sensor in the table and it can be identified by the 'address' field
- //
- }
- if(events == EVENT_ADD_NEW_SENSOR){
- // ...
- }
- }
- }
- // This callback occurs when we receive wireless data
- void packetReceivedCallback(uint32_t address, uint16_t data){
- // Copy the packet data into a global variable
- latestPacket.sourceAddress = address;
- latestPacket.data = data;
- // ...
- event_post(&myEventHandle, EVENT_NEW_STANDARD_DATA_PACKET)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement