Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: xtoff RF24Network mbed
Fork of RF24Network_Send by
Verzender.h@9:6d8c0b946259, 2018-03-09 (annotated)
- Committer:
- pietor
- Date:
- Fri Mar 09 09:58:02 2018 +0000
- Revision:
- 9:6d8c0b946259
- Parent:
- 8:62b4607c44ca
- Child:
- 10:875812a04307
Werkend 9/03
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
pietor | 5:e6067799a414 | 1 | #ifndef Verzender_h |
pietor | 5:e6067799a414 | 2 | #define Verzender_h |
pietor | 5:e6067799a414 | 3 | #include "mbed.h" |
pietor | 5:e6067799a414 | 4 | #include <RF24Network.h> |
pietor | 5:e6067799a414 | 5 | #include <RF24.h> |
pietor | 5:e6067799a414 | 6 | |
pietor | 5:e6067799a414 | 7 | #define nrf_CE p9 |
pietor | 5:e6067799a414 | 8 | #define nrf_CSN p8 |
pietor | 5:e6067799a414 | 9 | #define spi_SCK p7 |
pietor | 5:e6067799a414 | 10 | #define spi_MOSI p5 |
pietor | 5:e6067799a414 | 11 | #define spi_MISO p6 |
pietor | 5:e6067799a414 | 12 | |
pietor | 9:6d8c0b946259 | 13 | |
pietor | 9:6d8c0b946259 | 14 | //Identificatie verzender/ontvanger |
pietor | 5:e6067799a414 | 15 | const uint16_t this_node = 01; |
pietor | 5:e6067799a414 | 16 | const uint16_t other_node = 00; |
pietor | 8:62b4607c44ca | 17 | |
pietor | 5:e6067799a414 | 18 | struct payload_t { |
pietor | 5:e6067799a414 | 19 | bool reedsensor; |
pietor | 7:cbdbaf825b4a | 20 | float milligram; |
pietor | 5:e6067799a414 | 21 | }; |
pietor | 5:e6067799a414 | 22 | |
pietor | 6:03ba3e18ced2 | 23 | enum State {State_init, |
pietor | 6:03ba3e18ced2 | 24 | State_tare, |
pietor | 6:03ba3e18ced2 | 25 | State_position, |
pietor | 6:03ba3e18ced2 | 26 | State_read, |
pietor | 6:03ba3e18ced2 | 27 | State_receive |
pietor | 6:03ba3e18ced2 | 28 | }; |
pietor | 6:03ba3e18ced2 | 29 | |
pietor | 6:03ba3e18ced2 | 30 | struct state_Packet { |
pietor | 6:03ba3e18ced2 | 31 | State setstate; |
pietor | 6:03ba3e18ced2 | 32 | }; |
pietor | 6:03ba3e18ced2 | 33 | |
pietor | 6:03ba3e18ced2 | 34 | |
pietor | 5:e6067799a414 | 35 | class Verzender |
pietor | 5:e6067799a414 | 36 | { |
pietor | 5:e6067799a414 | 37 | private: |
pietor | 5:e6067799a414 | 38 | |
pietor | 5:e6067799a414 | 39 | |
pietor | 5:e6067799a414 | 40 | public: |
pietor | 5:e6067799a414 | 41 | Verzender(); |
pietor | 9:6d8c0b946259 | 42 | |
pietor | 9:6d8c0b946259 | 43 | /** |
pietor | 9:6d8c0b946259 | 44 | Update to receive a message available for this node |
pietor | 9:6d8c0b946259 | 45 | */ |
pietor | 5:e6067799a414 | 46 | void update(); |
pietor | 9:6d8c0b946259 | 47 | |
pietor | 9:6d8c0b946259 | 48 | |
pietor | 9:6d8c0b946259 | 49 | /** |
pietor | 9:6d8c0b946259 | 50 | Send a message to the receiver |
pietor | 9:6d8c0b946259 | 51 | |
pietor | 9:6d8c0b946259 | 52 | @param message of type payload_t |
pietor | 9:6d8c0b946259 | 53 | */ |
pietor | 5:e6067799a414 | 54 | bool write(payload_t message); |
pietor | 9:6d8c0b946259 | 55 | |
pietor | 9:6d8c0b946259 | 56 | |
pietor | 9:6d8c0b946259 | 57 | /** |
pietor | 9:6d8c0b946259 | 58 | Test whether there is a message available for this node |
pietor | 9:6d8c0b946259 | 59 | */ |
pietor | 6:03ba3e18ced2 | 60 | bool available(); |
pietor | 9:6d8c0b946259 | 61 | |
pietor | 9:6d8c0b946259 | 62 | |
pietor | 9:6d8c0b946259 | 63 | /** |
pietor | 9:6d8c0b946259 | 64 | Read a message to the receiver |
pietor | 9:6d8c0b946259 | 65 | |
pietor | 9:6d8c0b946259 | 66 | @return message of type state_packet |
pietor | 9:6d8c0b946259 | 67 | */ |
pietor | 6:03ba3e18ced2 | 68 | state_Packet read(); |
pietor | 5:e6067799a414 | 69 | }; |
pietor | 5:e6067799a414 | 70 | |
pietor | 5:e6067799a414 | 71 | #endif |
pietor | 5:e6067799a414 | 72 | |
pietor | 5:e6067799a414 | 73 | |
pietor | 5:e6067799a414 | 74 | |
pietor | 5:e6067799a414 | 75 | |
pietor | 5:e6067799a414 | 76 |