WizziLab's serial protocol library
Dependents: modem_ref_helper_for_v5_3_217 modem_ref_helper
Diff: WizziCom.h
- Revision:
- 8:42e00820df36
- Parent:
- 5:a06d239f3b3e
- Child:
- 9:0140247bab90
diff -r 45fe755f52bc -r 42e00820df36 WizziCom.h --- a/WizziCom.h Thu Aug 01 14:53:04 2019 +0000 +++ b/WizziCom.h Tue Aug 20 13:48:15 2019 +0000 @@ -6,6 +6,8 @@ #include "CBuffer.h" #include "WizziDebug.h" +// message header length in byte +#define KAL_COM_HEADER_LEN 5 typedef enum { @@ -138,7 +140,6 @@ private: volatile uint8_t _state; wizzi_com_rx_msg_t _msg; - uint16_t _skipped_bytes; uint8_t _tx_seq; uint8_t _rx_seq; @@ -146,9 +147,11 @@ InterruptIn* _irq_in; RawSerial* _serial; - CBuffer<uint8_t, 512> _rx_buf; + uint8_t _rx_header[KAL_COM_HEADER_LEN]; + uint8_t _rx_body[255]; - Semaphore _data_parsing; + Semaphore _tx_done; + Semaphore _rx_done; Semaphore _irq_in_int; Thread _rx_thread; Thread _tx_thread; @@ -158,15 +161,17 @@ Callback<void(WizziCom*, WizziComPacket_t*)> _callback[WIZZICOM_PKT_QTY+1]; - void _rx_isr(); + void _get_header(uint8_t length); + void _get_body(uint8_t length); + void _tx_done_isr(int event); + void _rx_done_isr(int event); void _irq_in_isr(); void _send_raw(uint8_t* data, uint32_t len); void _sys_xack(void); wizzi_com_tx_buf_t* _new_msg(wizzi_com_tx_msg_t* msg); void _post_msg(wizzi_com_tx_msg_t* msg); void _new_pkt(WizziComPacket_t* pkt); - void _parse_packet_header(void); - void _parse_packet_body(void); + void _parse_packet(void); void _thread_rx(void); void _thread_tx(void); void _thread_callback(void);