changed params for function defs to use unsigned chars

This commit is contained in:
Jake Goodwin 2023-01-14 12:03:16 -08:00
parent 3706cf27a1
commit 3554cb60f2
1 changed files with 9 additions and 7 deletions

View File

@ -16,8 +16,6 @@
//############################# //#############################
int main() { int main() {
unsigned char* tx_buffer[16];
unsigned char* rx_buffer[16];
led_blink(); led_blink();
led_blink(); led_blink();
@ -31,13 +29,15 @@ int main() {
sei(); sei();
uint8_t buf_len = 12; uint8_t buf_len = 12;
unsigned char data[12] = "HELLO WORLD\0"; //unsigned char data[12] = "snd 12chars\0";
unsigned char data[1] = "A";
while(1) { while(1) {
serial0_write(data, buf_len); serial0_write(data, buf_len);
_delay_ms(1000); _delay_ms(1000);
serial0_read(data, buf_len);
led_blink();
} }
return 0; return 0;
@ -126,7 +126,7 @@ void serial0_enable_timeouts(uint8_t ms) {
* Output: None * Output: None
* Description: * Description:
*/ */
void serial0_write(char* buffer, uint8_t write_length) { void serial0_write(unsigned char* buffer, uint8_t write_length) {
for(uint8_t i = 0; i < write_length; i++) { for(uint8_t i = 0; i < write_length; i++) {
tx_usart0(buffer[i]); tx_usart0(buffer[i]);
} }
@ -137,7 +137,9 @@ void serial0_write(char* buffer, uint8_t write_length) {
* Output: None * Output: None
* Description: Reads the serial data into a buffer of x length. * Description: Reads the serial data into a buffer of x length.
*/ */
void serial0_read(char* buffer, uint8_t buf_length) { void serial0_read(unsigned char* buffer, uint8_t buf_length) {
//clear buffer out?
buffer = 0;
for(uint8_t i = 0; i < buf_length; i++) { for(uint8_t i = 0; i < buf_length; i++) {
buffer[i] = rx_usart0(); buffer[i] = rx_usart0();
} }
@ -158,7 +160,7 @@ void serial0_read(char* buffer, uint8_t buf_length) {
* 6 --> 9600bps !!! 7% error rate * 6 --> 9600bps !!! 7% error rate
*/ */
void serial0_set_baud(uint8_t buad) { void serial0_set_baud(uint8_t baud) {
UBRR0H |= (uint8_t) (baud>>8); UBRR0H |= (uint8_t) (baud>>8);
UBRR0L |= (uint8_t) baud; UBRR0L |= (uint8_t) baud;
} }