AVR_ATMEGA_USART/avr_usart.h

66 lines
1.3 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-17 03:43:48 +00:00
#define __AVR_ATmega328P__
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
*/
2023-01-17 03:43:48 +00:00
#define FOSC 1000000UL
#define BLE_BAUD 4800
#define BT_UBRR ((FOSC)/(BLE_BAUD*16UL)-1)
2023-01-14 05:13:45 +00:00
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
//#############################
2023-01-17 03:43:48 +00:00
//MACROS
2023-01-14 05:13:45 +00:00
//#############################
2023-01-17 03:43:48 +00:00
#define USE_U2X 0
2023-01-14 05:13:45 +00:00
//#############################
//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
2023-01-14 21:45:21 +00:00