generic: Create generic board infrastructure and move misc.h to it

Instead of creating a misc.h file in each board directory, create a
generic board directory and declare misc.h there.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2016-06-05 14:52:17 -04:00
parent ff789058df
commit 9971f999b3
11 changed files with 73 additions and 70 deletions

View file

@ -7,7 +7,7 @@ CFLAGS-y += -mmcu=$(CONFIG_MCU) -DF_CPU=$(CONFIG_CLOCK_FREQ)
LDFLAGS-y += -Wl,--relax
# Add avr source files
src-y += avr/main.c avr/timer.c avr/gpio.c avr/alloc.c
src-y += avr/main.c avr/timer.c avr/gpio.c avr/misc.c
src-$(CONFIG_AVR_WATCHDOG) += avr/watchdog.c
src-$(CONFIG_AVR_USBSERIAL) += avr/usbserial.c ../lib/pjrc_usb_serial/usb_serial.c
src-$(CONFIG_AVR_SERIAL) += avr/serial.c

View file

@ -1,4 +1,4 @@
// AVR allocation checking code.
// AVR miscellaneous platform code
//
// Copyright (C) 2016 Kevin O'Connor <kevin@koconnor.net>
//
@ -6,10 +6,22 @@
#include <avr/io.h> // AVR_STACK_POINTER_REG
#include <stdlib.h> // __malloc_heap_end
#include <util/crc16.h> // _crc_ccitt_update
#include "autoconf.h" // CONFIG_AVR_STACK_SIZE
#include "board/misc.h" // alloc_maxsize
#include "compiler.h" // ALIGN
#include "misc.h" // alloc_maxsize
// Optimized crc16_ccitt for the avr processor
uint16_t
crc16_ccitt(char *buf, uint8_t len)
{
uint16_t crc = 0xFFFF;
while (len--)
crc = _crc_ccitt_update(crc, *buf++);
return crc;
}
// Return the maximum allocation size that can succeed up to 'reqsize'
size_t
alloc_maxsize(size_t reqsize)
{

View file

@ -1,25 +0,0 @@
#ifndef __AVR_MISC_H
#define __AVR_MISC_H
#include <stdint.h>
#include <util/crc16.h>
// alloc.c
size_t alloc_maxsize(size_t reqsize);
// console.c
char *console_get_input(uint8_t *plen);
void console_pop_input(uint8_t len);
char *console_get_output(uint8_t len);
void console_push_output(uint8_t len);
// Optimized crc16_ccitt for the avr processor
#define HAVE_OPTIMIZED_CRC 1
static inline uint16_t _crc16_ccitt(char *buf, uint8_t len) {
uint16_t crc = 0xFFFF;
while (len--)
crc = _crc_ccitt_update(crc, *buf++);
return crc;
}
#endif // misc.h

View file

@ -7,9 +7,9 @@
#include <avr/interrupt.h> // USART0_RX_vect
#include <string.h> // memmove
#include "autoconf.h" // CONFIG_SERIAL_BAUD
#include "board/misc.h" // console_get_input
#include "sched.h" // DECL_INIT
#include "irq.h" // irq_save
#include "misc.h" // console_get_input
#define SERIAL_BUFFER_SIZE 96
static char receive_buf[SERIAL_BUFFER_SIZE];