Project

General

Profile

Revision 6ca98a3f

ID6ca98a3f3d28be42c8b1ef7713894d4c62c23180
Parent 92a430bc
Child f602b25b

Added by Thomas Mullins over 11 years ago

Eradicated use of signed chars in serial d'oh

View differences:

toolbox/serial.c
1
#include "serial.h"
1
#include <stdint.h>
2 2
#include <avr/io.h>
3 3
#include <avr/interrupt.h>
4
#include "serial.h"
4 5

  
5 6
static int rx_start = 0, rx_end = 0;
6
static char rx_buffer[RX_BUFFER_SIZE];
7
static uint8_t rx_buffer[RX_BUFFER_SIZE];
7 8

  
8 9
ISR(USART1_RX_vect) {
9
  char data = UDR1;
10
  uint8_t data = UDR1;
10 11
  int new_end = rx_end+1;
11 12
  if (new_end == RX_BUFFER_SIZE) {
12 13
    new_end = 0;
......
43 44
  } else {
44 45
    ret = rx_buffer[rx_start];
45 46
    rx_start++;
46
    if (rx_start == RX_BUFFER_SIZE)
47
    if (rx_start == RX_BUFFER_SIZE) {
47 48
      rx_start = 0;
49
    }
48 50
  }
49 51
  sei();
50 52
  return ret;
......
57 59
  sei();
58 60
}
59 61

  
60
char serial_read_blocking() {
62
uint8_t serial_read_blocking() {
61 63
  int c;
62 64
  do {
63 65
    c = serial_read();
......
65 67
  return c;
66 68
}
67 69

  
68
void serial_write(char* data, int length) {
70
void serial_write(uint8_t* data, int length) {
69 71
  int i;
70 72
  for (i = 0; i < length; i++) {
71 73
    while (!(UCSR1A & _BV(UDRE1)));

Also available in: Unified diff