AVR_ATMEGA_USART/avr_usart.h

59 lines
1.2 KiB
C
Raw Normal View History

2023-01-14 05:13:45 +00:00
/*
* Author: Jake Goodwin
* Date: 2023
* Description: AT-09 Bluetooth module library for AVR micro crontrollers.
* Filename: avr_at-09.h
*/
2023-01-14 20:02:20 +00:00
#include <inttypes.h>
2023-01-14 20:59:34 +00:00
#include <stdint.h>
2023-01-14 05:13:45 +00:00
//#############################
//PIN DEFINES AND CONSTS
//#############################
/*
* AVR D0 --> AT-09 TX
* AVR D1 --> AT-09 RX
* AVR D2 --> AT-09 State
*/
#define FOSC 8000000
#define BLE_BAUD 9600
2023-01-14 05:13:45 +00:00
#define BT_UBRR FOSC/16/BLE_BAUD - 1
2023-01-14 21:26:29 +00:00
#define TX_PIN PIND1
#define TX_DDR DDD1
2023-01-14 05:13:45 +00:00
2023-01-14 21:26:29 +00:00
#define RX_PIN PIND0
#define RX_DDR DDD0
2023-01-14 05:13:45 +00:00
#define AT_PORT PORTD
//LED PIN for indicator and debug.
#define LED_PIN PINC0
#define LED_DDR DDC0
//#############################
//TYPES
//#############################
//#############################
//FUNCTION PROTOTYPES
//#############################
static void led_blink(void);
void init_usart0(void);
void tx_usart0(unsigned char data);
unsigned char rx_usart0(void);
2023-01-14 20:02:20 +00:00
void serial0_write(unsigned char* buffer, uint8_t write_length);
void serial0_read(unsigned char* buffer, uint8_t buf_length);
2023-01-14 20:59:34 +00:00
void serial0_read_with_err_checking(unsigned char* buffer, uint8_t buf_length);
2023-01-14 19:36:28 +00:00
void serial0_set_baud(uint8_t baud);
void seiral0_enable_timeouts(uint8_t ms);
2023-01-14 20:59:34 +00:00
void serial0_flush_rxbuf(void);
2023-01-14 19:36:28 +00:00