https://www.st.com/en/ecosystems/x-nucleo-plm01a1.html MBED driver for the ST7580 IC.

Committer:
Arthrik
Date:
Mon Apr 15 06:41:00 2019 +0000
Revision:
0:e88514a784bb
Child:
1:edbcde816013
Initial commit. rx_interrupt not stable yet

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Arthrik 0:e88514a784bb 1 #ifndef ST7580_H
Arthrik 0:e88514a784bb 2 #define ST7580_H
Arthrik 0:e88514a784bb 3
Arthrik 0:e88514a784bb 4 #include "mbed.h"
Arthrik 0:e88514a784bb 5 #include "ST7580_codes.h"
Arthrik 0:e88514a784bb 6 #include <stdio.h>
Arthrik 0:e88514a784bb 7 #include <string.h>
Arthrik 0:e88514a784bb 8
Arthrik 0:e88514a784bb 9 #define ST7580_TSR 100
Arthrik 0:e88514a784bb 10
Arthrik 0:e88514a784bb 11 /*! \class ST7580
Arthrik 0:e88514a784bb 12 * \brief ST7580 driver
Arthrik 0:e88514a784bb 13 *
Arthrik 0:e88514a784bb 14 * here is a minimal example:
Arthrik 0:e88514a784bb 15 *
Arthrik 0:e88514a784bb 16 * ST7580 shield(D8, D2, D13, D7);
Arthrik 0:e88514a784bb 17 * shield.init();
Arthrik 0:e88514a784bb 18 * wait(1);
Arthrik 0:e88514a784bb 19 * while(1) {
Arthrik 0:e88514a784bb 20 * shield.send_frame("Hello world!");
Arthrik 0:e88514a784bb 21 * }
Arthrik 0:e88514a784bb 22 */
Arthrik 0:e88514a784bb 23 class ST7580
Arthrik 0:e88514a784bb 24 {
Arthrik 0:e88514a784bb 25 public:
Arthrik 0:e88514a784bb 26 /*!
Arthrik 0:e88514a784bb 27 * \brief Constructor
Arthrik 0:e88514a784bb 28 *
Arthrik 0:e88514a784bb 29 * ST7580 Constructor
Arthrik 0:e88514a784bb 30 *
Arthrik 0:e88514a784bb 31 * \param tx : mbed UART transmission pin
Arthrik 0:e88514a784bb 32 * \param rx : mbed UART reception pin
Arthrik 0:e88514a784bb 33 * \param t_req : ST7580 transmit request pin
Arthrik 0:e88514a784bb 34 * \param reset : ST7580 reset pin
Arthrik 0:e88514a784bb 35 * \param usr_callback : callback to the user app with reception buffer, and payload length as arguments
Arthrik 0:e88514a784bb 36 */
Arthrik 0:e88514a784bb 37 ST7580(PinName tx, PinName rx, PinName t_req, PinName reset, void (*usr_callback)(unsigned char *, int));
Arthrik 0:e88514a784bb 38
Arthrik 0:e88514a784bb 39 /*!
Arthrik 0:e88514a784bb 40 * \brief Initialises the pins and UART needed for the driver
Arthrik 0:e88514a784bb 41 *
Arthrik 0:e88514a784bb 42 * Creates the UART handle and needed pins
Arthrik 0:e88514a784bb 43 */
Arthrik 0:e88514a784bb 44 void init();
Arthrik 0:e88514a784bb 45 void send_frame(unsigned char *msg, int msg_length);
Arthrik 0:e88514a784bb 46 //void receive_frame();
Arthrik 0:e88514a784bb 47
Arthrik 0:e88514a784bb 48 private:
Arthrik 0:e88514a784bb 49 void wait_status();
Arthrik 0:e88514a784bb 50 void wait_reset();
Arthrik 0:e88514a784bb 51 void reset_reception_buffer();
Arthrik 0:e88514a784bb 52 void rx_complete();
Arthrik 0:e88514a784bb 53 void rx_callback();
Arthrik 0:e88514a784bb 54
Arthrik 0:e88514a784bb 55 void (*_usr_callback)(unsigned char *, int);
Arthrik 0:e88514a784bb 56 volatile unsigned char _rx_char;
Arthrik 0:e88514a784bb 57 volatile unsigned char _rcv_data[512];
Arthrik 0:e88514a784bb 58 volatile int _rcv_data_idx;
Arthrik 0:e88514a784bb 59 volatile int _rcv_data_offset;
Arthrik 0:e88514a784bb 60 volatile int _step;
Arthrik 0:e88514a784bb 61
Arthrik 0:e88514a784bb 62 DigitalOut *_plm_t_req;
Arthrik 0:e88514a784bb 63 DigitalOut *_plm_reset;
Arthrik 0:e88514a784bb 64 RawSerial *_plm_uart;
Arthrik 0:e88514a784bb 65 };
Arthrik 0:e88514a784bb 66
Arthrik 0:e88514a784bb 67 #endif