/* * Author: Jake Goodwin * Date: 2023 * Description: AT-09 Bluetooth module library for AVR micro crontrollers. * Filename: avr_at-09.h */ #define __AVR_ATmega328P__ #include #include //############################# //PIN DEFINES AND CONSTS //############################# /* * AVR D0 --> AT-09 TX * AVR D1 --> AT-09 RX * AVR D2 --> AT-09 State */ #define FOSC 1000000UL #define BLE_BAUD 4800 #define BT_UBRR ((FOSC)/(BLE_BAUD*16UL)-1) #define TX_PIN PIND1 #define TX_DDR DDD1 #define RX_PIN PIND0 #define RX_DDR DDD0 #define AT_PORT PORTD //LED PIN for indicator and debug. #define LED_PIN PINC0 #define LED_DDR DDC0 //############################# //MACROS //############################# #define USE_U2X 0 #define STOP_BITS 2 #define DATA_BITS 8 #define CLOCK_POL 0 #define PARITY_BITS 0 #define PARITY_POS 0 #define CARRIAGE_RETURN 0 #define LINE_FEED 0 //############################# //FUNCTION PROTOTYPES //############################# static void led_blink(void); void init_usart0(void); void tx_usart0(unsigned char data); unsigned char rx_usart0(void); void serial0_write(unsigned char* buffer, uint8_t write_length); void serial0_read(unsigned char* buffer, uint8_t buf_length); void serial0_read_with_err_checking(unsigned char* buffer, uint8_t buf_length); void serial0_set_baud(uint8_t baud); void seiral0_enable_timeouts(uint8_t ms); void serial0_flush_rxbuf(void);