This is a RS485 class that uses the second UART and was tested on a Nucleo F030R8. A main demo program howto use the class is included. This class control the direction pin on the transceiver buffer automatically, and used transmit and receive interrupts. Ring buffers (256 bytes) are implemented on both transmission and reception. It assumes a ADM3485 'type' buffer where pins 2 ans 3 are connected and seen as direction. This test program could easily be adapted as base for other programs.
Diff: dlms_comms.h
- Revision:
- 3:29454cac7930
- Parent:
- 0:044dfba47660
- Child:
- 5:e00f46d18514
--- a/dlms_comms.h Tue Nov 11 16:16:34 2014 +0000 +++ b/dlms_comms.h Tue Nov 11 16:39:29 2014 +0000 @@ -20,7 +20,8 @@ Timer * parent_timer); bool get_dir485 (void); bool poll_rs485 (void); - UINT_64 ret_irq_count (void); + UINT_64 ret_tx_irq_count (void); + UINT_64 ret_rx_irq_count (void); private: void Rx_interrupt (void); void Tx_interrupt (void); @@ -29,7 +30,9 @@ Timer * timer; UINT_8 rx_buffer[256]; UINT_8 rx_head_ptr; - UINT_64 irq_count; UINT_8 rx_tail_ptr; + + UINT_64 tx_irq_count; + UINT_64 rx_irq_count; }; #endif