/* * Author: Jake Goodwin * Date: 2023 * Description: Small library to communicate with the AT-09 bluetooth module. */ #include #include #include #include #include "avr_usart.h" //############################# //Globals //############################# int main() { led_blink(); led_blink(); led_blink(); _delay_ms(1000); init_usart0(); //enable interrupts sei(); unsigned char data[8] = "AT+BAUD3"; unsigned char data_cmd[2] = "AT"; uint8_t data_len = 8; uint8_t data_cmd_len = 2; while(1) { led_blink(); serial0_write(data, data_len); //_delay_ms(1000); _delay_ms(500); } return 0; } //############################# //FUNCTIONS //############################# /* * Input: None * Output: None * Description: init usart0 hardware in async mode */ void init_usart0(void) { //setup stuff for usart communications. UBRR0H |= (uint8_t) (BT_UBRR>>8); UBRR0L |= (uint8_t) BT_UBRR; //Enable recv and Transmit pins, overrides other uses. //IN the usart control and status register 0B UCSR0B = (1< 300bps * 103 --> 600bps * 51 --> 1200bps * 25 --> 2400bps * 12 --> 4800bps * 6 --> 9600bps !!! 7% error rate */ void serial0_set_baud(uint8_t baud) { UBRR0H |= (uint8_t) (baud>>8); UBRR0L |= (uint8_t) baud; } /* * Input: None * Output: None * Description: Toggles the pin for the LED indicator. */ static void led_blink(void) { //Set the DDR for output. DDRC |= (1<