sss7modem/software/sss7core/sss7.h

66 lines
1.2 KiB
C
Raw Normal View History

2016-10-27 18:28:01 +02:00
#ifndef _SSS7_H_
#define _SSS7_H_
#ifdef __cplusplus
extern "C" {
#endif
2016-11-21 12:48:29 +01:00
#include <stdint.h>
2016-10-27 18:28:01 +02:00
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-11-21 09:42:22 +01:00
const static uint16_t sss7_timeout = 50;
const static uint16_t sss7_timeout_increment = 1;
2016-10-27 18:28:01 +02:00
#define SSS7_PAYLOAD_SIZE 16
#define SSS7_RX_BUFFER_SIZE 2
2016-10-27 18:28:01 +02:00
2016-11-21 09:42:22 +01:00
2016-10-27 18:28:01 +02:00
extern volatile enum sss7State sss7_state;
extern volatile uint8_t sss7_tx_failed;
extern uint8_t sss7_rx_buffer_write;
extern uint8_t sss7_rx_buffer_read;
2016-10-27 18:28:01 +02:00
void sss7_process_rx(void);
void sss7_process_tx(void);
2016-11-21 09:42:22 +01:00
void sss7_process_ticks(uint16_t ticks);
2016-11-21 11:58:09 +01:00
extern void uart_put_byte(uint8_t byte);
extern uint8_t uart_get_byte(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) {
return sss7_rx_buffer_read != sss7_rx_buffer_write;
2016-10-27 18:28:01 +02:00
}
void sss7_get_received(uint8_t msg[SSS7_PAYLOAD_SIZE]);
#ifdef __cplusplus
}
#endif
2016-10-27 18:28:01 +02:00
#endif