diff --git a/source/firmware/arch/stm32f4xx/__dep/delay.c b/source/firmware/arch/stm32f4xx/__dep/delay.c deleted file mode 100755 index 5821f39..0000000 --- a/source/firmware/arch/stm32f4xx/__dep/delay.c +++ /dev/null @@ -1,62 +0,0 @@ -/* - * delay.c - * - * Created on: Feb 16, 2012 - * Author: tkl - */ - -#include -#include - -#ifdef BOARD_STM32_H103 -#include "system_stm32f10x.h" -#endif -#ifdef BOARD_STM32F4_DISCOVERY -#include "system_stm32f4xx.h" -#endif - -#include "delay.h" - -#define CORRECT 30 // Korrekturfaktor (stm32-h103 - oszi ermittelt (startup code ???) - -//----------------------------------------------------------------------------- -static uint32_t get_div_us(void) { - uint32_t us = 1e6; - uint32_t ret = SystemCoreClock; - ret /= us; - if(ret == 0) { - ret += 1; - } - return ret; -} - -//----------------------------------------------------------------------------- -static uint32_t get_div_ms(void) { - uint32_t ms = 1e3; - uint32_t ret = SystemCoreClock; - ret /= ms; - if(ret == 0) { - ret += 1; - } - return ret; -} - -//----------------------------------------------------------------------------- -void delay_us(uint32_t delay_us) { - uint32_t div = get_div_us(); - volatile uint64_t count = delay_us * div / CORRECT; - - while(count > 0) { - count--; - } -} - -//----------------------------------------------------------------------------- -void delay_ms(uint32_t delay_ms) { - uint32_t div = get_div_ms(); - volatile uint64_t count = delay_ms * div / CORRECT; - - while(count > 0) { - count--; - } -} diff --git a/source/firmware/arch/stm32f4xx/__dep/delay.h b/source/firmware/arch/stm32f4xx/__dep/delay.h deleted file mode 100755 index da1b621..0000000 --- a/source/firmware/arch/stm32f4xx/__dep/delay.h +++ /dev/null @@ -1,21 +0,0 @@ -/*! \file delay.h - * \author tkl - * \date Feb 16, 2012 - * \brief Header file of the architecture independent delay tool. - */ -#ifndef DELAY_H_ -#define DELAY_H_ - -//----------------------------------------------------------------------------- -/*! \brief Loop for microseconds. - * \param delay_us microseconds to loop. - */ -void delay_us(uint32_t delay_us); - -//----------------------------------------------------------------------------- -/*! \brief Loop for milliseconds. - * \param delay_ms milliseconds to loop. - */ -void delay_ms(uint32_t delay_ms); - -#endif /* DELAY_H_ */ diff --git a/source/firmware/arch/stm32f4xx/board/stm32f4-discovery/bsp_stm32f4-discovery.h b/source/firmware/arch/stm32f4xx/board/stm32f4-discovery/include/bsp_stm32f4-discovery.h similarity index 100% rename from source/firmware/arch/stm32f4xx/board/stm32f4-discovery/bsp_stm32f4-discovery.h rename to source/firmware/arch/stm32f4xx/board/stm32f4-discovery/include/bsp_stm32f4-discovery.h diff --git a/source/firmware/arch/stm32f4xx/driver/timer/stm32_sys_tick.h b/source/firmware/arch/stm32f4xx/driver/include/stm32_sys_tick.h similarity index 100% rename from source/firmware/arch/stm32f4xx/driver/timer/stm32_sys_tick.h rename to source/firmware/arch/stm32f4xx/driver/include/stm32_sys_tick.h diff --git a/source/firmware/arch/stm32f4xx/driver/gpio/stm32f4_gpio.h b/source/firmware/arch/stm32f4xx/driver/include/stm32f4_gpio.h similarity index 100% rename from source/firmware/arch/stm32f4xx/driver/gpio/stm32f4_gpio.h rename to source/firmware/arch/stm32f4xx/driver/include/stm32f4_gpio.h diff --git a/source/firmware/arch/stm32f4xx/driver/uart/stm32f4_uart.h b/source/firmware/arch/stm32f4xx/driver/include/stm32f4_uart.h similarity index 100% rename from source/firmware/arch/stm32f4xx/driver/uart/stm32f4_uart.h rename to source/firmware/arch/stm32f4xx/driver/include/stm32f4_uart.h diff --git a/source/firmware/arch/stm32f4xx/driver/timer/stm32_sys_tick.c b/source/firmware/arch/stm32f4xx/driver/stm32_sys_tick.c similarity index 100% rename from source/firmware/arch/stm32f4xx/driver/timer/stm32_sys_tick.c rename to source/firmware/arch/stm32f4xx/driver/stm32_sys_tick.c diff --git a/source/firmware/arch/stm32f4xx/driver/gpio/stm32f4_gpio.c b/source/firmware/arch/stm32f4xx/driver/stm32f4_gpio.c similarity index 100% rename from source/firmware/arch/stm32f4xx/driver/gpio/stm32f4_gpio.c rename to source/firmware/arch/stm32f4xx/driver/stm32f4_gpio.c diff --git a/source/firmware/arch/stm32f4xx/driver/uart/stm32f4_uart.c b/source/firmware/arch/stm32f4xx/driver/stm32f4_uart.c similarity index 100% rename from source/firmware/arch/stm32f4xx/driver/uart/stm32f4_uart.c rename to source/firmware/arch/stm32f4xx/driver/stm32f4_uart.c diff --git a/source/firmware/arch/stm32f4xx/stm32f4xx_ctx.h b/source/firmware/arch/stm32f4xx/include/stm32f4xx_ctx.h similarity index 100% rename from source/firmware/arch/stm32f4xx/stm32f4xx_ctx.h rename to source/firmware/arch/stm32f4xx/include/stm32f4xx_ctx.h diff --git a/source/firmware/arch/stm32f4xx/stm32f4xx_irq.h b/source/firmware/arch/stm32f4xx/include/stm32f4xx_irq.h similarity index 100% rename from source/firmware/arch/stm32f4xx/stm32f4xx_irq.h rename to source/firmware/arch/stm32f4xx/include/stm32f4xx_irq.h diff --git a/source/firmware/arch/stm32f4xx/stm32f4xx_isr.h b/source/firmware/arch/stm32f4xx/include/stm32f4xx_isr.h similarity index 100% rename from source/firmware/arch/stm32f4xx/stm32f4xx_isr.h rename to source/firmware/arch/stm32f4xx/include/stm32f4xx_isr.h diff --git a/source/firmware/arch/stm32f4xx/stm32f4xx_low_power.h b/source/firmware/arch/stm32f4xx/include/stm32f4xx_low_power.h similarity index 100% rename from source/firmware/arch/stm32f4xx/stm32f4xx_low_power.h rename to source/firmware/arch/stm32f4xx/include/stm32f4xx_low_power.h diff --git a/source/firmware/arch/stm32f4xx/stm32f4xx_stack.h b/source/firmware/arch/stm32f4xx/include/stm32f4xx_stack.h similarity index 100% rename from source/firmware/arch/stm32f4xx/stm32f4xx_stack.h rename to source/firmware/arch/stm32f4xx/include/stm32f4xx_stack.h diff --git a/source/firmware/kernel/ascii_font.h b/source/firmware/kernel/ascii_font.h deleted file mode 100644 index 68d3915..0000000 --- a/source/firmware/kernel/ascii_font.h +++ /dev/null @@ -1,280 +0,0 @@ -/* - * ascii_font.h - * - * Created on: Jan 15, 2016 - * Author: tkl - */ - -#ifndef ASCII_FONT_H_ -#define ASCII_FONT_H_ - -#include "font.h" - -static const unsigned char ascii_font[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, - 0x3E, 0x5B, 0x4F, 0x5B, 0x3E, - 0x3E, 0x6B, 0x4F, 0x6B, 0x3E, - 0x1C, 0x3E, 0x7C, 0x3E, 0x1C, - 0x18, 0x3C, 0x7E, 0x3C, 0x18, - 0x1C, 0x57, 0x7D, 0x57, 0x1C, - 0x1C, 0x5E, 0x7F, 0x5E, 0x1C, - 0x00, 0x18, 0x3C, 0x18, 0x00, - 0xFF, 0xE7, 0xC3, 0xE7, 0xFF, - 0x00, 0x18, 0x24, 0x18, 0x00, - 0xFF, 0xE7, 0xDB, 0xE7, 0xFF, - 0x30, 0x48, 0x3A, 0x06, 0x0E, - 0x26, 0x29, 0x79, 0x29, 0x26, - 0x40, 0x7F, 0x05, 0x05, 0x07, - 0x40, 0x7F, 0x05, 0x25, 0x3F, - 0x5A, 0x3C, 0xE7, 0x3C, 0x5A, - 0x7F, 0x3E, 0x1C, 0x1C, 0x08, - 0x08, 0x1C, 0x1C, 0x3E, 0x7F, - 0x14, 0x22, 0x7F, 0x22, 0x14, - 0x5F, 0x5F, 0x00, 0x5F, 0x5F, - 0x06, 0x09, 0x7F, 0x01, 0x7F, - 0x00, 0x66, 0x89, 0x95, 0x6A, - 0x60, 0x60, 0x60, 0x60, 0x60, - 0x94, 0xA2, 0xFF, 0xA2, 0x94, - 0x08, 0x04, 0x7E, 0x04, 0x08, - 0x10, 0x20, 0x7E, 0x20, 0x10, - 0x08, 0x08, 0x2A, 0x1C, 0x08, - 0x08, 0x1C, 0x2A, 0x08, 0x08, - 0x1E, 0x10, 0x10, 0x10, 0x10, - 0x0C, 0x1E, 0x0C, 0x1E, 0x0C, - 0x30, 0x38, 0x3E, 0x38, 0x30, - 0x06, 0x0E, 0x3E, 0x0E, 0x06, - 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x5F, 0x00, 0x00, - 0x00, 0x07, 0x00, 0x07, 0x00, - 0x14, 0x7F, 0x14, 0x7F, 0x14, - 0x24, 0x2A, 0x7F, 0x2A, 0x12, - 0x23, 0x13, 0x08, 0x64, 0x62, - 0x36, 0x49, 0x56, 0x20, 0x50, - 0x00, 0x08, 0x07, 0x03, 0x00, - 0x00, 0x1C, 0x22, 0x41, 0x00, - 0x00, 0x41, 0x22, 0x1C, 0x00, - 0x2A, 0x1C, 0x7F, 0x1C, 0x2A, - 0x08, 0x08, 0x3E, 0x08, 0x08, - 0x00, 0x80, 0x70, 0x30, 0x00, - 0x08, 0x08, 0x08, 0x08, 0x08, - 0x00, 0x00, 0x60, 0x60, 0x00, - 0x20, 0x10, 0x08, 0x04, 0x02, - 0x3E, 0x51, 0x49, 0x45, 0x3E, - 0x00, 0x42, 0x7F, 0x40, 0x00, - 0x72, 0x49, 0x49, 0x49, 0x46, - 0x21, 0x41, 0x49, 0x4D, 0x33, - 0x18, 0x14, 0x12, 0x7F, 0x10, - 0x27, 0x45, 0x45, 0x45, 0x39, - 0x3C, 0x4A, 0x49, 0x49, 0x31, - 0x41, 0x21, 0x11, 0x09, 0x07, - 0x36, 0x49, 0x49, 0x49, 0x36, - 0x46, 0x49, 0x49, 0x29, 0x1E, - 0x00, 0x00, 0x14, 0x00, 0x00, - 0x00, 0x40, 0x34, 0x00, 0x00, - 0x00, 0x08, 0x14, 0x22, 0x41, - 0x14, 0x14, 0x14, 0x14, 0x14, - 0x00, 0x41, 0x22, 0x14, 0x08, - 0x02, 0x01, 0x59, 0x09, 0x06, - 0x3E, 0x41, 0x5D, 0x59, 0x4E, - 0x7C, 0x12, 0x11, 0x12, 0x7C, - 0x7F, 0x49, 0x49, 0x49, 0x36, - 0x3E, 0x41, 0x41, 0x41, 0x22, - 0x7F, 0x41, 0x41, 0x41, 0x3E, - 0x7F, 0x49, 0x49, 0x49, 0x41, - 0x7F, 0x09, 0x09, 0x09, 0x01, - 0x3E, 0x41, 0x41, 0x51, 0x73, - 0x7F, 0x08, 0x08, 0x08, 0x7F, - 0x00, 0x41, 0x7F, 0x41, 0x00, - 0x20, 0x40, 0x41, 0x3F, 0x01, - 0x7F, 0x08, 0x14, 0x22, 0x41, - 0x7F, 0x40, 0x40, 0x40, 0x40, - 0x7F, 0x02, 0x1C, 0x02, 0x7F, - 0x7F, 0x04, 0x08, 0x10, 0x7F, - 0x3E, 0x41, 0x41, 0x41, 0x3E, - 0x7F, 0x09, 0x09, 0x09, 0x06, - 0x3E, 0x41, 0x51, 0x21, 0x5E, - 0x7F, 0x09, 0x19, 0x29, 0x46, - 0x26, 0x49, 0x49, 0x49, 0x32, - 0x03, 0x01, 0x7F, 0x01, 0x03, - 0x3F, 0x40, 0x40, 0x40, 0x3F, - 0x1F, 0x20, 0x40, 0x20, 0x1F, - 0x3F, 0x40, 0x38, 0x40, 0x3F, - 0x63, 0x14, 0x08, 0x14, 0x63, - 0x03, 0x04, 0x78, 0x04, 0x03, - 0x61, 0x59, 0x49, 0x4D, 0x43, - 0x00, 0x7F, 0x41, 0x41, 0x41, - 0x02, 0x04, 0x08, 0x10, 0x20, - 0x00, 0x41, 0x41, 0x41, 0x7F, - 0x04, 0x02, 0x01, 0x02, 0x04, - 0x40, 0x40, 0x40, 0x40, 0x40, - 0x00, 0x03, 0x07, 0x08, 0x00, - 0x20, 0x54, 0x54, 0x78, 0x40, - 0x7F, 0x28, 0x44, 0x44, 0x38, - 0x38, 0x44, 0x44, 0x44, 0x28, - 0x38, 0x44, 0x44, 0x28, 0x7F, - 0x38, 0x54, 0x54, 0x54, 0x18, - 0x00, 0x08, 0x7E, 0x09, 0x02, - 0x18, 0xA4, 0xA4, 0x9C, 0x78, - 0x7F, 0x08, 0x04, 0x04, 0x78, - 0x00, 0x44, 0x7D, 0x40, 0x00, - 0x20, 0x40, 0x40, 0x3D, 0x00, - 0x7F, 0x10, 0x28, 0x44, 0x00, - 0x00, 0x41, 0x7F, 0x40, 0x00, - 0x7C, 0x04, 0x78, 0x04, 0x78, - 0x7C, 0x08, 0x04, 0x04, 0x78, - 0x38, 0x44, 0x44, 0x44, 0x38, - 0xFC, 0x18, 0x24, 0x24, 0x18, - 0x18, 0x24, 0x24, 0x18, 0xFC, - 0x7C, 0x08, 0x04, 0x04, 0x08, - 0x48, 0x54, 0x54, 0x54, 0x24, - 0x04, 0x04, 0x3F, 0x44, 0x24, - 0x3C, 0x40, 0x40, 0x20, 0x7C, - 0x1C, 0x20, 0x40, 0x20, 0x1C, - 0x3C, 0x40, 0x30, 0x40, 0x3C, - 0x44, 0x28, 0x10, 0x28, 0x44, - 0x4C, 0x90, 0x90, 0x90, 0x7C, - 0x44, 0x64, 0x54, 0x4C, 0x44, - 0x00, 0x08, 0x36, 0x41, 0x00, - 0x00, 0x00, 0x77, 0x00, 0x00, - 0x00, 0x41, 0x36, 0x08, 0x00, - 0x02, 0x01, 0x02, 0x04, 0x02, - 0x3C, 0x26, 0x23, 0x26, 0x3C, - 0x1E, 0xA1, 0xA1, 0x61, 0x12, - 0x3A, 0x40, 0x40, 0x20, 0x7A, - 0x38, 0x54, 0x54, 0x55, 0x59, - 0x21, 0x55, 0x55, 0x79, 0x41, - 0x22, 0x54, 0x54, 0x78, 0x42, // a-umlaut - 0x21, 0x55, 0x54, 0x78, 0x40, - 0x20, 0x54, 0x55, 0x79, 0x40, - 0x0C, 0x1E, 0x52, 0x72, 0x12, - 0x39, 0x55, 0x55, 0x55, 0x59, - 0x39, 0x54, 0x54, 0x54, 0x59, - 0x39, 0x55, 0x54, 0x54, 0x58, - 0x00, 0x00, 0x45, 0x7C, 0x41, - 0x00, 0x02, 0x45, 0x7D, 0x42, - 0x00, 0x01, 0x45, 0x7C, 0x40, - 0x7D, 0x12, 0x11, 0x12, 0x7D, // A-umlaut - 0xF0, 0x28, 0x25, 0x28, 0xF0, - 0x7C, 0x54, 0x55, 0x45, 0x00, - 0x20, 0x54, 0x54, 0x7C, 0x54, - 0x7C, 0x0A, 0x09, 0x7F, 0x49, - 0x32, 0x49, 0x49, 0x49, 0x32, - 0x3A, 0x44, 0x44, 0x44, 0x3A, // o-umlaut - 0x32, 0x4A, 0x48, 0x48, 0x30, - 0x3A, 0x41, 0x41, 0x21, 0x7A, - 0x3A, 0x42, 0x40, 0x20, 0x78, - 0x00, 0x9D, 0xA0, 0xA0, 0x7D, - 0x3D, 0x42, 0x42, 0x42, 0x3D, // O-umlaut - 0x3D, 0x40, 0x40, 0x40, 0x3D, - 0x3C, 0x24, 0xFF, 0x24, 0x24, - 0x48, 0x7E, 0x49, 0x43, 0x66, - 0x2B, 0x2F, 0xFC, 0x2F, 0x2B, - 0xFF, 0x09, 0x29, 0xF6, 0x20, - 0xC0, 0x88, 0x7E, 0x09, 0x03, - 0x20, 0x54, 0x54, 0x79, 0x41, - 0x00, 0x00, 0x44, 0x7D, 0x41, - 0x30, 0x48, 0x48, 0x4A, 0x32, - 0x38, 0x40, 0x40, 0x22, 0x7A, - 0x00, 0x7A, 0x0A, 0x0A, 0x72, - 0x7D, 0x0D, 0x19, 0x31, 0x7D, - 0x26, 0x29, 0x29, 0x2F, 0x28, - 0x26, 0x29, 0x29, 0x29, 0x26, - 0x30, 0x48, 0x4D, 0x40, 0x20, - 0x38, 0x08, 0x08, 0x08, 0x08, - 0x08, 0x08, 0x08, 0x08, 0x38, - 0x2F, 0x10, 0xC8, 0xAC, 0xBA, - 0x2F, 0x10, 0x28, 0x34, 0xFA, - 0x00, 0x00, 0x7B, 0x00, 0x00, - 0x08, 0x14, 0x2A, 0x14, 0x22, - 0x22, 0x14, 0x2A, 0x14, 0x08, - 0x55, 0x00, 0x55, 0x00, 0x55, // #176 (25% block) missing in old code - 0xAA, 0x55, 0xAA, 0x55, 0xAA, // 50% block - 0xFF, 0x55, 0xFF, 0x55, 0xFF, // 75% block - 0x00, 0x00, 0x00, 0xFF, 0x00, - 0x10, 0x10, 0x10, 0xFF, 0x00, - 0x14, 0x14, 0x14, 0xFF, 0x00, - 0x10, 0x10, 0xFF, 0x00, 0xFF, - 0x10, 0x10, 0xF0, 0x10, 0xF0, - 0x14, 0x14, 0x14, 0xFC, 0x00, - 0x14, 0x14, 0xF7, 0x00, 0xFF, - 0x00, 0x00, 0xFF, 0x00, 0xFF, - 0x14, 0x14, 0xF4, 0x04, 0xFC, - 0x14, 0x14, 0x17, 0x10, 0x1F, - 0x10, 0x10, 0x1F, 0x10, 0x1F, - 0x14, 0x14, 0x14, 0x1F, 0x00, - 0x10, 0x10, 0x10, 0xF0, 0x00, - 0x00, 0x00, 0x00, 0x1F, 0x10, - 0x10, 0x10, 0x10, 0x1F, 0x10, - 0x10, 0x10, 0x10, 0xF0, 0x10, - 0x00, 0x00, 0x00, 0xFF, 0x10, - 0x10, 0x10, 0x10, 0x10, 0x10, - 0x10, 0x10, 0x10, 0xFF, 0x10, - 0x00, 0x00, 0x00, 0xFF, 0x14, - 0x00, 0x00, 0xFF, 0x00, 0xFF, - 0x00, 0x00, 0x1F, 0x10, 0x17, - 0x00, 0x00, 0xFC, 0x04, 0xF4, - 0x14, 0x14, 0x17, 0x10, 0x17, - 0x14, 0x14, 0xF4, 0x04, 0xF4, - 0x00, 0x00, 0xFF, 0x00, 0xF7, - 0x14, 0x14, 0x14, 0x14, 0x14, - 0x14, 0x14, 0xF7, 0x00, 0xF7, - 0x14, 0x14, 0x14, 0x17, 0x14, - 0x10, 0x10, 0x1F, 0x10, 0x1F, - 0x14, 0x14, 0x14, 0xF4, 0x14, - 0x10, 0x10, 0xF0, 0x10, 0xF0, - 0x00, 0x00, 0x1F, 0x10, 0x1F, - 0x00, 0x00, 0x00, 0x1F, 0x14, - 0x00, 0x00, 0x00, 0xFC, 0x14, - 0x00, 0x00, 0xF0, 0x10, 0xF0, - 0x10, 0x10, 0xFF, 0x10, 0xFF, - 0x14, 0x14, 0x14, 0xFF, 0x14, - 0x10, 0x10, 0x10, 0x1F, 0x00, - 0x00, 0x00, 0x00, 0xF0, 0x10, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, - 0xFF, 0xFF, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xFF, 0xFF, - 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, - 0x38, 0x44, 0x44, 0x38, 0x44, - 0xFC, 0x4A, 0x4A, 0x4A, 0x34, // sharp-s or beta - 0x7E, 0x02, 0x02, 0x06, 0x06, - 0x02, 0x7E, 0x02, 0x7E, 0x02, - 0x63, 0x55, 0x49, 0x41, 0x63, - 0x38, 0x44, 0x44, 0x3C, 0x04, - 0x40, 0x7E, 0x20, 0x1E, 0x20, - 0x06, 0x02, 0x7E, 0x02, 0x02, - 0x99, 0xA5, 0xE7, 0xA5, 0x99, - 0x1C, 0x2A, 0x49, 0x2A, 0x1C, - 0x4C, 0x72, 0x01, 0x72, 0x4C, - 0x30, 0x4A, 0x4D, 0x4D, 0x30, - 0x30, 0x48, 0x78, 0x48, 0x30, - 0xBC, 0x62, 0x5A, 0x46, 0x3D, - 0x3E, 0x49, 0x49, 0x49, 0x00, - 0x7E, 0x01, 0x01, 0x01, 0x7E, - 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, - 0x44, 0x44, 0x5F, 0x44, 0x44, - 0x40, 0x51, 0x4A, 0x44, 0x40, - 0x40, 0x44, 0x4A, 0x51, 0x40, - 0x00, 0x00, 0xFF, 0x01, 0x03, - 0xE0, 0x80, 0xFF, 0x00, 0x00, - 0x08, 0x08, 0x6B, 0x6B, 0x08, - 0x36, 0x12, 0x36, 0x24, 0x36, - 0x06, 0x0F, 0x09, 0x0F, 0x06, - 0x00, 0x00, 0x18, 0x18, 0x00, - 0x00, 0x00, 0x10, 0x10, 0x00, - 0x30, 0x40, 0xFF, 0x01, 0x01, - 0x00, 0x1F, 0x01, 0x01, 0x1E, - 0x00, 0x19, 0x1D, 0x17, 0x12, - 0x00, 0x3C, 0x3C, 0x3C, 0x3C, - 0x00, 0x00, 0x00, 0x00, 0x00 // #255 NBSP -}; - -const struct font font_ascii_7x5 = { - 5, - 7, - 1, - 256, - (unsigned char *)ascii_font -}; - -#endif /* ASCII_FONT_H_ */ diff --git a/source/firmware/kernel/bitmap.c b/source/firmware/kernel/bitmap.c deleted file mode 100644 index 0a55b60..0000000 --- a/source/firmware/kernel/bitmap.c +++ /dev/null @@ -1,35 +0,0 @@ -/* - * canvas.c - * - * Created on: Jan 15, 2016 - * Author: tkl - */ - -#include -#include - -#include "font.h" -#include "bitmap.h" - -int bitmap_print_text(const struct font *font, struct bitmap *bitmap, int x_pos, - int y_pos, char *text) -{ - int i = 0, pos = 0; - /* align to page */ - if(y_pos % 8 != 0) - y_pos -= y_pos % 8; - - pos = y_pos / 8 * bitmap->x_size + x_pos; - while(text[i] != 0) { - while(((pos + font->char_size_x) % bitmap->x_size) < font->char_size_x) - pos++; - memcpy(&bitmap->buffer[pos], &font->font[text[i] * font->char_size_x], - font->char_size_x); - memset(&bitmap->buffer[pos + font->char_size_x], 0x00, - font->char_between); - i++; - pos += font->char_size_x + 1; - } - - return 0; -} diff --git a/source/firmware/kernel/bitmap.h b/source/firmware/kernel/bitmap.h deleted file mode 100644 index 052f9d1..0000000 --- a/source/firmware/kernel/bitmap.h +++ /dev/null @@ -1,20 +0,0 @@ -/* - * bitmap.h - * - * Created on: Jan 15, 2016 - * Author: tkl - */ - -#ifndef BITMAP_H_ -#define BITMAP_H_ - -struct bitmap { - int x_size; - int y_size; - char *buffer; -}; - -int bitmap_print_text(const struct font *font, struct bitmap *bitmap, int x_pos, - int y_pos, char *text); - -#endif /* BITMAP_H_ */ diff --git a/source/firmware/kernel/driver/battery_monitor.c b/source/firmware/kernel/driver/battery_monitor.c deleted file mode 100755 index 94c774b..0000000 --- a/source/firmware/kernel/driver/battery_monitor.c +++ /dev/null @@ -1,25 +0,0 @@ -/* - * battery_monitor.c - * - * Created on: Dec 23, 2012 - * Author: tkl - */ -#include "stddef.h" -#include "adc.h" -#include "battery_monitor.h" - -//------------------------------------------------------------------------------ -struct battery_monitor_voltage get_voltage(const struct battery_monitor *device) -{ - struct battery_monitor_voltage ret; - ret.valid = false; - if(NULL == device) { - return ret; - } - adc_open(device->adc); - ret.raw = adc_read(device->adc, device->timeout); - adc_close(device->adc); - ret.voltage = ret.raw * device->factor / device->divider + device->offset; - ret.valid = true; - return ret; -} diff --git a/source/firmware/kernel/driver/battery_monitor.h b/source/firmware/kernel/driver/battery_monitor.h deleted file mode 100755 index 0251019..0000000 --- a/source/firmware/kernel/driver/battery_monitor.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * battery_monitor.h - * - * Created on: Dec 23, 2012 - * Author: tkl - */ - -#ifndef BATTERY_MONITOR_H_ -#define BATTERY_MONITOR_H_ - -#include "stdbool.h" - -//------------------------------------------------------------------------------ -//! \brief battery monitor device. -struct battery_monitor { - const struct adc *adc; //!< Adc device for the battery monitor. - const unsigned short timeout; //!< Adc measurement timeout. - const int factor; //!< Factor to calculate voltage from adc result. - const int divider; //!< Divider to calculate voltage from adc result. - const int offset; //!< Offset to calculate voltage from adc result. -}; - -//------------------------------------------------------------------------------ -//! \brief Value container for the battery monitor. -struct battery_monitor_voltage { - unsigned short voltage; //!< Calculated voltage. - unsigned short raw; //!< Raw value of the adc. - bool valid; //!< Indicates if result is valid. -}; - -//------------------------------------------------------------------------------ -struct battery_monitor_voltage get_voltage(const struct battery_monitor * device); - -#endif /* BATTERY_MONITOR_H_ */ diff --git a/source/firmware/kernel/driver/cc110x.c b/source/firmware/kernel/driver/cc110x.c deleted file mode 100755 index 63aa5a0..0000000 --- a/source/firmware/kernel/driver/cc110x.c +++ /dev/null @@ -1,146 +0,0 @@ -/* - * cc110x.c - * - * Created on: Jul 20, 2012 - * Author: tkl - */ - -#include -#include -#include "board.h" -#include "stack.h" -#include "queue.h" -#include "thread.h" -#include "schedule.h" -#include "irq.h" -#include "sys_tick.h" -#include "cc110x.h" - -static volatile bool tx_condition; -extern volatile struct thread_context *current_thread; - -static void it_cb(const struct cc110x *cc110x, enum cc110x_it_type it_type); - -int cc110x_open(const struct cc110x *cc110x) -{ - if(NULL == cc110x) - return (-1); - - tx_condition = false; - cc110x->fp->init(cc110x); - cc110x->fp->set_it_callback(cc110x->arch_dep_device, it_cb, cc110x); - cc110x_set_radio_mode(cc110x, CC110X_RADIO_MODE_PWD); - cc110x_write_pa_table(cc110x); - return (0); -} - -int cc110x_close(const struct cc110x *cc110x) -{ - cc110x_set_radio_mode(cc110x, CC110X_RADIO_MODE_PWD); - blocking_read_wakeup(cc110x); - return 0; -} - -void cc110x_set_radio_mode(const struct cc110x *cc110x, - enum cc110x_radio_mode mode) -{ - if(NULL == cc110x) { - return; - } - *(cc110x->radio_mode) = mode; - enum cc110x_strobe_cmd cmd = STROBE_SIDLE; - switch(mode) { - case CC110X_RADIO_MODE_NONE: return; - case CC110X_RADIO_MODE_IDLE: cmd = STROBE_SIDLE; break; - case CC110X_RADIO_MODE_RX: cmd = STROBE_SRX; break; - case CC110X_RADIO_MODE_TX: cmd = STROBE_STX; break; - case CC110X_RADIO_MODE_PWD: cmd = STROBE_SPWD; break; - } - cc110x->fp->strobe(cc110x->arch_dep_device, cmd); -} - -enum cc110x_radio_mode cc110x_get_radio_mode(const struct cc110x *cc110x) -{ - if(NULL == cc110x) - return (CC110X_RADIO_MODE_NONE); - return (*(cc110x->radio_mode)); -} - -void cc110x_write_pa_table(const struct cc110x *cc110x) -{ - if(NULL == cc110x) - return; - cc110x->fp->write_pa_table(cc110x->arch_dep_device); -} - -void cc110x_strobe(const struct cc110x *cc110x, enum cc110x_strobe_cmd cmd) -{ - if(NULL == cc110x) - return; - cc110x->fp->strobe(cc110x->arch_dep_device, cmd); -} - -int cc110x_write(const struct cc110x *cc110x, const char *buffer, - int size) -{ - enum cc110x_radio_mode mode; - int ret; - if((NULL == cc110x) || (NULL == buffer)) - return (-1); - mode = cc110x_get_radio_mode(cc110x); - cc110x_set_radio_mode(cc110x, CC110X_RADIO_MODE_IDLE); - cc110x_strobe(cc110x, STROBE_SFTX); - ret = cc110x->fp->write(cc110x->arch_dep_device, buffer, size); - tx_condition = true; - cc110x_set_radio_mode(cc110x, CC110X_RADIO_MODE_TX); - while(tx_condition); - cc110x_set_radio_mode(cc110x, CC110X_RADIO_MODE_IDLE); - cc110x_strobe(cc110x, STROBE_SFTX); - cc110x_set_radio_mode(cc110x, mode); - return (ret); -} - -int cc110x_read(const struct cc110x *cc110x, char *buffer, int size) -{ - int ret; - if((NULL == cc110x) || (NULL == buffer)) - return (-1); - if(0 == cc110x_get_rx_count(cc110x)) { - unsigned int irq = disable_irq(); - current_thread->status = THREAD_STATUS_BLOCKING; - current_thread->wakeup_blocking_source = (void*) cc110x; - restore_irq(irq); - schedule(); - } - enum cc110x_radio_mode mode = cc110x_get_radio_mode(cc110x); - cc110x_set_radio_mode(cc110x, CC110X_RADIO_MODE_IDLE); - ret = cc110x_get_rx_count(cc110x); - ret = cc110x->fp->read(cc110x->arch_dep_device, buffer, ret); - cc110x_strobe(cc110x, STROBE_SFRX); - cc110x_set_radio_mode(cc110x, mode); - return (ret); -} - -int cc110x_get_rx_count(const struct cc110x *cc110x) -{ - if(NULL == cc110x) - return (-1); - return (cc110x->fp->get_rx_count(cc110x->arch_dep_device)); -} - -static void it_cb(const struct cc110x *cc110x, - enum cc110x_it_type it_type) -{ - if(NULL == cc110x) - return; - switch(it_type) { - case IT_TYPE_NONE: - break; - case IT_TYPE_RX_COMPLETE: - blocking_read_wakeup(cc110x); - break; - case IT_TYPE_TX_COMPLETE: - tx_condition = false; - break; - } -} diff --git a/source/firmware/kernel/driver/cc110x.h b/source/firmware/kernel/driver/cc110x.h deleted file mode 100755 index 5200916..0000000 --- a/source/firmware/kernel/driver/cc110x.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * cc110x.h - * - * Created on: Jul 20, 2012 - * Author: tkl - */ - -#ifndef CC110X_H_ -#define CC110X_H_ - -enum cc110x_radio_mode { - CC110X_RADIO_MODE_NONE = 0, - CC110X_RADIO_MODE_IDLE, - CC110X_RADIO_MODE_RX, - CC110X_RADIO_MODE_TX, - CC110X_RADIO_MODE_PWD -}; - -enum cc110x_strobe_cmd { - STROBE_SRES = 0, - STROBE_SFSTXON, - STROBE_SXOFF, - STROBE_SCAL, - STROBE_SRX, - STROBE_STX, - STROBE_SIDLE, - STROBE_SWOR, - STROBE_SPWD, - STROBE_SFRX, - STROBE_SFTX, - STROBE_SWORRST, - STROBE_SNOP -}; - -enum cc110x_it_type { - IT_TYPE_NONE = 0, - IT_TYPE_RX_COMPLETE, - IT_TYPE_TX_COMPLETE -}; - -typedef void (*cc110x_fp_init)(const void *); -typedef void (*cc110x_fp_write_pa_table)(const void *); -typedef void (*cc110x_fp_set_radio_mode)(const void *, enum cc110x_radio_mode); -typedef char (*cc110x_fp_strobe)(const void *, enum cc110x_strobe_cmd); -typedef int (*cc110x_fp_write)(const void *, const char *, int); -typedef int (*cc110x_fp_read)(const void *, char *, int); -typedef int (*cc110x_fp_set_it_cb)(const void *, const void *, const void *); -typedef int (*cc110x_fp_get_rx_count)(const void *); - -//! \brief Contains the function pointer to access the cc110x driver. -struct cc110x_fp { - /*! Function pointer to the init function. */ - const cc110x_fp_init init; - /*! Function pointer to the strobe function. */ - const cc110x_fp_strobe strobe; - /*! Function pointer to the write function. */ - const cc110x_fp_write write; - /*! Function pointer to the read function. */ - const cc110x_fp_read read; - /*! Function pointer to the write_pa_table function. */ - const cc110x_fp_write_pa_table write_pa_table; - /*! Function pointer to the set_it_callback function. */ - const cc110x_fp_set_it_cb set_it_callback; - /*! Function pointer to the get_rx_count function. */ - const cc110x_fp_get_rx_count get_rx_count; -}; - -//! \brief The cc110x driver object. -struct cc110x { - /*! Radio mode. */ - enum cc110x_radio_mode *radio_mode; - /*! Architecture depended underlaying device (i.e. spi_t or NULL). */ - const void *arch_dep_device; - /*! Function pointer for the cc110x driver access. */ - const struct cc110x_fp *fp; -}; - -int cc110x_open(const struct cc110x *cc110x); -int cc110x_close(const struct cc110x *cc110x); -int cc110x_write(const struct cc110x *cc110x, const char *buffer, int size); -int cc110x_read(const struct cc110x *cc110x, char *buffer, int size); -int cc110x_get_rx_count(const struct cc110x *cc110x); -void cc110x_set_radio_mode(const struct cc110x *cc110x, enum cc110x_radio_mode mode); -enum cc110x_radio_mode cc110x_get_radio_mode(const struct cc110x *cc110x); -void cc110x_write_pa_table(const struct cc110x *cc110x); -void cc110x_strobe(const struct cc110x *cc110x, enum cc110x_strobe_cmd cmd); - -#endif /* CC110X_H_ */ diff --git a/source/firmware/kernel/driver/ds75.c b/source/firmware/kernel/driver/ds75.c deleted file mode 100755 index eb4f8c2..0000000 --- a/source/firmware/kernel/driver/ds75.c +++ /dev/null @@ -1,126 +0,0 @@ -/* - * ds75.c - * - * Created on: Aug 1, 2012 - * Author: tkl - */ - -#include -#include "ds75.h" - -//----------------------------------------------------------------------------- -#define TEMPERATURE_REGISTER_ADDR 0x00 -#define CONFIGURATION_REGISTER_ADDR 0x01 - -//----------------------------------------------------------------------------- -int ds75_open(const struct ds75 *device) { - if(NULL == device) { - return -1; - } - *device->config_value = 0x00; - return device->i2c->fp->open(device->i2c->arch_dep_device); -} - -//----------------------------------------------------------------------------- -int ds75_close(const struct ds75 *device) { - if(NULL == device) { - return -1; - } - return device->i2c->fp->close(device->i2c->arch_dep_device); -} - -//----------------------------------------------------------------------------- -int ds75_set_precision(const struct ds75 *device, enum ds75_precision precision) -{ - if(NULL == device) { - return -1; - } - char cfg = *device->config_value | (precision << 5); - char buffer[] = {CONFIGURATION_REGISTER_ADDR, cfg}; - int ret = device->i2c->fp->write(device->i2c->arch_dep_device, - device->i2c_slave_addr, buffer, sizeof(buffer)); - if (ret >= 0) { - *device->config_value = cfg; - } - return ret; -} - -//----------------------------------------------------------------------------- -enum ds75_precision ds_75_get_precision(const struct ds75 *device) { - if(NULL == device) { - return DS_75_PRECISION_INVALID; - } - - char cfg = *device->config_value; - cfg >>= 5; - cfg &= 3; - return (enum ds75_precision) cfg; -} - -//----------------------------------------------------------------------------- -int ds_75_shut_down(const struct ds75 *device) { - if(NULL == device) { - return -1; - } - char cfg = *device->config_value | (1 << 0); - char buffer[] = {CONFIGURATION_REGISTER_ADDR, cfg}; - int ret = device->i2c->fp->write(device->i2c->arch_dep_device, - device->i2c_slave_addr, buffer, sizeof(buffer)); - if (ret >= 0) { - *device->config_value = cfg; - } - return ret; -} - -//----------------------------------------------------------------------------- -int ds_75_wakeup(const struct ds75 *device) { - if(NULL == device) { - return -1; - } - char cfg = *device->config_value & ~(1 << 0); - char buffer[] = {CONFIGURATION_REGISTER_ADDR, cfg}; - int ret = device->i2c->fp->write(device->i2c->arch_dep_device, - device->i2c_slave_addr, buffer, sizeof(buffer)); - if (ret >= 0) { - *device->config_value = cfg; - } - return ret; -} - -//----------------------------------------------------------------------------- -struct ds75_temperature ds_75_get_temperature(const struct ds75 *device) { - struct ds75_temperature ret; - ret.temperature = 0xFFFF; - ret.raw[0] = 0xFF; - ret.raw[1] = 0xFF; - ret.valid = false; - if(NULL == device) { - return ret; - } - // set temperature register - char addr = TEMPERATURE_REGISTER_ADDR; - int res = device->i2c->fp->write(device->i2c->arch_dep_device, device->i2c_slave_addr, &addr, 1); - if(res < 0) { - return ret; - } - - // read temperature register - res = device->i2c->fp->read(device->i2c->arch_dep_device, device->i2c_slave_addr, ret.raw, 2); - if(res < 0) { - return ret; - } - ret.valid = true; - - ret.temperature = ret.raw[0]; - if(ret.temperature & 0x0080) { - ret.temperature |= 0xFF00; - } - ret.temperature *= 10; - unsigned short s_low = (unsigned char)ret.raw[1]; - s_low >>= 4; - s_low *= 625; - s_low += 500; - s_low /= 1000; - ret.temperature += s_low; - return ret; -} diff --git a/source/firmware/kernel/driver/ds75.h b/source/firmware/kernel/driver/ds75.h deleted file mode 100755 index 0ab43e2..0000000 --- a/source/firmware/kernel/driver/ds75.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * ds75.h - * - * Created on: Aug 1, 2012 - * Author: tkl - */ - -#ifndef DS75_H_ -#define DS75_H_ - -#include -#include "i2c.h" - -//----------------------------------------------------------------------------- -enum ds75_precision { - DS_75_PRECISION_9_BIT = 0, - DS_75_PRECISION_10_BIT, - DS_75_PRECISION_11_BIT, - DS_75_PRECISION_12_BIT, - - DS_75_PRECISION_INVALID -}; - -//----------------------------------------------------------------------------- -//! \brief The ds75 driver object. -struct ds75 { - const struct i2c * i2c; //!< The i2c device the ds75 is connected to. - const char i2c_slave_addr; //!< The i2c slave address of the ds 75. - char *const config_value; //!< Config value. -}; - -//----------------------------------------------------------------------------- -//! \brief Data container for the ds 75 measurement result. -struct ds75_temperature { - short temperature; //!< Calculated temperature. - char raw[2]; //!< Raw i2c result. - bool valid; //!< Validity indicator. -}; - -//----------------------------------------------------------------------------- -int ds75_open(const struct ds75 *device); -int ds75_close(const struct ds75 *device); -int ds75_set_precision(const struct ds75 *device, enum ds75_precision precision); -enum ds75_precision ds_75_get_precision(const struct ds75 *device); -int ds_75_shut_down(const struct ds75 *device); -int ds_75_wakeup(const struct ds75 *device); -struct ds75_temperature ds_75_get_temperature(const struct ds75 *device); - -#endif /* DS75_H_ */ diff --git a/source/firmware/kernel/driver/adc.h b/source/firmware/kernel/driver/include/adc.h similarity index 100% rename from source/firmware/kernel/driver/adc.h rename to source/firmware/kernel/driver/include/adc.h diff --git a/source/firmware/kernel/driver/gpio.h b/source/firmware/kernel/driver/include/gpio.h similarity index 100% rename from source/firmware/kernel/driver/gpio.h rename to source/firmware/kernel/driver/include/gpio.h diff --git a/source/firmware/kernel/driver/i2c.h b/source/firmware/kernel/driver/include/i2c.h similarity index 100% rename from source/firmware/kernel/driver/i2c.h rename to source/firmware/kernel/driver/include/i2c.h diff --git a/source/firmware/kernel/driver/rtc.h b/source/firmware/kernel/driver/include/rtc.h similarity index 100% rename from source/firmware/kernel/driver/rtc.h rename to source/firmware/kernel/driver/include/rtc.h diff --git a/source/firmware/kernel/driver/spi.h b/source/firmware/kernel/driver/include/spi.h similarity index 100% rename from source/firmware/kernel/driver/spi.h rename to source/firmware/kernel/driver/include/spi.h diff --git a/source/firmware/kernel/driver/timer.h b/source/firmware/kernel/driver/include/timer.h similarity index 100% rename from source/firmware/kernel/driver/timer.h rename to source/firmware/kernel/driver/include/timer.h diff --git a/source/firmware/kernel/driver/uart.h b/source/firmware/kernel/driver/include/uart.h similarity index 100% rename from source/firmware/kernel/driver/uart.h rename to source/firmware/kernel/driver/include/uart.h diff --git a/source/firmware/kernel/driver/ssd1306.c b/source/firmware/kernel/driver/ssd1306.c deleted file mode 100644 index 5bf62b2..0000000 --- a/source/firmware/kernel/driver/ssd1306.c +++ /dev/null @@ -1,139 +0,0 @@ -/* - * ssd1306.c - * - * Created on: Jan 13, 2016 - * Author: tkl - */ - -#include -#include "i2c.h" -#include "font.h" -#include "bitmap.h" -#include "ssd1306.h" - -#define MAX_COLUMN 128 -#define MAX_ROW 64 -#define PAGE_COUNT 8 -#define HEAD_PAGE_COUNT 2 -#define BODY_PAGE_COUNT PAGE_COUNT - HEAD_PAGE_COUNT - -#define CMD_MODE 0x80 -#define DATA_MODE 0x40 - -#define COLUMN_ADDR 0x21 -#define PAGE_ADDR 0x22 -#define DISPLAY_OFF 0xAE - -static const char init_sequence[] = { - 0x80, 0xAE, 0x80, 0x20, 0x80, 0x10, 0x80, 0xb0, 0x80, 0xc8, 0x80, 0x00, - 0x80, 0x10, 0x80, 0x40, 0x80, 0x81, 0x80, 0x7f, 0x80, 0xa1, 0x80, 0xa6, - 0x80, 0xa8, 0x80, 0x3f, 0x80, 0xa4, 0x80, 0xd3, 0x80, 0x00, 0x80, 0xd5, - 0x80, 0xf0, 0x80, 0xd9, 0x80, 0x22, 0x80, 0xda, 0x80, 0x12, 0x80, 0xdb, - 0x80, 0x20, 0x80, 0x8d, 0x80, 0x14, 0x80, 0xaf -}; - -static int set_column(const struct ssd1306 *dev, char column) -{ - char buf[6]; - buf[0] = CMD_MODE; - buf[1] = COLUMN_ADDR; - buf[2] = CMD_MODE; - buf[3] = column; - buf[4] = CMD_MODE; - buf[5] = MAX_COLUMN - 1; - return i2c_write(dev->dev, dev->i2c_addr, buf, 6); -} - -static int set_page(const struct ssd1306 *dev, char page) -{ - char buf[6]; - buf[0] = CMD_MODE; - buf[1] = PAGE_ADDR; - buf[2] = CMD_MODE; - buf[3] = page; - buf[4] = CMD_MODE; - buf[5] = MAX_ROW / PAGE_COUNT - 1; - return i2c_write(dev->dev, dev->i2c_addr, buf, 6); -} - -static int clear_head(const struct ssd1306 *dev) -{ - int ret, i, j; - char buf[2]; - - ret = set_column(dev, 0); - ret |= set_page(dev, 0); - - buf[0] = DATA_MODE; - buf[1] = 0x00; - for(i = 0; i < HEAD_PAGE_COUNT; i++) - for(j = 0; j < MAX_COLUMN; j++) - ret |= i2c_write(dev->dev, dev->i2c_addr, buf, 2); - return ret; -} - -static int clear_body(const struct ssd1306 *dev) -{ - int ret, i, j; - char buf[2]; - - ret = set_column(dev, 0); - ret |= set_page(dev, 2); - - buf[0] = DATA_MODE; - buf[1] = 0x00; - for(i = 0; i < BODY_PAGE_COUNT; i++) - for(j = 0; j < MAX_COLUMN; j++) - ret |= i2c_write(dev->dev, dev->i2c_addr, buf, 2); - return ret; -} - -static int clear(const struct ssd1306 *dev) -{ - int ret; - ret = clear_head(dev); - ret |= clear_body(dev); - - return ret; -} - -int ssd1306_open(const struct ssd1306 *dev) -{ - int ret; - ret = i2c_open((struct i2c *)dev->dev); - ret |= i2c_write(dev->dev, dev->i2c_addr, init_sequence, - sizeof(init_sequence) / sizeof(init_sequence[0])); - ret |= clear(dev); - ret |= set_column(dev, 0); - ret |= set_page(dev, 0); - - return ret; -} - -int ssd1306_close(const struct ssd1306 *dev) -{ - int ret; - char buf[2]; - buf[0] = CMD_MODE; - buf[1] = DISPLAY_OFF; - ret = i2c_write(dev->dev, dev->i2c_addr, buf, 2); - ret |= i2c_close((struct i2c *)dev->dev); - return ret; -} - -int ssd1306_write(const struct ssd1306 *dev, const struct bitmap *bitmap) -{ - int ret, i, len = bitmap->x_size * bitmap->y_size / 8; - char buf[2] = {DATA_MODE, 0x00}; - - if(len != MAX_COLUMN * PAGE_COUNT) - return -1; - ret = set_column(dev, 0); - ret |= set_page(dev, 0); - for(i = 0; i < len; i++) { - buf[1] = bitmap->buffer[i]; - ret |= i2c_write(dev->dev, dev->i2c_addr, buf, 2); - } - - return ret; -} diff --git a/source/firmware/kernel/driver/ssd1306.h b/source/firmware/kernel/driver/ssd1306.h deleted file mode 100644 index 00c4508..0000000 --- a/source/firmware/kernel/driver/ssd1306.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - * ssd1306.h - * - * Created on: Jan 13, 2016 - * Author: tkl - */ - -#ifndef SSD1306_H_ -#define SSD1306_H_ - -struct ssd1306 { - const struct i2c *dev; - const char i2c_addr; -}; - -struct bitmap; - -int ssd1306_open(const struct ssd1306 *dev); -int ssd1306_close(const struct ssd1306 *dev); -int ssd1306_write(const struct ssd1306 *dev, const struct bitmap *bitmap); - -#endif /* SSD1306_H_ */ diff --git a/source/firmware/kernel/font.h b/source/firmware/kernel/font.h deleted file mode 100644 index bbf569d..0000000 --- a/source/firmware/kernel/font.h +++ /dev/null @@ -1,19 +0,0 @@ -/* - * font.h - * - * Created on: Jan 15, 2016 - * Author: tkl - */ - -#ifndef FONT_H_ -#define FONT_H_ - -struct font { - int char_size_x; - int char_size_y; - int char_between; - int char_count; - unsigned char *font; -}; - -#endif /* FONT_H_ */ diff --git a/source/firmware/kernel/ctx.h b/source/firmware/kernel/include/ctx.h similarity index 100% rename from source/firmware/kernel/ctx.h rename to source/firmware/kernel/include/ctx.h diff --git a/source/firmware/kernel/irq.h b/source/firmware/kernel/include/irq.h similarity index 100% rename from source/firmware/kernel/irq.h rename to source/firmware/kernel/include/irq.h diff --git a/source/firmware/kernel/isr.h b/source/firmware/kernel/include/isr.h similarity index 100% rename from source/firmware/kernel/isr.h rename to source/firmware/kernel/include/isr.h diff --git a/source/firmware/kernel/include/list.h b/source/firmware/kernel/include/list.h new file mode 100644 index 0000000..b87e3be --- /dev/null +++ b/source/firmware/kernel/include/list.h @@ -0,0 +1,24 @@ +/* + * list.h + * + * Created on: Jul 27, 2016 + * Author: tkl + */ + +#ifndef SOURCE_FIRMWARE_KERNEL_LIST_H_ +#define SOURCE_FIRMWARE_KERNEL_LIST_H_ + +struct list_node { + struct list_node *next; + unsigned int data; +}; + +struct list { + struct list_node *front; + struct list_node *rear; +}; + +int list_init(struct list *head); +int list_add(struct list *head, struct list_node *node); + +#endif /* SOURCE_FIRMWARE_KERNEL_LIST_H_ */ diff --git a/source/firmware/kernel/low_power.h b/source/firmware/kernel/include/low_power.h similarity index 100% rename from source/firmware/kernel/low_power.h rename to source/firmware/kernel/include/low_power.h diff --git a/source/firmware/kernel/queue.h b/source/firmware/kernel/include/queue.h similarity index 100% rename from source/firmware/kernel/queue.h rename to source/firmware/kernel/include/queue.h diff --git a/source/firmware/kernel/ringbuffer.h b/source/firmware/kernel/include/ringbuffer.h similarity index 100% rename from source/firmware/kernel/ringbuffer.h rename to source/firmware/kernel/include/ringbuffer.h diff --git a/source/firmware/kernel/schedule.h b/source/firmware/kernel/include/schedule.h similarity index 100% rename from source/firmware/kernel/schedule.h rename to source/firmware/kernel/include/schedule.h diff --git a/source/firmware/kernel/semaphore.h b/source/firmware/kernel/include/semaphore.h similarity index 100% rename from source/firmware/kernel/semaphore.h rename to source/firmware/kernel/include/semaphore.h diff --git a/source/firmware/kernel/stack.h b/source/firmware/kernel/include/stack.h similarity index 100% rename from source/firmware/kernel/stack.h rename to source/firmware/kernel/include/stack.h diff --git a/source/firmware/kernel/sys_tick.h b/source/firmware/kernel/include/sys_tick.h similarity index 100% rename from source/firmware/kernel/sys_tick.h rename to source/firmware/kernel/include/sys_tick.h diff --git a/source/firmware/kernel/thread.h b/source/firmware/kernel/include/thread.h similarity index 100% rename from source/firmware/kernel/thread.h rename to source/firmware/kernel/include/thread.h diff --git a/source/firmware/kernel/list.c b/source/firmware/kernel/list.c new file mode 100644 index 0000000..7e25b4e --- /dev/null +++ b/source/firmware/kernel/list.c @@ -0,0 +1,36 @@ +/* + * list.c + * + * Created on: Jul 27, 2016 + * Author: tkl + */ + +#include "stddef.h" +#include "list.h" + +int list_init(struct list *head) +{ + if(NULL == head) + return -1; + + head->front = NULL; + head->rear = NULL; + + return 0; +} + +int list_add(struct list *head, struct list_node *node) +{ + if((NULL == head) || (NULL == node)) + return -1; + + if(head->front == NULL) { + head->front = node; + head->rear = node; + } + else { + head->rear->next = node; + head->rear = node; + } + return 1; +}