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.
Fork of d7a_1x by
Diff: include/d7a_com.h
- Revision:
- 24:a8433b091764
- Child:
- 25:aac250164497
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/include/d7a_com.h Wed Mar 23 16:00:53 2016 +0000
@@ -0,0 +1,69 @@
+#ifndef _D7A_COM_H_
+#define _D7A_COM_H_
+
+#include "mbed.h"
+#include "rtos.h"
+#include "defs.h"
+
+typedef struct {
+ PinName tx;
+ PinName rx;
+ PinName rts;
+ PinName cts;
+ uint16_t rx_buffer_size;
+} d7a_com_config_t;
+
+TYPEDEF_STRUCT_PACKED {
+ uint8_t len;
+ uint8_t id;
+ uint8_t data[1];
+} d7a_com_pkt_t;
+
+
+
+typedef struct
+{
+ DigitalOut* rts;
+ InterruptIn* cts;
+
+ // RX buffer address
+ uint8_t* rx_buffer;
+ // RX buffer size
+ uint16_t rx_buffer_size;
+ // Write index in RX buffer
+ volatile uint16_t write_idx;
+ // Read index in RX buffer
+ uint16_t read_idx;
+ // Number of bytes available in RX buffer
+ volatile uint16_t data_available;
+ // Port TX sequence number
+ uint8_t tx_seq;
+ // Port RX sequence number
+ uint8_t rx_seq;
+ // Response to command maximum time
+ uint32_t timeout;
+
+ // Packet reception queue
+ Queue<d7a_com_pkt_t, 32> pkt_queue;
+
+ // Waiting for data available in RX buffer
+ Semaphore* data_parsing;
+ // CTS management
+ Semaphore* cts_int;
+
+ // Data treatment threads
+ Thread* parse_thread;
+ Serial* serial;
+
+ uint32_t rx_pkt_count;
+ uint32_t rx_byte_count;
+ uint32_t tx_pkt_count;
+ uint32_t tx_byte_count;
+} d7a_com_ctx_t;
+
+void d7a_com_open( const d7a_com_config_t* config );
+void d7a_com_close();
+void d7a_com_send_msg( kal_com_tx_msg_t* msg );
+d7a_com_pkt_t* d7a_com_wait_pkt( uint32_t millisec = osWaitForever );
+
+#endif // _D7A_COM_H_
\ No newline at end of file
