sss7modem/software/AVR8/sss7.h

50 lines
914 B
C
Raw Normal View History

2016-10-27 18:28:01 +02:00
#ifndef _SSS7_H_
#define _SSS7_H_
#include "stdint.h"
enum sss7State {
SSS7_IDLE,
SSS7_TX_HEADER,
SSS7_TX_PAYLOAD,
SSS7_TX_CRC,
SSS7_RX_HEADER,
SSS7_RX_PAYLOAD,
SSS7_RX_CRC
};
const static uint8_t SSS7_HEADER[] = {0xAA, 0xFE};
2016-10-27 18:28:01 +02:00
#define SSS7_PAYLOAD_SIZE 16
#define SSS7_RX_BUFFER_COUNT 2
extern volatile enum sss7State sss7_state;
extern volatile uint8_t sss7_tx_failed;
2016-10-27 18:28:01 +02:00
extern uint8_t sss7_rx_active_buffer;
extern uint8_t sss7_rx_oldest_buffer;
void sss7_process_rx(void);
void sss7_process_tx(void);
void sss7_init(void);
2016-10-27 18:28:01 +02:00
static inline uint8_t sss7_can_send(void) {
2016-10-27 18:28:01 +02:00
return sss7_state == SSS7_IDLE;
}
void sss7_send(uint8_t msg[SSS7_PAYLOAD_SIZE]);
static inline uint8_t sss7_send_failed(void) {
return sss7_tx_failed;
2016-10-27 18:28:01 +02:00
}
static inline uint8_t sss7_has_received(void) {
2016-10-27 18:28:01 +02:00
return sss7_rx_oldest_buffer < sss7_rx_active_buffer;
}
void sss7_get_received(uint8_t msg[SSS7_PAYLOAD_SIZE]);
#endif