Commit 53113514 authored by Jacob Vosmaer's avatar Jacob Vosmaer

Use 'error and pointers' style for uart_read

parent d994c429
......@@ -20,6 +20,6 @@ uint8_t midi_load(uint8_t *status, uint8_t *data1, uint8_t *data2);
// Fake uart functions to let midi.c compile
void uart_init(void) { }
uint16_t uart_read(void) { return 0; }
uint8_t uart_read(uint8_t *data) { return 0; }
#endif
......@@ -139,13 +139,13 @@ midi_load(uint8_t *status, uint8_t *data1, uint8_t *data2)
uint8_t
midi_read(uint8_t *status, uint8_t *data1, uint8_t *data2)
{
uint16_t uart_data = uart_read();
if (uart_data >> 8) {
// uart error
uint8_t uart_data;
if (uart_read(&uart_data)) {
return MIDI_READ_NO_DATA;
}
midi_parse(uart_data & 0xff);
midi_parse(uart_data);
return midi_load(status, data1, data2);
}
......@@ -39,16 +39,8 @@ uart_init(void)
sei();
}
#define UART_ERROR (1<<8)
uint16_t
uart_read(void)
uint8_t
uart_read(uint8_t *data)
{
uint8_t data;
if (buffer_pop(&data)) {
return UART_ERROR;
}
return data;
return buffer_pop(data);
}
#ifndef uart_h
#define uart_h
uint16_t uart_read(void);
uint8_t uart_read(uint8_t *data);
void uart_init(void);
#endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment