authorNathael Pajani <nathael.pajani@ed3l.fr>
Thu, 3 Jan 2019 21:44:59 +0000 (22:44 +0100)
committerNathael Pajani <nathael.pajani@ed3l.fr>
Thu, 3 Jan 2019 21:44:59 +0000 (22:44 +0100)
22 files changed:
apps/blyes/inter_lights/Makefile [deleted file]
apps/blyes/inter_lights/README [deleted file]
apps/blyes/inter_lights/config.c [deleted file]
apps/blyes/inter_lights/config.h [deleted file]
apps/blyes/inter_lights/main.c [deleted file]
apps/blyes/inter_lights/sensors.c [deleted file]
apps/blyes/inter_lights/sensors.h [deleted file]
apps/blyes/inter_lights/time.c [deleted file]
apps/blyes/inter_lights/time.h [deleted file]
apps/blyes/inter_lights/uSD.c [deleted file]
apps/blyes/inter_lights/uSD.h [deleted file]
apps/blyes/relay_lights/Makefile [deleted file]
apps/blyes/relay_lights/README [deleted file]
apps/blyes/relay_lights/config.c [deleted file]
apps/blyes/relay_lights/config.h [deleted file]
apps/blyes/relay_lights/interface.c [deleted file]
apps/blyes/relay_lights/interface.h [deleted file]
apps/blyes/relay_lights/main.c [deleted file]
apps/cape_rccar/rccar/Makefile [deleted file]
apps/cape_rccar/rccar/main.c [deleted file]
apps/cape_rccar/remote/Makefile [deleted file]
apps/cape_rccar/remote/main.c [deleted file]

diff --git a/apps/blyes/inter_lights/Makefile b/apps/blyes/inter_lights/Makefile
deleted file mode 100644 (file)
index 41ae555..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-# Makefile for apps
-
-MODULE = $(shell basename $(shell cd .. && pwd && cd -))
-NAME = $(shell basename $(CURDIR))
-
-# Add this to your ~/.vimrc in order to get proper function of :make in vim :
-# let $COMPILE_FROM_IDE = 1
-ifeq ($(strip $(COMPILE_FROM_IDE)),)
-       PRINT_DIRECTORY = --no-print-directory
-else
-       PRINT_DIRECTORY =
-       LANG = C
-endif
-
-.PHONY: $(NAME).bin
-$(NAME).bin:
-       @make -C ../../.. ${PRINT_DIRECTORY} NAME=$(NAME) MODULE=$(MODULE) apps/$(MODULE)/$(NAME)/$@
-
-clean mrproper:
-       @make -C ../../.. ${PRINT_DIRECTORY} $@
-
diff --git a/apps/blyes/inter_lights/README b/apps/blyes/inter_lights/README
deleted file mode 100644 (file)
index 1cce61b..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-Blyes - Inter Lights board
-
-Copyright 2018 Nathael Pajani <nathael.pajani@ed3l.fr>
-
-
-/* ****************************************************************************
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- *************************************************************************** */
-
diff --git a/apps/blyes/inter_lights/config.c b/apps/blyes/inter_lights/config.c
deleted file mode 100644 (file)
index 39b44c4..0000000
+++ /dev/null
@@ -1,209 +0,0 @@
-/****************************************************************************
- *   apps/blyes/inter_lights/config.c
- *
- * Copyright 2018 Nathael Pajani <nathael.pajani@ed3l.fr>
- *
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- *************************************************************************** */
-
-#include "core/system.h"
-#include "core/systick.h"
-#include "core/pio.h"
-
-#include "drivers/serial.h"
-#include "drivers/gpio.h"
-#include "drivers/i2c.h"
-#include "drivers/ssp.h"
-
-#include "extdrv/status_led.h"
-
-#include "lib/stdio.h"
-
-#include "sensors.h"
-#include "uSD.h"
-#include "time.h"
-
-#define SELECTED_FREQ  FREQ_SEL_48MHz
-
-/***************************************************************************** */
-/* Pins configuration */
-/* pins blocks are passed to set_pins() for pins configuration.
- * Unused pin blocks can be removed safely with the corresponding set_pins() call
- * All pins blocks may be safelly merged in a single block for single set_pins() call..
- */
-const struct pio_config common_pins[] = {
-       /* UART 0 */
-       { LPC_UART0_RX_PIO_0_1,  LPC_IO_DIGITAL },
-       { LPC_UART0_TX_PIO_0_2,  LPC_IO_DIGITAL },
-       { LPC_UART0_RTS_PIO_0_0, LPC_IO_DIGITAL },
-       { LPC_GPIO_0_28, LPC_IO_DIGITAL },
-       /* UART 1 */
-       { LPC_UART1_RX_PIO_0_8,  LPC_IO_DIGITAL },
-       { LPC_UART1_TX_PIO_0_9,  LPC_IO_DIGITAL },
-       /* I2C 0 */
-       { LPC_I2C0_SCL_PIO_0_10, (LPC_IO_DIGITAL | LPC_IO_OPEN_DRAIN_ENABLE) },
-       { LPC_I2C0_SDA_PIO_0_11, (LPC_IO_DIGITAL | LPC_IO_OPEN_DRAIN_ENABLE) },
-       /* SPI : uSD card */
-       { LPC_SSP0_SCLK_PIO_0_14, LPC_IO_DIGITAL },
-       { LPC_SSP0_MOSI_PIO_0_17, LPC_IO_DIGITAL },
-       { LPC_SSP0_MISO_PIO_0_16, LPC_IO_DIGITAL },
-       { LPC_GPIO_0_15, LPC_IO_DIGITAL },  /* uSD Card SPI Chip Select */
-       { LPC_GPIO_0_18, LPC_IO_DIGITAL },  /* External SPI Chip Select */
-       /* Lights control switches */
-       { LPC_GPIO_0_19, LPC_IO_DIGITAL },
-       { LPC_GPIO_0_20, LPC_IO_DIGITAL },
-       /* Shutters control */
-       { LPC_GPIO_0_30, (LPC_IO_DIGITAL | LPC_IO_MODE_PULL_UP) },
-       { LPC_GPIO_0_31, (LPC_IO_DIGITAL | LPC_IO_MODE_PULL_UP) },
-       /* Led lights 12V */
-       { LPC_GPIO_1_3, (LPC_IO_DIGITAL | LPC_IO_MODE_PULL_UP) },
-       { LPC_GPIO_1_4, (LPC_IO_DIGITAL | LPC_IO_MODE_PULL_UP) },
-       { LPC_GPIO_1_5, (LPC_IO_DIGITAL | LPC_IO_MODE_PULL_UP) },
-       { LPC_GPIO_1_6, (LPC_IO_DIGITAL | LPC_IO_MODE_PULL_UP) },
-       ARRAY_LAST_PIO,
-};
-
-const struct pio status_led_green = LPC_GPIO_0_23;
-const struct pio status_led_red = LPC_GPIO_0_24;
-
-const struct pio rs485_rxen = LPC_GPIO_0_28;
-
-const struct pio uSD_cs = LPC_GPIO_0_15;
-
-const struct pio cmd_shutters_up = LPC_GPIO_1_1;
-const struct pio cmd_shutters_down = LPC_GPIO_1_2;
-const struct pio led_0 = LPC_GPIO_1_3;
-const struct pio led_1 = LPC_GPIO_1_4;
-const struct pio led_2 = LPC_GPIO_1_5;
-const struct pio led_3 = LPC_GPIO_1_6;
-const struct pio inter0 = LPC_GPIO_0_19;
-const struct pio inter1 = LPC_GPIO_0_20;
-
-/***************************************************************************** */
-void system_init()
-{
-       /* Stop the watchdog */
-       startup_watchdog_disable(); /* Do it right now, before it gets a chance to break in */
-       system_set_default_power_state();
-       system_brown_out_detection_config(0); /* No ADC used */
-       clock_config(SELECTED_FREQ);
-       set_pins(common_pins);
-       gpio_on();
-       status_led_config(&status_led_green, &status_led_red);
-       /* System tick timer MUST be configured and running in order to use the sleeping
-        * functions */
-       systick_timer_on(1); /* 1ms */
-       systick_start();
-}
-
-/* Define our fault handler. This one is not mandatory, the dummy fault handler
- * will be used when it's not overridden here.
- * Note : The default one does a simple infinite loop. If the watchdog is deactivated
- * the system will hang.
- */
-void fault_info(const char* name, uint32_t len)
-{
-       uprintf(UART0, name);
-       while (1);
-}
-
-
-/***************************************************************************** */
-extern void uart_cmd(uint8_t c);
-extern void debug_cmd(uint8_t c);
-void modules_config(void)
-{
-       uart_on(UART0, 115200, uart_cmd);
-       uart_on(UART1, 115200, debug_cmd);
-       i2c_on(I2C0, I2C_CLK_100KHz, I2C_MASTER);
-       ssp_master_on(0, LPC_SSP_FRAME_SPI, 8, 4*1000*1000);
-
-       /* RS485 config */
-       if (1) {
-               uint32_t rs485_ctrl = LPC_RS485_ENABLE;
-               uint8_t addr = 0, delay = 1;
-               rs485_ctrl |= LPC_RS485_DIR_PIN_RTS | LPC_RS485_AUTO_DIR_EN | LPC_RS485_DIR_CTRL_INV;
-               uart_set_mode_rs485(UART0, rs485_ctrl, addr, delay);
-               config_gpio(&rs485_rxen, 0, GPIO_DIR_OUT, 0);
-       }
-}
-
-/***************************************************************************** */
-void env_sensors_config(uint32_t uart)
-{
-       /* Configure environnement sensors */
-       bme_config(uart);
-       uv_config(uart);
-       lux_config(uart);
-}
-
-
-/***************************************************************************** */
-extern void inter_callback(uint32_t gpio);
-void board_io_config(void)
-{
-       /* Configure shutters command pins : Output and default state high (free) */
-       config_gpio(&cmd_shutters_down, 0, GPIO_DIR_OUT, 1);
-       config_gpio(&cmd_shutters_up, 0, GPIO_DIR_OUT, 1);
-       /* Configure 12V leds command pins */
-       config_gpio(&led_0, 0, GPIO_DIR_OUT, 0);
-       config_gpio(&led_1, 0, GPIO_DIR_OUT, 0);
-       config_gpio(&led_2, 0, GPIO_DIR_OUT, 0);
-       config_gpio(&led_3, 0, GPIO_DIR_OUT, 0);
-       /* NOTE : Setting to both edges in case buttons are switchs instead of push */
-       set_gpio_callback(inter_callback, &inter0, EDGES_BOTH);
-       set_gpio_callback(inter_callback, &inter1, EDGES_BOTH);
-}
-
-
-
-/***************************************************************************** */
-/* microSD card init */
-void uSD_config(void)
-{
-       memcpy(&(micro_sd.chip_select), &(uSD_cs), sizeof(struct pio));
-       micro_sd.ssp_bus_num = SSP_BUS_0;
-}
-
-
-/***************************************************************************** */
-/* RTC init */
-#define RTC_ADDR   0xA2
-void time_config()
-{
-       rtc_conf.bus_num = I2C0;
-       rtc_conf.addr = RTC_ADDR;
-}
-
-
-/***************************************************************************** */
-/* Configure external components */
-void external_config(uint32_t uart)
-{
-       /* Configure environnement sensors */
-       env_sensors_config(uart);
-
-       /* Configure GPIO for specific board usage */
-       board_io_config();
-
-       /* microSD card configure and check presence */
-       uSD_config();
-       uSD_detect(uart);
-
-       /* RTC config */
-       time_config();
-       time_init_check(uart);
-}
diff --git a/apps/blyes/inter_lights/config.h b/apps/blyes/inter_lights/config.h
deleted file mode 100644 (file)
index 7b8a254..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-/****************************************************************************
- *   apps/blyes/inter_lights/config.h
- *
- * Copyright 2018 Nathael Pajani <nathael.pajani@ed3l.fr>
- *
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- *************************************************************************** */
-
-#ifndef CONFIG_H
-#define CONFIG_H
-
-#include "core/system.h"
-#include "core/pio.h"
-
-
-#define SELECTED_FREQ  FREQ_SEL_48MHz
-
-/***************************************************************************** */
-/* Pins configuration */
-extern const struct pio status_led_green;
-extern const struct pio status_led_red;
-
-extern const struct pio rs485_rxen;
-
-extern const struct pio cmd_shutters_up;
-extern const struct pio cmd_shutters_down;
-extern const struct pio led_0;
-extern const struct pio led_1;
-extern const struct pio led_2;
-extern const struct pio led_3;
-
-extern const struct pio inter0;
-extern const struct pio inter1;
-
-enum load_changes_and_states {
-    NO_CHANGE = 0,
-    LOAD_TURN_ON,
-    LOAD_TURN_OFF,
-    LOAD_TOGGLE,
-    LOAD_ON,
-    LOAD_OFF,
-};
-
-enum inter_configs {
-    CONFIG_PUSH,
-    CONFIG_SWITCH,
-};
-
-enum gpio_numbers {
-    INTER0_GPIO_NUM = 19,
-    INTER1_GPIO_NUM = 20,
-};
-
-
-/***************************************************************************** */
-/* Configuration */
-
-/* Configure the watchdog, clocks, systick, power and common pins */
-void system_init();
-
-/* Define our fault handler. This one is not mandatory, the dummy fault handler
- * will be used when it's not overridden here.
- * Note : The default one does a simple infinite loop. If the watchdog is deactivated
- * the system will hang.
- */
-void fault_info(const char* name, uint32_t len);
-
-
-/* Configure modules and main functions */
-void modules_config(void);
-
-/* Configure GPIO for specific board usage */
-void board_io_config(void);
-
-/* Configure external components */
-void external_config(uint32_t uart);
-
-
-#endif /* CONFIG_H */
-
diff --git a/apps/blyes/inter_lights/main.c b/apps/blyes/inter_lights/main.c
deleted file mode 100644 (file)
index 2fdcc96..0000000
+++ /dev/null
@@ -1,231 +0,0 @@
-/****************************************************************************
- *   apps/blyes/inter_lights/main.c
- *
- * Copyright 2018 Nathael Pajani <nathael.pajani@ed3l.fr>
- *
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- *************************************************************************** */
-
-#include "core/system.h"
-
-#include "drivers/serial.h"
-#include "drivers/gpio.h"
-
-#include "extdrv/status_led.h"
-#include "extdrv/sdmmc.h"
-
-#include "lib/stdio.h"
-#include "lib/errno.h"
-#include "lib/utils.h"
-
-#include "sensors.h"
-#include "config.h"
-#include "uSD.h"
-#include "time.h"
-
-
-
-#define MODULE_VERSION   0x01
-#define MODULE_NAME "Inter Lights"
-
-#define TEST_VERSION 0x0A
-
-#define INTER0_CONFIG CONFIG_PUSH
-#define INTER1_CONFIG CONFIG_PUSH
-
-/* Declare buffer for MMC data access */
-uint8_t mmc_data[MMC_BUF_SIZE];
-
-/* RTC time */
-struct rtc_time now;
-
-volatile uint8_t cmd_up = 0;
-volatile uint8_t cmd_down = 0;
-void uart_cmd(uint8_t c)
-{
-       serial_send_quickbyte(UART1, c);
-       switch (c) {
-               case '0':
-                       cmd_up = 0;
-                       cmd_down = 0;
-                       break;
-               case '1':
-                       cmd_up = 1;
-                       cmd_down = 1;
-                       break;
-               case 'u':
-                       cmd_up = 0;
-                       cmd_down = 1;
-                       break;
-               case 'd':
-                       cmd_up = 1;
-                       cmd_down = 0;
-                       break;
-               case 'g':
-                       gpio_toggle(led_0);
-                       break;
-               case 'h':
-                       gpio_toggle(led_1);
-                       break;
-               case 'j':
-                       gpio_toggle(led_2);
-                       break;
-               case 'k':
-                       gpio_toggle(led_3);
-                       break;
-       }
-
-}
-
-void debug_cmd(uint8_t c)
-{
-       serial_send_quickbyte(UART0, c);
-}
-
-volatile uint8_t inter0_request = NO_CHANGE;
-volatile uint8_t inter1_request = NO_CHANGE;
-uint8_t led_0_state = LOAD_OFF;
-uint8_t led_1_state = LOAD_OFF;
-uint8_t led_2_state = LOAD_OFF;
-uint8_t led_3_state = LOAD_OFF;
-void inter_callback(uint32_t gpio)
-{
-       switch (gpio) {
-               case INTER0_GPIO_NUM:
-                       if (INTER0_CONFIG == CONFIG_SWITCH) {
-                               if (gpio_read(inter0) == 0) {
-                                       inter0_request = LOAD_TURN_ON;
-                               } else {
-                                       inter0_request = LOAD_TURN_OFF;
-                               }
-                       } else {
-                               if (gpio_read(inter0) != 0) {
-                                       inter0_request = LOAD_TOGGLE;
-                               }
-                       }
-                       break;
-
-               case INTER1_GPIO_NUM:
-                       if (INTER1_CONFIG == CONFIG_SWITCH) {
-                               if (gpio_read(inter1) == 0) {
-                                       inter1_request = LOAD_TURN_ON;
-                               } else {
-                                       inter1_request = LOAD_TURN_OFF;
-                               }
-                       } else {
-                               if (gpio_read(inter1) != 0) {
-                                       inter1_request = LOAD_TOGGLE;
-                               }
-                       }
-                       break;
-       }
-}
-
-
-/***************************************************************************** */
-int main(void)
-{
-       uint8_t cmd_up_old = 0, cmd_down_old = 0;
-
-       /* Configure the watchdog, clocks, systick, power and common pins */
-       system_init();
-       /* Configure modules and main functions */
-       modules_config();
-
-       uprintf(UART0, "Test version %d\n", TEST_VERSION);
-
-       /* Configure GPIO for specific board usage */
-       board_io_config();
-
-       /* Configure external components */
-       external_config(UART0);
-
-       status_led(green_only);
-
-       while (1) {
-#if 0
-               bme_display(UART0);
-               uv_display(UART0);
-               lux_display(UART0);
-#endif
-               msleep(25);
-               status_led(none);
-
-               /* Handle shutters */
-               if (cmd_up != cmd_up_old) {
-                       uprintf(UART0, "Up changed to %d\n", cmd_up);
-                       cmd_up_old = cmd_up;
-               }
-               if (cmd_down != cmd_down_old) {
-                       uprintf(UART0, "Down changed to %d\n", cmd_down);
-                       cmd_down_old = cmd_down;
-               }
-               if (cmd_up == 1) {
-                       gpio_set(cmd_shutters_up);
-               } else {
-                       gpio_clear(cmd_shutters_up);
-               }
-               if (cmd_down == 1) {
-                       gpio_set(cmd_shutters_down);
-               } else {
-                       gpio_clear(cmd_shutters_down);
-               }
-
-               /* Handle lights */
-               switch (inter0_request) {
-                       case LOAD_TURN_ON:
-                               uprintf(UART0, "Inter ON\n");
-                               gpio_set(led_0);
-                               gpio_set(led_1);
-                               gpio_set(led_2);
-                               gpio_set(led_3);
-                               led_0_state = LOAD_ON;
-                               break;
-
-                       case LOAD_TURN_OFF:
-                               uprintf(UART0, "Inter OFF\n");
-                               gpio_clear(led_0);
-                               gpio_clear(led_1);
-                               gpio_clear(led_2);
-                               gpio_clear(led_3);
-                               led_0_state = LOAD_OFF;
-                               break;
-
-                       case LOAD_TOGGLE:
-                               if (led_0_state == LOAD_ON) {
-                                       uprintf(UART0, "Inter OFF\n");
-                                       gpio_clear(led_0);
-                                       gpio_clear(led_1);
-                                       gpio_clear(led_2);
-                                       gpio_clear(led_3);
-                                       led_0_state = LOAD_OFF;
-                               } else {
-                                       uprintf(UART0, "Inter ON\n");
-                                       gpio_set(led_0);
-                                       gpio_set(led_1);
-                                       gpio_set(led_2);
-                                       gpio_set(led_3);
-                                       led_0_state = LOAD_ON;
-                               }
-                               break;
-               }
-               inter0_request = NO_CHANGE;
-       }
-       return 0;
-}
-
-
-
diff --git a/apps/blyes/inter_lights/sensors.c b/apps/blyes/inter_lights/sensors.c
deleted file mode 100644 (file)
index c73a177..0000000
+++ /dev/null
@@ -1,156 +0,0 @@
-/****************************************************************************
- *   apps/blyes/inter_lights/sensors.c
- *
- * Copyright 2018 Nathael Pajani <nathael.pajani@ed3l.fr>
- *
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- *************************************************************************** */
-
-#include "core/system.h"
-#include "lib/stdio.h"
-#include "drivers/serial.h"
-#include "drivers/i2c.h"
-#include "extdrv/bme280_humidity_sensor.h"
-#include "extdrv/veml6070_uv_sensor.h"
-#include "extdrv/tsl256x_light_sensor.h"
-
-
-
-/***************************************************************************** */
-/* Luminosity */
-
-/* Note : These are 8bits address */
-#define TSL256x_ADDR   0x52 /* Pin Addr Sel (pin2 of tsl256x) connected to GND */
-struct tsl256x_sensor_config tsl256x_sensor = {
-       .bus_num = I2C0,
-       .addr = TSL256x_ADDR,
-       .gain = TSL256x_LOW_GAIN,
-       .integration_time = TSL256x_INTEGRATION_100ms,
-       .package = TSL256x_PACKAGE_T,
-};
-
-void lux_config(int uart_num)
-{
-       int ret = 0;
-       ret = tsl256x_configure(&tsl256x_sensor);
-       if (ret != 0) {
-               uprintf(uart_num, "Lux config error: %d\n", ret);
-       }
-}
-
-void lux_display(int uart_num)
-{
-       uint16_t comb = 0, ir = 0;
-       uint32_t lux = 0;
-       int ret = 0;
-
-       ret = tsl256x_sensor_read(&tsl256x_sensor, &comb, &ir, &lux);
-       if (ret != 0) {
-               uprintf(uart_num, "Lux read error: %d\n", ret);
-       } else {
-               uprintf(uart_num, "Lux: %d  (Comb: 0x%04x, IR: 0x%04x)\n", lux, comb, ir);
-       }
-}
-
-
-
-/***************************************************************************** */
-/* BME280 Sensor */
-
-/* Note : 8bits address */
-#define BME280_ADDR   0xEC
-struct bme280_sensor_config bme280_sensor = {
-       .bus_num = I2C0,
-       .addr = BME280_ADDR,
-       .humidity_oversampling = BME280_OS_x16,
-       .temp_oversampling = BME280_OS_x16,
-       .pressure_oversampling = BME280_OS_x16,
-       .mode = BME280_NORMAL,
-       .standby_len = BME280_SB_62ms,
-       .filter_coeff = BME280_FILT_OFF,
-};
-
-void bme_config(int uart_num)
-{
-       int ret = 0;
-
-       ret = bme280_configure(&bme280_sensor);
-       if (ret != 0) {
-               uprintf(uart_num, "Sensor config error: %d\n", ret);
-       }
-}
-
-void bme_display(int uart_num)
-{
-       uint32_t pressure = 0, temp = 0;
-       uint16_t humidity = 0;
-       int ret = 0;
-
-       ret = bme280_sensor_read(&bme280_sensor, &pressure, &temp, &humidity);
-       if (ret != 0) {
-               uprintf(uart_num, "Sensor read error: %d\n", ret);
-       } else {
-               int comp_temp = 0;
-               uint32_t comp_pressure = 0;
-               uint32_t comp_humidity = 0;
-
-               comp_temp = bme280_compensate_temperature(&bme280_sensor, temp) / 10;
-               comp_pressure = bme280_compensate_pressure(&bme280_sensor, pressure) / 100;
-               comp_humidity = bme280_compensate_humidity(&bme280_sensor, humidity) / 10;
-               uprintf(uart_num, "P: %d hPa, T: %d,%02d degC, H: %d,%d rH\n",
-                               comp_pressure,
-                               comp_temp / 10,  (comp_temp > 0) ? (comp_temp % 10) : ((-comp_temp) % 10),
-                               comp_humidity / 10, comp_humidity % 10);
-       }
-}
-
-/***************************************************************************** */
-/* UV */
-
-/* The I2C UV light sensor is at addresses 0x70, 0x71 and 0x73 */
-/* Note : These are 8bits address */
-#define VEML6070_ADDR   0x70
-struct veml6070_sensor_config veml6070_sensor = {
-       .bus_num = I2C0,
-       .addr = VEML6070_ADDR,
-};
-
-void uv_config(int uart_num)
-{
-       int ret = 0;
-
-       /* UV sensor */
-       ret = veml6070_configure(&veml6070_sensor);
-       if (ret != 0) {
-               uprintf(uart_num, "UV config error: %d\n", ret);
-       }
-}
-
-void uv_display(int uart_num)
-{
-       uint16_t uv_raw = 0;
-       int ret = 0;
-
-       ret = veml6070_sensor_read(&veml6070_sensor, &uv_raw);
-       if (ret != 0) {
-               uprintf(uart_num, "UV read error: %d\n", ret);
-       } else {
-               uprintf(uart_num, "UV: 0x%04x\n", uv_raw);
-       }
-}
-
-
-
diff --git a/apps/blyes/inter_lights/sensors.h b/apps/blyes/inter_lights/sensors.h
deleted file mode 100644 (file)
index e029752..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/****************************************************************************
- *   apps/blyes/inter_lights/sensors.h
- *
- * Copyright 2018 Nathael Pajani <nathael.pajani@ed3l.fr>
- *
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- *************************************************************************** */
-
-#ifndef SENSORS_H
-#define SENSORS_H
-
-/***************************************************************************** */
-/* Luminosity */
-void lux_config(int uart_num);
-void lux_display(int uart_num);
-
-/***************************************************************************** */
-/* BME280 Sensor */
-void bme_config(int uart_num);
-void bme_display(int uart_num);
-
-/***************************************************************************** */
-/* UV */
-void uv_config(int uart_num);
-void uv_display(int uart_num);
-
-#endif /* SENSORS_H */
-
diff --git a/apps/blyes/inter_lights/time.c b/apps/blyes/inter_lights/time.c
deleted file mode 100644 (file)
index e507685..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-/****************************************************************************
- *   apps/blyes/inter_lights/time.c
- *
- * Copyright 2018 Nathael Pajani <nathael.pajani@ed3l.fr>
- *
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- *************************************************************************** */
-
-#include "core/system.h"
-
-#include "drivers/serial.h"
-#include "drivers/i2c.h"
-
-#include "lib/stdio.h"
-#include "lib/errno.h"
-
-#include "time.h"
-
-
-/***************************************************************************** */
-/* RTC */
-struct rtc_pcf85363a_config rtc_conf = {
-    .mode = PCF85363A_MODE_RTC,
-    .config_marker = PCF85363A_CONFIGURED_1,
-    .batt_ctrl = PCF85363A_CONF_BATT_TH_2_8V,
-};
-/* Oldest acceptable time in RTC. BCD coded. */
-const struct rtc_time oldest = {
-    .year = 0x18,
-    .month = 0x08,
-    .day = 0x09,
-    .hour = 0x13,
-    .min = 0x37,
-};
-int time_valid = 0;
-int rtc_conf_ok = 0;
-
-int time_init_check(uint32_t uart)
-{
-    int ret = 0;
-    ret = rtc_pcf85363a_config(&rtc_conf);
-       if (ret < 0) {
-               uprintf(uart, "RTC config error: %d\n", ret);
-               return -1;
-       }
-       rtc_conf_ok = 1;
-
-    ret = rtc_pcf85363a_is_up(&rtc_conf, &oldest);
-    if (ret == 1) {
-        /* Time is valid (newer than source code time) */
-        char buff[30];
-        rtc_pcf85363_time_read(&rtc_conf, &now);
-        rtc_pcf85363_time_to_str(&now, buff, 30);
-        /* Debug */
-        uprintf(uart, "Using time from RTC: %s\n", buff);
-        time_valid = 1;
-    } else if (ret == -EFAULT) {
-               /* Time is older than source code time */
-        time_valid = 0;
-               uprintf(uart, "RTC time too old, provide valid time.\n");
-               /* FIXME: remove this, time should come from control master */
-               memcpy(&now, &oldest, sizeof(struct rtc_time));
-               rtc_pcf85363_time_write(&rtc_conf, &now);
-    } else {
-               /* RTC config error */
-               rtc_conf_ok = 0;
-       }
-       return ret;
-}
-
diff --git a/apps/blyes/inter_lights/time.h b/apps/blyes/inter_lights/time.h
deleted file mode 100644 (file)
index 7839390..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/****************************************************************************
- *   apps/blyes/inter_lights/time.h
- *
- * Copyright 2018 Nathael Pajani <nathael.pajani@ed3l.fr>
- *
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- *************************************************************************** */
-
-#ifndef RTC_TIME_H
-#define RTC_TIME_H
-
-#include "extdrv/rtc_pcf85363a.h"
-
-extern struct rtc_pcf85363a_config rtc_conf;
-extern struct rtc_time now;
-
-int time_init_check(uint32_t uart);
-
-
-#endif /* RTC_TIME_H */
-
diff --git a/apps/blyes/inter_lights/uSD.c b/apps/blyes/inter_lights/uSD.c
deleted file mode 100644 (file)
index 6e75957..0000000
+++ /dev/null
@@ -1,118 +0,0 @@
-/****************************************************************************
- *   apps/blyes/inter_lights/uSD.c
- *
- * Copyright 2018 Nathael Pajani <nathael.pajani@ed3l.fr>
- *
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- *************************************************************************** */
-
-#include "core/system.h"
-
-#include "drivers/serial.h"
-#include "drivers/ssp.h"
-
-#include "lib/stdio.h"
-
-#include "uSD.h"
-
-
-/***************************************************************************** */
-/* SD/MMC Card */
-struct sdmmc_card micro_sd = {
-       .card_type = MMC_CARDTYPE_UNKNOWN,
-       .block_size = 16,
-};
-
-static uint8_t got_uSD = 0;
-
-
-/* Read up to 4 blocks of 16 bytes each */
-int uSD_read(uint32_t offset, uint8_t nb_blocks)
-{
-       int i = 0, ret = 0;
-       if (got_uSD == 0) {
-               return -1;
-       }
-       if (nb_blocks > 4) {
-               return -2;
-       }
-       memset(mmc_data, 0, MMC_BUF_SIZE);
-       for (i = 0; i < nb_blocks; i++) {
-               ret = sdmmc_read_block(&micro_sd, (offset + i), (mmc_data + (i * 16)));
-               /* FIXME : check return value */
-       }
-       return 0;
-}
-
-
-/* Write up to 4 blocks of 16 bytes each */
-int uSD_write(uint32_t offset, uint8_t nb_blocks)
-{
-       int i = 0, ret = 0;
-       if (got_uSD == 0) {
-               return -1;
-       }
-       if (nb_blocks > 4) {
-               return -1;
-       }
-       for (i = 0; i < nb_blocks; i++) {
-               ret = sdmmc_write_block(&micro_sd, (offset + i), (mmc_data + (i * 16)));
-               /* FIXME : check return value */
-       }
-       return 0;
-}
-
-/* microSD card init */
-int uSD_detect(int uart)
-{
-       int i = 0, ret = 0;
-       do {
-               ret = sdmmc_init(&micro_sd);
-               if (ret == 0) {
-                       msleep(10);
-                       ret = sdmmc_init_wait_card_ready(&micro_sd);
-                       if (ret == 0) {
-                               ret = sdmmc_init_end(&micro_sd);
-                       }
-               }
-               uprintf(uart, "uSD init(%d): %d, type: %d, bs: %d\n",
-                                               i, ret, micro_sd.card_type, micro_sd.block_size);
-               i++;
-       } while ((ret != 0) && (i < 10)); 
-
-       /* Got uSD ? */
-       if (i >= 10) {
-               uprintf(uart, "uSD init failed, no uSD card present.\n");
-               got_uSD = 0;
-               return -1;
-       }
-
-       /* uSD card detected */
-       got_uSD = 1;
-       /* got_uSD MUST be set to 1 from here on ! */
-       uSD_read(0, 4); /* Read 4 blocks at start of card */
-       /* FIXME : check that the card magic is present */
-       uprintf(uart, "uSD read: %s\n", mmc_data);
-
-       return 0;
-}
-
-
-int uSD_logs_init(int uart)
-{
-       /* FIXME : read 4 blocks at offset FIXME to get the last block used info */
-       return 0;
-}
diff --git a/apps/blyes/inter_lights/uSD.h b/apps/blyes/inter_lights/uSD.h
deleted file mode 100644 (file)
index e96f89e..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/****************************************************************************
- *   apps/blyes/inter_lights/usSD.h
- *
- * Copyright 2018 Nathael Pajani <nathael.pajani@ed3l.fr>
- *
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- *************************************************************************** */
-
-#ifndef USD_H
-#define USD_H
-
-#include "extdrv/sdmmc.h"
-
-#define MMC_BUF_SIZE   64
-
-extern struct sdmmc_card micro_sd;
-extern uint8_t mmc_data[MMC_BUF_SIZE];
-
-int uSD_detect(int uart);
-
-int uSD_read(uint32_t offset, uint8_t nb_blocks);
-int uSD_write(uint32_t offset, uint8_t nb_blocks);
-
-
-#endif /* USD_H */
-
diff --git a/apps/blyes/relay_lights/Makefile b/apps/blyes/relay_lights/Makefile
deleted file mode 100644 (file)
index 41ae555..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-# Makefile for apps
-
-MODULE = $(shell basename $(shell cd .. && pwd && cd -))
-NAME = $(shell basename $(CURDIR))
-
-# Add this to your ~/.vimrc in order to get proper function of :make in vim :
-# let $COMPILE_FROM_IDE = 1
-ifeq ($(strip $(COMPILE_FROM_IDE)),)
-       PRINT_DIRECTORY = --no-print-directory
-else
-       PRINT_DIRECTORY =
-       LANG = C
-endif
-
-.PHONY: $(NAME).bin
-$(NAME).bin:
-       @make -C ../../.. ${PRINT_DIRECTORY} NAME=$(NAME) MODULE=$(MODULE) apps/$(MODULE)/$(NAME)/$@
-
-clean mrproper:
-       @make -C ../../.. ${PRINT_DIRECTORY} $@
-
diff --git a/apps/blyes/relay_lights/README b/apps/blyes/relay_lights/README
deleted file mode 100644 (file)
index 1cce61b..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-Blyes - Inter Lights board
-
-Copyright 2018 Nathael Pajani <nathael.pajani@ed3l.fr>
-
-
-/* ****************************************************************************
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- *************************************************************************** */
-
diff --git a/apps/blyes/relay_lights/config.c b/apps/blyes/relay_lights/config.c
deleted file mode 100644 (file)
index 8fc2626..0000000
+++ /dev/null
@@ -1,167 +0,0 @@
-/****************************************************************************
- *   apps/blyes/relay_lights/config.c
- *
- * Copyright 2018 Nathael Pajani <nathael.pajani@ed3l.fr>
- *
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- *************************************************************************** */
-
-#include "core/system.h"
-#include "core/systick.h"
-#include "core/pio.h"
-
-#include "drivers/serial.h"
-#include "drivers/gpio.h"
-#include "drivers/i2c.h"
-
-#include "extdrv/status_led.h"
-
-#include "lib/stdio.h"
-
-#include "config.h"
-#include "interface.h"
-
-#define SELECTED_FREQ  FREQ_SEL_48MHz
-
-
-uint8_t config_got_interface = 1;
-
-/***************************************************************************** */
-/* Pins configuration */
-/* pins blocks are passed to set_pins() for pins configuration.
- * Unused pin blocks can be removed safely with the corresponding set_pins() call
- * All pins blocks may be safelly merged in a single block for single set_pins() call..
- */
-const struct pio_config common_pins[] = {
-       /* UART 0 */
-       { LPC_UART0_RX_PIO_0_1,  LPC_IO_DIGITAL },
-       { LPC_UART0_TX_PIO_0_2,  LPC_IO_DIGITAL },
-       /* UART 1 */
-       { LPC_UART1_RX_PIO_0_8,  LPC_IO_DIGITAL },
-       { LPC_UART1_TX_PIO_0_9,  LPC_IO_DIGITAL },
-       /* I2C 0 */
-       { LPC_I2C0_SCL_PIO_0_10, (LPC_IO_DIGITAL | LPC_IO_OPEN_DRAIN_ENABLE) },
-       { LPC_I2C0_SDA_PIO_0_11, (LPC_IO_DIGITAL | LPC_IO_OPEN_DRAIN_ENABLE) },
-       /* ADC */
-       { LPC_ADC_AD7_PIO_1_5,  LPC_IO_ANALOG },
-       ARRAY_LAST_PIO,
-};
-
-const struct pio status_light_green = LPC_GPIO_0_26;
-const struct pio status_light_red = LPC_GPIO_0_27;
-
-
-struct load l1 = {
-    .config = CONFIG_PUSH,
-    .change_req = NO_CHANGE,
-    .state = LOAD_OFF,
-    .set = LPC_GPIO_0_29,
-    .release = LPC_GPIO_0_28,
-       .zc_count = 0,
-    .zc = LPC_GPIO_0_5,
-    .inter = LPC_GPIO_0_4,
-};
-
-struct load l2 = {
-    .config = CONFIG_PUSH,
-    .change_req = NO_CHANGE,
-    .state = LOAD_OFF,
-    .set = LPC_GPIO_0_31,
-       .release = LPC_GPIO_0_30,
-       .zc_count = 0,
-       .zc = LPC_GPIO_0_6,
-       .inter = LPC_GPIO_0_7,
-};
-
-
-/***************************************************************************** */
-void system_init()
-{
-       /* Stop the watchdog */
-       startup_watchdog_disable(); /* Do it right now, before it gets a chance to break in */
-       system_set_default_power_state();
-       clock_config(SELECTED_FREQ);
-       set_pins(common_pins);
-       gpio_on();
-       status_led_config(&status_light_green, &status_light_red);
-       /* System tick timer MUST be configured and running in order to use the sleeping
-        * functions */
-       systick_timer_on(1); /* 1ms */
-       systick_start();
-}
-
-/* Define our fault handler. This one is not mandatory, the dummy fault handler
- * will be used when it's not overridden here.
- * Note : The default one does a simple infinite loop. If the watchdog is deactivated
- * the system will hang.
- */
-void fault_info(const char* name, uint32_t len)
-{
-       uprintf(UART0, name);
-       while (1);
-}
-
-
-/***************************************************************************** */
-extern void uart_cmd(uint8_t c);
-extern void debug_cmd(uint8_t c);
-void modules_config(void)
-{
-       uart_on(UART0, 115200, debug_cmd);
-       uart_on(UART1, 115200, uart_cmd);
-       i2c_on(I2C0, I2C_CLK_100KHz, I2C_MASTER);
-}
-
-
-/***************************************************************************** */
-extern void zc_callback(uint32_t gpio);
-extern void inter_callback(uint32_t gpio);
-void board_io_config(void)
-{
-       /* Configure load command pins */
-       config_gpio(&(l1.set), 0, GPIO_DIR_OUT, 0);
-       config_gpio(&(l2.set), 0, GPIO_DIR_OUT, 0);
-       config_gpio(&(l1.release), 0, GPIO_DIR_OUT, 0);
-       config_gpio(&(l2.release), 0, GPIO_DIR_OUT, 0);
-
-       /* Configure Inputs */
-       set_gpio_callback(zc_callback, &(l1.zc), EDGE_RISING);
-       set_gpio_callback(zc_callback, &(l2.zc), EDGE_RISING);
-       /* NOTE : Setting to both edges in case buttons are switchs instead of push */
-       set_gpio_callback(inter_callback, &(l1.inter), EDGES_BOTH);
-       set_gpio_callback(inter_callback, &(l2.inter), EDGES_BOTH);
-}
-
-
-
-/***************************************************************************** */
-/* Configure external components */
-int external_config(uint32_t uart)
-{
-       int ret = 0;
-       /* Configure GPIO for specific board usage */
-       board_io_config();
-       if (config_got_interface == 1) {
-               ret = interface_config(uart);
-       } else {
-               system_brown_out_detection_config(0); /* No ADC used */
-       }
-       if (ret != 0) {
-               system_brown_out_detection_config(0); /* No ADC used */
-               return -1;
-       }
-       return 0;
-}
diff --git a/apps/blyes/relay_lights/config.h b/apps/blyes/relay_lights/config.h
deleted file mode 100644 (file)
index 547bee3..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-/****************************************************************************
- *   apps/blyes/relay_lights/config.h
- *
- * Copyright 2018 Nathael Pajani <nathael.pajani@ed3l.fr>
- *
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- *************************************************************************** */
-
-#ifndef CONFIG_H
-#define CONFIG_H
-
-#include "core/system.h"
-#include "core/pio.h"
-
-
-
-/***************************************************************************** */
-/* Pins configuration */
-enum inter_configs {
-    CONFIG_PUSH,
-    CONFIG_SWITCH,
-};
-
-struct load {
-    struct pio set;
-    struct pio release;
-    struct pio zc;
-    struct pio inter;
-       uint32_t zc_count;
-    uint8_t config;
-    volatile uint8_t change_req;
-    volatile uint8_t state;
-};
-extern struct load l1;
-extern struct load l2;
-
-enum load_changes_and_states {
-    NO_CHANGE = 0,
-    LOAD_TURN_ON,
-    LOAD_TURN_OFF,
-    LOAD_TOGGLE,
-    LOAD_ON,
-    LOAD_OFF,
-};
-
-enum gpio_numbers {
-       ZC1_GPIO_NUM = 5,
-       INTER1_GPIO_NUM = 4,
-       ZC2_GPIO_NUM = 6,
-       INTER2_GPIO_NUM = 7,
-};
-
-/***************************************************************************** */
-/* Configuration */
-
-/* Configure the watchdog, clocks, systick, power and common pins */
-void system_init();
-
-/* Define our fault handler. This one is not mandatory, the dummy fault handler
- * will be used when it's not overridden here.
- * Note : The default one does a simple infinite loop. If the watchdog is deactivated
- * the system will hang.
- */
-void fault_info(const char* name, uint32_t len);
-
-
-/* Configure modules and main functions */
-void modules_config(void);
-
-/* Configure GPIO for specific board usage */
-void board_io_config(void);
-
-/* Configure external components */
-int external_config(uint32_t uart);
-
-
-#endif /* CONFIG_H */
-
diff --git a/apps/blyes/relay_lights/interface.c b/apps/blyes/relay_lights/interface.c
deleted file mode 100644 (file)
index 00d9760..0000000
+++ /dev/null
@@ -1,223 +0,0 @@
-/****************************************************************************
- *   apps/blyes/relay_lights/interface.c
- *
- * Copyright 2018 Nathael Pajani <nathael.pajani@ed3l.fr>
- *
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- *************************************************************************** */
-
-#include "core/system.h"
-#include "core/systick.h"
-#include "core/pio.h"
-
-#include "drivers/serial.h"
-#include "drivers/gpio.h"
-#include "drivers/i2c.h"
-#include "drivers/adc.h"
-
-#include "extdrv/status_led.h"
-#include "extdrv/ws2812.h"
-#include "extdrv/tmp101_temp_sensor.h"
-#include "extdrv/ssd130x_oled_driver.h"
-#include "extdrv/ssd130x_oled_buffer.h"
-
-#include "lib/stdio.h"
-#include "lib/font.h"
-#include "lib/time.h"
-
-#include "interface.h"
-
-/***************************************************************************** */
-/* Buttons inputs on front panel */
-const struct pio button_up = LPC_GPIO_0_25;
-const struct pio button_right = LPC_GPIO_0_24;
-const struct pio button_left = LPC_GPIO_0_23;
-const struct pio button_down = LPC_GPIO_0_22;
-/* ISP  /User button OK */
-const struct pio button_ok = LPC_GPIO_0_12;
-
-/* Led control data pin */
-const struct pio ws2812_data_out_pin = LPC_GPIO_0_21;
-
-
-static uint8_t interface_board_present = 0;
-
-/***************************************************************************** */
-/* TMP101 onboard I2C temperature sensor */
-#define TMP101_ADDR  0x94  /* Pin Addr0 (pin5 of tmp101) connected to VCC */
-struct tmp101_sensor_config tmp101_sensor = {
-       .bus_num = I2C0,
-       .addr = TMP101_ADDR,
-       .resolution = TMP_RES_ELEVEN_BITS,
-};
-
-/***************************************************************************** */
-/* Oled Display */
-static uint8_t gddram[ 4 + GDDRAM_SIZE ];
-
-#define DISPLAY_ADDR   0x78
-struct oled_display display = {
-       .bus_type = SSD130x_BUS_I2C,
-       .address = DISPLAY_ADDR,
-       .bus_num = I2C0,
-       .charge_pump = SSD130x_EXT_VCC,
-       .video_mode = SSD130x_DISP_NORMAL,
-       .contrast = 128,
-       .scan_dir = SSD130x_SCAN_BOTTOM_TOP,
-       .read_dir = SSD130x_RIGHT_TO_LEFT,
-       .display_offset_dir = SSD130x_MOVE_TOP,
-       .display_offset = 4,
-       .gddram = gddram,
-};
-
-#define ROW(x)   VERTICAL_REV(x)
-DECLARE_FONT(font);
-
-void display_char(uint8_t line, uint8_t col, uint8_t c)
-{
-       uint8_t tile = (c > FIRST_FONT_CHAR) ? (c - FIRST_FONT_CHAR) : 0;
-       uint8_t* tile_data = (uint8_t*)(&font[tile]);
-       ssd130x_buffer_set_tile(gddram, col, line, tile_data);
-}
-int display_line(uint8_t line, uint8_t col, char* text)
-{
-       int len = strlen((char*)text);
-       int i = 0, ret = 0;
-
-       if (interface_board_present == 0) {
-               return -1;
-       }
-
-       for (i = 0; i < len; i++) {
-               uint8_t tile = (text[i] > FIRST_FONT_CHAR) ? (text[i] - FIRST_FONT_CHAR) : 0;
-               uint8_t* tile_data = (uint8_t*)(&font[tile]);
-               ssd130x_buffer_set_tile(gddram, col++, line, tile_data);
-               if (col >= (OLED_LINE_CHAR_LENGTH)) {
-                       col = 0;
-                       line++;
-                       if (line >= SSD130x_NB_PAGES) {
-                               len = i;
-                               break;
-                       }
-               }
-       }
-       /* Update Oled display */
-       ret = ssd130x_display_full_screen(&display);
-       if (ret != 0) {
-               return ret;
-       }
-       return len;
-}
-
-int erase_line(uint8_t line)
-{
-       uint8_t* tile_data = (uint8_t*)(&font[0]);
-       uint8_t col = 0;
-       int i = 0, ret = 0;
-
-       if (interface_board_present == 0) {
-               return -1;
-       }
-
-       for (i = 0; i < OLED_LINE_CHAR_LENGTH; i++) {
-               ssd130x_buffer_set_tile(gddram, col++, line, tile_data);
-       }
-       /* Update Oled display */
-       ret = ssd130x_display_full_screen(&display);
-       if (ret != 0) {
-               return ret;
-       }
-       return 0;
-}
-
-
-int temp_display(uint32_t uart, uint8_t line_num)
-{
-       char line[DISPLAY_LINE_LENGTH];
-       int tmp101_deci_degrees = 0;
-       int abs_deci = 0;
-       int ret = 0;
-
-       if (interface_board_present == 0) {
-               return -1;
-       }
-
-       tmp101_sensor_start_conversion(&tmp101_sensor);
-       msleep(15);
-       ret = tmp101_sensor_read(&tmp101_sensor, NULL, &tmp101_deci_degrees);
-       if (ret != 0) {
-               uprintf(uart, "TMP101 read error : %d\n", ret);
-               return ret;
-       }
-       if (tmp101_deci_degrees < 0) {
-               abs_deci = -tmp101_deci_degrees;
-       } else {
-               abs_deci = tmp101_deci_degrees;
-       }
-       uprintf(uart, "Internal Temp : % 4d.%02d\n", (tmp101_deci_degrees / 10), (abs_deci % 10));
-       snprintf(line, DISPLAY_LINE_LENGTH, "T:% 2d.%02d %cC", (tmp101_deci_degrees / 10), (abs_deci % 10), 0x1F);
-       display_line(line_num, 0, line);
-       return 0;
-}
-
-/***************************************************************************** */
-void button_callback(uint32_t gpio)
-{
-}
-
-int interface_config(uint32_t uart)
-{
-       int ret = 0;
-       char line[DISPLAY_LINE_LENGTH];
-
-       /* TMP101 sensor config */
-       ret = tmp101_sensor_config(&tmp101_sensor);
-       if (ret != 0) {
-               uprintf(uart, "Temp config error: %d\n", ret);
-               interface_board_present = 0;
-               return -1;
-       }
-       interface_board_present = 1;
-
-       /* Buttons inputs on front panel */
-       /* Activate on Rising edge (button release) */
-       set_gpio_callback(button_callback, &button_up, EDGE_RISING);
-       set_gpio_callback(button_callback, &button_left, EDGE_RISING);
-       set_gpio_callback(button_callback, &button_right, EDGE_RISING);
-       set_gpio_callback(button_callback, &button_down, EDGE_RISING);
-       set_gpio_callback(button_callback, &button_ok, EDGE_RISING);
-
-       adc_on(NULL);
-
-       /* WS2812B Leds on display board */
-       ws2812_config(&ws2812_data_out_pin);
-
-       /* Configure and start display */
-       ret = ssd130x_display_on(&display);
-       /* Erase screen */
-       ssd130x_buffer_set(gddram, 0x00);
-       ret = ssd130x_display_full_screen(&display);
-
-       ws2812_set_pixel(0, 0x05, 0x15, 0x08);
-       ws2812_send_frame(0);
-
-       snprintf(line, DISPLAY_LINE_LENGTH, "System config OK");
-       display_line(2, 0, line);
-
-       return 0;
-}
-
-
diff --git a/apps/blyes/relay_lights/interface.h b/apps/blyes/relay_lights/interface.h
deleted file mode 100644 (file)
index c939bfd..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/****************************************************************************
- *   apps/blyes/relay_lights/interface.h
- *
- * Copyright 2018 Nathael Pajani <nathael.pajani@ed3l.fr>
- *
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- *************************************************************************** */
-
-#ifndef INTERFACE_H
-#define INTERFACE_H
-
-#include "core/system.h"
-#include "core/pio.h"
-
-#include "extdrv/ssd130x_oled_driver.h"
-
-#define OLED_LINE_CHAR_LENGTH  (SSD130x_NB_COL / 8)
-#define DISPLAY_LINE_LENGTH  (OLED_LINE_CHAR_LENGTH + 1)
-
-
-/***************************************************************************** */
-/* Pins configuration */
-/* Buttons inputs on front panel */
-extern const struct pio button_up;
-extern const struct pio button_left;
-extern const struct pio button_right;
-extern const struct pio button_down;
-extern const struct pio button_ok;
-
-/***************************************************************************** */
-/* Configuration */
-/* Configure interface board */
-int interface_config(uint32_t uart);
-
-int display_line(uint8_t line_num, uint8_t col, char* text);
-int erase_line(uint8_t line_num);
-
-int temp_display(uint32_t uart, uint8_t line_num);
-
-#endif /* INTERFACE_H */
-
diff --git a/apps/blyes/relay_lights/main.c b/apps/blyes/relay_lights/main.c
deleted file mode 100644 (file)
index e1caadf..0000000
+++ /dev/null
@@ -1,194 +0,0 @@
-/****************************************************************************
- *   apps/blyes/relay_lights/main.c
- *
- * Copyright 2018 Nathael Pajani <nathael.pajani@ed3l.fr>
- *
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- *************************************************************************** */
-
-#include "core/system.h"
-
-#include "drivers/serial.h"
-#include "drivers/gpio.h"
-
-#include "extdrv/status_led.h"
-#include "extdrv/sdmmc.h"
-
-#include "lib/stdio.h"
-#include "lib/errno.h"
-#include "lib/utils.h"
-
-#include "config.h"
-#include "interface.h"
-
-
-#define MODULE_VERSION   0x01
-#define MODULE_NAME "Relay Lights"
-
-#define TEST_VERSION 0x01
-
-
-
-void uart_cmd(uint8_t c)
-{
-       serial_send_quickbyte(UART0, c);
-       switch (c) {
-               case '0':
-                       break;
-               case '1':
-                       break;
-               case 'j':
-                       break;
-               case 'k':
-                       break;
-       }
-}
-
-void debug_cmd(uint8_t c)
-{
-       serial_send_quickbyte(UART1, c);
-}
-
-struct load* load_select(uint32_t gpio)
-{
-       switch (gpio) {
-               case ZC1_GPIO_NUM:
-               case INTER1_GPIO_NUM:
-                       return &l1;
-
-               case ZC2_GPIO_NUM:
-               case INTER2_GPIO_NUM:
-                       return &l2;
-       }
-       return NULL;
-}
-
-
-void zc_callback(uint32_t gpio)
-{
-       struct load* ltmp = load_select(gpio);
-       if (ltmp != NULL) {
-               ltmp->zc_count++;
-               ltmp->state = LOAD_ON;
-       }
-}
-
-
-void inter_callback(uint32_t gpio)
-{
-       struct load* ltmp = load_select(gpio);
-       if (ltmp == NULL) {
-               return;
-       }
-       
-       /* Request load 1 state change ? */
-       if (ltmp->config == CONFIG_SWITCH) {
-               if (gpio_read(ltmp->inter) != 0) {
-                       ltmp->change_req = LOAD_TURN_ON;
-               } else {
-                       ltmp->change_req = LOAD_TURN_OFF;
-               }
-       } else { /* CONFIG_PUSH : Request load 1 state toggle */
-               if (gpio_read(ltmp->inter) != 0) {
-                       if (ltmp->state == LOAD_ON) {
-                               ltmp->change_req = LOAD_TURN_OFF;
-                       } else {
-                               ltmp->change_req = LOAD_TURN_ON;
-                       }
-               }
-       }
-}
-
-
-void update_load(struct load* ltmp)
-{
-       switch (ltmp->change_req) {
-               case LOAD_TURN_ON:
-                       gpio_set(ltmp->set);
-                       msleep(5);
-                       gpio_clear(ltmp->set);
-                       ltmp->state = LOAD_ON;
-                       break;
-
-               case LOAD_TURN_OFF:
-                       gpio_set(ltmp->release);
-                       msleep(5);
-                       gpio_clear(ltmp->release);
-                       ltmp->state = LOAD_OFF;
-                       break;
-       }
-       ltmp->change_req = NO_CHANGE;
-}
-
-/***************************************************************************** */
-int main(void)
-{
-       char line[DISPLAY_LINE_LENGTH];
-       int cnt = 0, ret = 0;
-
-       /* Configure the watchdog, clocks, systick, power and common pins */
-       system_init();
-       /* Configure modules and main functions */
-       modules_config();
-
-       uprintf(UART0, "Test version %d\n", TEST_VERSION);
-
-       /* Configure GPIO for specific board usage */
-       board_io_config();
-
-       /* Configure external components */
-       ret = external_config(UART0);
-       if (ret != 0) {
-               uprintf(UART0, "No interface board detected.\n");
-       }
-       uprintf(UART0, "System config OK\n");
-
-       status_led(green_only);
-
-       while (1) {
-               msleep(250);
-
-               if (l1.change_req != NO_CHANGE) {
-                       update_load(&l1);
-                       snprintf(line, DISPLAY_LINE_LENGTH, "Changed L1");
-                       display_line(4, 0, line);
-                       uprintf(UART0, "Changed L1 to %s\n",
-                               (l1.state == LOAD_ON)?"On":"Off");
-                       cnt = 0;
-               }
-               if (l2.change_req != NO_CHANGE) {
-                       update_load(&l2);
-                       snprintf(line, DISPLAY_LINE_LENGTH, "Changed L2");
-                       display_line(4, 0, line);
-                       uprintf(UART0, "Changed L2 to %s\n",
-                               (l2.state == LOAD_ON)?"On":"Off");
-                       cnt = 0;
-               }
-
-               temp_display(UART0, 6);
-               snprintf(line, DISPLAY_LINE_LENGTH, "L1: %d, L2: %d", l1.zc_count, l2.zc_count);
-               display_line(5, 0, line);
-               if (cnt++ >= 10) {
-                       erase_line(4);
-                       cnt = 0;
-               }
-               uprintf(UART1, "Test version %d\n", TEST_VERSION);
-       }
-       return 0;
-}
-
-
-
diff --git a/apps/cape_rccar/rccar/Makefile b/apps/cape_rccar/rccar/Makefile
deleted file mode 100644 (file)
index 41ae555..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-# Makefile for apps
-
-MODULE = $(shell basename $(shell cd .. && pwd && cd -))
-NAME = $(shell basename $(CURDIR))
-
-# Add this to your ~/.vimrc in order to get proper function of :make in vim :
-# let $COMPILE_FROM_IDE = 1
-ifeq ($(strip $(COMPILE_FROM_IDE)),)
-       PRINT_DIRECTORY = --no-print-directory
-else
-       PRINT_DIRECTORY =
-       LANG = C
-endif
-
-.PHONY: $(NAME).bin
-$(NAME).bin:
-       @make -C ../../.. ${PRINT_DIRECTORY} NAME=$(NAME) MODULE=$(MODULE) apps/$(MODULE)/$(NAME)/$@
-
-clean mrproper:
-       @make -C ../../.. ${PRINT_DIRECTORY} $@
-
diff --git a/apps/cape_rccar/rccar/main.c b/apps/cape_rccar/rccar/main.c
deleted file mode 100644 (file)
index 4d3ae8d..0000000
+++ /dev/null
@@ -1,729 +0,0 @@
-/****************************************************************************
- *   apps/dev/rccar/main.c
- *
- * Micro-controller support for the RC-Car Cape for BeagleBone Black
- *
- * Copyright 2016 Nathael Pajani <nathael.pajani@ed3l.fr>
- *
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- *************************************************************************** */
-
-
-#include "core/system.h"
-#include "core/systick.h"
-#include "core/pio.h"
-#include "lib/stdio.h"
-#include "drivers/serial.h"
-#include "drivers/gpio.h"
-#include "drivers/ssp.h"
-#include "drivers/i2c.h"
-#include "drivers/adc.h"
-#include "drivers/timers.h"
-#include "extdrv/cc1101.h"
-#include "extdrv/status_led.h"
-#include "extdrv/tmp101_temp_sensor.h"
-#include "extdrv/ws2812.h"
-#include "lib/protocols/dtplug/slave.h"
-
-
-#define MODULE_VERSION 0x02
-#define MODULE_NAME "Cape RC-Car"
-
-
-#define RF_868MHz  1
-#define RF_915MHz  0
-#if ((RF_868MHz) + (RF_915MHz) != 1)
-#error Either RF_868MHz or RF_915MHz MUST be defined.
-#endif
-
-
-#define DEBUG 0
-#define UART_DEBUG  UART0
-#define BUFF_LEN 60
-
-#define SELECTED_FREQ  FREQ_SEL_48MHz
-
-#define LPC_TIMER_PIN_CONFIG   (LPC_IO_MODE_PULL_UP | LPC_IO_DIGITAL | LPC_IO_DRIVE_HIGHCURENT)
-
-/***************************************************************************** */
-/* Pins configuration */
-/* pins blocks are passed to set_pins() for pins configuration.
- * Unused pin blocks can be removed safely with the corresponding set_pins() call
- * All pins blocks may be safelly merged in a single block for single set_pins() call..
- */
-const struct pio_config common_pins[] = {
-       /* UART 0 */
-       { LPC_UART0_RX_PIO_0_1,  LPC_IO_DIGITAL },
-       { LPC_UART0_TX_PIO_0_2,  LPC_IO_DIGITAL },
-       /* UART 1 */
-       { LPC_UART1_RX_PIO_0_8,  LPC_IO_DIGITAL },
-       { LPC_UART1_TX_PIO_0_9,  LPC_IO_DIGITAL },
-       /* I2C 0 */
-       { LPC_I2C0_SCL_PIO_0_10, (LPC_IO_DIGITAL | LPC_IO_OPEN_DRAIN_ENABLE) },
-       { LPC_I2C0_SDA_PIO_0_11, (LPC_IO_DIGITAL | LPC_IO_OPEN_DRAIN_ENABLE) },
-       /* SPI */
-       { LPC_SSP0_SCLK_PIO_0_14, LPC_IO_DIGITAL },
-       { LPC_SSP0_MOSI_PIO_0_17, LPC_IO_DIGITAL },
-       { LPC_SSP0_MISO_PIO_0_16, LPC_IO_DIGITAL },
-       /* TIMER_32B0 - PWM */
-       { LPC_TIMER_32B0_M0_PIO_0_18, LPC_TIMER_PIN_CONFIG },
-       { LPC_TIMER_32B0_M1_PIO_0_19, LPC_TIMER_PIN_CONFIG },
-       { LPC_TIMER_32B0_M2_PIO_0_20, LPC_TIMER_PIN_CONFIG },
-       /* TIMER_32B1 - PWM */
-       { LPC_TIMER_32B1_M0_PIO_0_23, LPC_TIMER_PIN_CONFIG },
-       { LPC_TIMER_32B1_M1_PIO_0_24, LPC_TIMER_PIN_CONFIG },
-       { LPC_TIMER_32B1_M2_PIO_0_25, LPC_TIMER_PIN_CONFIG },
-       /* ADC */
-       { LPC_ADC_AD0_PIO_0_30, LPC_IO_ANALOG },
-       { LPC_ADC_AD1_PIO_0_31, LPC_IO_ANALOG },
-       { LPC_ADC_AD2_PIO_1_0,  LPC_IO_ANALOG },
-       /* GPIO */
-       { LPC_GPIO_0_3, LPC_IO_DIGITAL},
-       { LPC_GPIO_0_4, LPC_IO_DIGITAL},
-       { LPC_GPIO_0_5, LPC_IO_DIGITAL},
-       { LPC_GPIO_0_6, LPC_IO_DIGITAL},
-       { LPC_GPIO_0_7, LPC_IO_DIGITAL},
-       { LPC_GPIO_0_21, LPC_IO_DIGITAL},
-       { LPC_GPIO_0_22, LPC_IO_DIGITAL},
-       { LPC_GPIO_0_26, LPC_IO_DIGITAL},
-       { LPC_GPIO_0_27, LPC_IO_DIGITAL},
-       { LPC_GPIO_0_28, LPC_IO_DIGITAL},
-       { LPC_GPIO_0_29, LPC_IO_DIGITAL},
-       ARRAY_LAST_PIO,
-};
-
-/* RF - CC1101 */
-const struct pio cc1101_cs_pin = LPC_GPIO_0_6;
-const struct pio cc1101_miso_pin = LPC_SSP0_MISO_PIO_0_16;
-const struct pio cc1101_gdo0 = LPC_GPIO_0_7;
-/* 9D - LSM9DSO sensor */
-const struct pio lsm9d_cs_pin = LPC_GPIO_0_5;
-
-/* On-board I2C temperature sensor */
-#define TMP101_ADDR  0x94  /* Pin Addr0 (pin5 of tmp101) connected to VCC */
-struct tmp101_sensor_config tmp101_sensor = {
-       .bus_num = I2C0,
-       .addr = TMP101_ADDR,
-       .resolution = TMP_RES_ELEVEN_BITS,
-};
-
-/* Servomotor functions definition by servo numbers */
-#define DIRECTION_CTRL_SERVO  0
-#define DIRECTION_CTRL_SERVO_MIN 60
-#define DIRECTION_CTRL_SERVO_MAX 120
-#define SPEED_CTRL_SERVO      1
-#define SPEED_CTRL_SERVO_MIN 60
-#define SPEED_CTRL_SERVO_MAX 110
-
-#define DIST_SLOW 400
-#define DIST_STOP 200
-#define SLOW_MOTION 98
-#define HALT 86
-uint8_t max_forward_speed = SPEED_CTRL_SERVO_MAX;
-
-/* Lights - WS2812B Leds strip */
-const struct pio leds = LPC_GPIO_0_3;
-
-/* External movement detector */
-const struct pio ext_move_pin = LPC_GPIO_0_4;
-
-/* Ultrasound sensors */
-#define NUM_PULSE_SENSORS  6
-const struct pio us_pulse_sensors[NUM_PULSE_SENSORS] = {
-       LPC_GPIO_0_21, LPC_GPIO_0_22, LPC_GPIO_0_26,
-       LPC_GPIO_0_27, LPC_GPIO_0_28, LPC_GPIO_0_29,
-};
-
-/* Status Led */
-const struct pio status_led_green = LPC_GPIO_1_4;
-const struct pio status_led_red = LPC_GPIO_1_5;
-
-
-#define ADC_SMOKE  LPC_ADC(0)
-#define ADC_VBAT1  LPC_ADC(1)
-#define ADC_VBAT2  LPC_ADC(2)
-#define ALL_BOARD_ADC   (ADC_MCH(ADC_SMOKE) | ADC_MCH(ADC_VBAT1) | ADC_MCH(ADC_VBAT2))
-
-/***************************************************************************** */
-void system_init()
-{
-       /* Stop the watchdog */
-       startup_watchdog_disable(); /* Do it right now, before it gets a chance to break in */
-       system_set_default_power_state();
-       clock_config(SELECTED_FREQ);
-       set_pins(common_pins);
-       gpio_on();
-       /* System tick timer MUST be configured and running in order to use the sleeping
-        * functions */
-       systick_timer_on(1); /* 1ms */
-       systick_start();
-}
-
-/* Define our fault handler. This one is not mandatory, the dummy fault handler
- * will be used when it's not overridden here.
- * Note : The default one does a simple infinite loop. If the watchdog is deactivated
- * the system will hang.
- */
-void fault_info(const char* name, uint32_t len)
-{
-       uprintf(UART1, name);
-       while (1);
-}
-
-
-
-/***************************************************************************** */
-/* Temperature */
-/* The I2C Temperature sensor is at address 0x94 */
-void temp_config(int uart_num)
-{
-       int ret = 0;
-       ret = tmp101_sensor_config(&tmp101_sensor);
-       if (ret != 0) {
-#if (DEBUG == 1)
-               uprintf(uart_num, "Temp config error\n");
-#endif
-       }
-}
-
-
-/******************************************************************************/
-/* Servo-motors */
-static uint32_t servo_med_pos_cmd = 0;
-static uint32_t servo_one_deg_step = 0;
-int servo_config(uint8_t uart_num)
-{
-       uint32_t servo_command_period = 0;
-       struct lpc_timer_pwm_config timer_conf = {
-               .nb_channels = 3,
-               .period_chan = 3,
-               .outputs = { 0, 1, 2, },
-       };
-
-       /* compute the period and median position for the servo command */
-       /* We want 20ms (50Hz), timer counts at main clock frequency */
-       servo_command_period = get_main_clock() / 50;
-       /* servo_command_period is 20ms, we need 1.5ms, which is 3/40. */
-       servo_med_pos_cmd = ((servo_command_period / 40) * 3);
-       servo_one_deg_step = ((servo_command_period / 41) / 48);
-
-       timer_conf.match_values[0] = servo_med_pos_cmd;
-       timer_conf.match_values[1] = servo_med_pos_cmd;
-       timer_conf.match_values[2] = servo_med_pos_cmd;
-       timer_conf.period = servo_command_period;
-
-    timer_on(LPC_TIMER_32B0, 0, NULL);
-       timer_pwm_config(LPC_TIMER_32B0, &timer_conf);
-       timer_start(LPC_TIMER_32B0);
-
-    timer_on(LPC_TIMER_32B1, 0, NULL);
-       timer_pwm_config(LPC_TIMER_32B1, &timer_conf);
-       timer_start(LPC_TIMER_32B1);
-
-#if (DEBUG == 1)
-       uprintf(uart_num, "Servos configured, Period : %d, med_pos : %d\n",
-                                                       servo_command_period, servo_med_pos_cmd);
-#endif
-       return 0;
-}
-
-int set_servo(int uart_num, int servo_num, int angle)
-{
-       uint32_t pos = servo_med_pos_cmd;
-       int timer = (servo_num < 3) ? LPC_TIMER_32B0 : LPC_TIMER_32B1;
-       int channel = (servo_num % 3);
-
-       if (angle > 180) {
-               angle = 180;
-       }
-
-       /* And compute the new match value for the angle */
-       if (angle >= 90) {
-               pos += ((angle - 90) * servo_one_deg_step);
-       } else {
-               pos -= ((90 - angle) * servo_one_deg_step);
-       }
-       timer_set_match(timer, channel, pos);
-#if (DEBUG == 1)
-       uprintf(uart_num, "Servo(%d - %d.%d): %d (%d)\n", servo_num, timer, channel, angle, pos);
-#endif
-       return pos;
-}
-
-
-/******************************************************************************/
-/* Ultrasonic distance sensors */
-
-/* Delay between measures should be at least 50ms  */
-#define PULSE_DELAY 50
-enum pulse_states {
-       PULSE_STATE_NONE = 0,
-       PULSE_STATE_MUST_TRIGGER,
-       PULSE_STATE_TRIG_DELAY,
-       PULSE_STATE_TRIG_START,
-       PULSE_STATE_TRIG_DONE,
-       PULSE_STATE_PULSE_START,
-       PULSE_STATE_PULSE_END,
-};
-
-/* Note that clock cycles counter wraps every 89 seconds with system clock running at 48 MHz */
-static volatile uint32_t pulse_start[NUM_PULSE_SENSORS];  /* Clock cycles counter upon echo start */
-static volatile uint32_t pulse_duration[NUM_PULSE_SENSORS];
-static volatile uint8_t pulse_state[6] = {0};
-void pulse_feedback(uint32_t gpio)
-{
-       int sensor_num = 0;
-       uint32_t now = systick_get_clock_cycles();
-       /* Find sensor number */
-       do {
-               if (us_pulse_sensors[sensor_num].pin == gpio) {
-                       break;
-               }
-       } while (++sensor_num < NUM_PULSE_SENSORS);
-       if (sensor_num >= NUM_PULSE_SENSORS) {
-               return;
-       }
-       
-       if (pulse_state[sensor_num] == PULSE_STATE_TRIG_DONE) {
-               pulse_start[sensor_num] = now;
-               pulse_state[sensor_num] = PULSE_STATE_PULSE_START;
-       } else if (pulse_state[sensor_num] == PULSE_STATE_PULSE_START) {
-               if (now > pulse_start[sensor_num]) {
-                       pulse_duration[sensor_num] = (now - pulse_start[sensor_num]);
-               } else {
-                       pulse_duration[sensor_num] = (0xFFFFFFFF - pulse_start[sensor_num]);
-                       pulse_duration[sensor_num] += now;
-               }
-               pulse_state[sensor_num] = PULSE_STATE_PULSE_END;
-               /* Remove GPIO interrupt, we got what we wanted, do not trig interrupt on
-                * sensor trigger pulse. */
-               remove_gpio_callback(&us_pulse_sensors[sensor_num]);
-       }
-}
-
-void ultrasound_sensors_trig_timer_int(uint32_t flags)
-{
-       int i = 0;
-       for (i = 0; i < NUM_PULSE_SENSORS; i++) {
-               switch (pulse_state[i]) {
-                       case PULSE_STATE_TRIG_DELAY:
-                               gpio_set(us_pulse_sensors[i]);
-                               pulse_state[i] = PULSE_STATE_TRIG_START;
-                               /* And restart timer for the high state */
-                               timer_restart(LPC_TIMER_16B0);
-                               break;
-                       case PULSE_STATE_TRIG_START:
-                               gpio_clear(us_pulse_sensors[i]);
-                               gpio_dir_in(us_pulse_sensors[i]);
-                               pulse_state[i] = PULSE_STATE_TRIG_DONE;
-                               /* Re-activate GPIO interrupt */
-                               set_gpio_callback(pulse_feedback, &(us_pulse_sensors[i]), EDGES_BOTH);
-                               break;
-               }
-       }
-}
-
-/* Initiate distance mesurement */
-void pulse_trig(int sensor_num)
-{
-       /* Set pin as output and clear for 10us at least */
-       gpio_dir_out(us_pulse_sensors[sensor_num]);
-       gpio_clear(us_pulse_sensors[sensor_num]);
-       pulse_state[sensor_num] = PULSE_STATE_TRIG_DELAY;
-       /* Start or restart timer to generate event.
-        * If timer was already started, it will restart timer thus we get a delay of 10 to 60us
-        *   depending on how many times this function is called and when.
-        */
-       timer_restart(LPC_TIMER_16B0);
-}
-
-static volatile uint16_t distances[NUM_PULSE_SENSORS] = {0};
-uint32_t div = 0;
-void ultrasound_sensors_update(uint32_t tick)
-{
-       static int i = 0;
-       uint32_t distance_tmp = 0;
-
-       if (pulse_state[i] == PULSE_STATE_PULSE_END) {
-               /* Convert pulse width in us to distance in mm */
-               distance_tmp = (((pulse_duration[i] * 10) / div) / 29);
-               distances[i] = (uint16_t)byte_swap_16((uint16_t)distance_tmp);
-               pulse_state[i] = PULSE_STATE_MUST_TRIGGER;
-       }
-       /* Always trigger a new round, this prevents being stuck somewhere */
-       pulse_trig(i);
-
-       /* Next time we will trigger the next sensor */
-       i = ((i + 1) % NUM_PULSE_SENSORS);
-}
-
-int ultrasound_sensors_config(int uart_num)
-{
-       struct lpc_tc_config timer_conf = {
-               .mode = (LPC_TIMER_MODE_TIMER | LPC_TIMER_MODE_MATCH),
-               .match_control = { LPC_TIMER_INT_RESET_AND_STOP_ON_MATCH, 0, 0, 0, },
-       };
-       uint32_t match = get_main_clock() / (50 * 1000); /* 5 us */
-
-       /* Set divisor only once : main clock must not be changed. */
-       div = (get_main_clock() / (1000*1000));
-
-       /* Add a callback to trigger the range measurement every 50 to 100 ms */
-       add_systick_callback(ultrasound_sensors_update, 40);
-
-       timer_conf.match[0] = match;
-    timer_on(LPC_TIMER_16B0, 0, ultrasound_sensors_trig_timer_int);
-       timer_counter_config(LPC_TIMER_16B0, &timer_conf);
-
-#if (DEBUG == 1)
-       uprintf(uart_num, "Ultrasound distance sensors configured.\n");
-#endif
-       return 0;
-}
-
-
-/******************************************************************************/
-/* RF Communication */
-#define RF_BUFF_LEN  64
-
-static volatile uint32_t cc_tx = 0;
-static volatile uint8_t cc_tx_buff[RF_BUFF_LEN];
-static volatile uint8_t cc_ptr = 0;
-
-static volatile int check_rx = 0;
-void rf_rx_calback(uint32_t gpio)
-{
-       check_rx = 1;
-}
-
-static uint8_t rf_specific_settings[] = {
-       CC1101_REGS(gdo_config[2]), 0x07, /* GDO_0 - Assert on CRC OK | Disable temp sensor */
-       CC1101_REGS(gdo_config[0]), 0x2E, /* GDO_2 - FIXME : do something usefull with it for tests */
-       CC1101_REGS(pkt_ctrl[0]), 0x0F, /* Accept all sync, CRC err auto flush, Append, Addr check and Bcast */
-};
-
-/* RF config */
-void rf_config(void)
-{
-       config_gpio(&cc1101_gdo0, LPC_IO_MODE_PULL_UP, GPIO_DIR_IN, 0);
-       cc1101_init(0, &cc1101_cs_pin, &cc1101_miso_pin); /* ssp_num, cs_pin, miso_pin */
-       /* Set default config */
-       cc1101_config();
-       /* And change application specific settings */
-       cc1101_update_config(rf_specific_settings, sizeof(rf_specific_settings));
-       set_gpio_callback(rf_rx_calback, &cc1101_gdo0, EDGE_RISING);
-
-#if (DEBUG == 1)
-       uprintf(UART_DEBUG, "CC1101 RF link init done.\n");
-#endif
-}
-
-void handle_rf_rx_data(void)
-{
-       uint8_t data[RF_BUFF_LEN];
-       int8_t ret = 0;
-       uint8_t status = 0;
-
-       /* Check for received packet (and get it if any) */
-       ret = cc1101_receive_packet(data, RF_BUFF_LEN, &status);
-       /* Go back to RX mode */
-       cc1101_enter_rx_mode();
-
-#if (DEBUG == 1)
-       uprintf(UART_DEBUG, "RF: ret:%d, st: %d.\n", ret, status);
-#endif
-
-       if (ret <= 0) {
-               return;
-       }
-
-       switch (data[2]) {
-               case 'D':
-                       if (data[3] > DIRECTION_CTRL_SERVO_MAX) {
-                               data[3] = DIRECTION_CTRL_SERVO_MAX;
-                       }
-                       if (data[3] < DIRECTION_CTRL_SERVO_MIN) {
-                               data[3] = DIRECTION_CTRL_SERVO_MIN;
-                       }
-                       set_servo(UART_DEBUG, DIRECTION_CTRL_SERVO, data[3]);
-                       break;
-               case 'S':
-                       if (data[3] > max_forward_speed) {
-                               data[3] = max_forward_speed;
-                       }
-                       set_servo(UART_DEBUG, SPEED_CTRL_SERVO, data[3]);
-                       break;
-               default:
-                       uprintf(UART_DEBUG, "Received unhandled command on RF\n");
-                       break;
-       }
-}
-
-void send_on_rf(void)
-{
-    uint8_t cc_tx_data[RF_BUFF_LEN + 2];
-    uint8_t tx_len = cc_ptr;
-    int ret = 0;
-
-    /* Create a local copy */
-    memcpy((char*)&(cc_tx_data[2]), (char*)cc_tx_buff, tx_len);
-    /* "Free" the rx buffer as soon as possible */
-    cc_ptr = 0;
-    /* Prepare buffer for sending */
-    cc_tx_data[0] = tx_len + 1;
-    cc_tx_data[1] = 0; /* Broadcast */
-    /* Send */
-    if (cc1101_tx_fifo_state() != 0) {
-        cc1101_flush_tx_fifo();
-    }
-    ret = cc1101_send_packet(cc_tx_data, (tx_len + 2));
-
-#if (DEBUG == 1)
-       /* Give some feedback on UART 0 */
-       uprintf(UART_DEBUG, "Tx ret: %d\n", ret);
-#endif
-       if (ret <= 0) {
-               return;
-       }
-}
-
-
-
-/******************************************************************************/
-/* Serial Communication */
-
-static struct dtplug_protocol_handle uart_handle;
-
-void quickdata_to_packet(struct packet* pkt)
-{
-       struct header* head = &(pkt->info);
-       if (head->seq_num & QUICK_DATA_PACKET) {
-               pkt->data[0] = head->quick_data[0];
-               pkt->data[1] = head->quick_data[1];
-               if (head->seq_num & QUICK_DATA_PACKET_ONE_BYTE) {
-                       head->data.size = 1;
-               } else {
-                       head->data.size = 2;
-               }
-       }
-}
-
-
-#define PKT_TYPE_GET_DISTANCES    (PKT_TYPE_LAST + 40)
-#define PKT_TYPE_GET_SMOKE        (PKT_TYPE_LAST + 41)
-#define PKT_TYPE_GET_BATTERY      (PKT_TYPE_LAST + 42)
-#define PKT_TYPE_GET_IR           (PKT_TYPE_LAST + 43)
-
-#define PKT_TYPE_SET_SPEED        (PKT_TYPE_LAST + 50)
-#define PKT_TYPE_SET_DIRECTION    (PKT_TYPE_LAST + 51)
-
-int board_temp = 0;
-uint16_t adc_smoke = 0;
-
-void handle_commands(struct packet* command)
-{
-       struct header* head = &(command->info);
-       uint8_t* data = command->data;
-       uint16_t value = 0;
-       int i = 0;
-       /* Transform quick data packets to standard packets */
-       quickdata_to_packet(command);
-
-       /* And handle commands */
-       switch (head->type) {
-               case PKT_TYPE_GET_TEMPERATURE:
-                       value = (int16_t)board_temp;
-                       value = (uint16_t)byte_swap_16(value);
-                       dtplug_protocol_send_reply(&uart_handle, command, NO_ERROR, 2, (uint8_t*)(&value));
-                       break;
-               case PKT_TYPE_GET_ADC_VALUE:
-                       break;
-               case PKT_TYPE_GET_SMOKE:
-                       value = (uint16_t)byte_swap_16(adc_smoke);
-                       dtplug_protocol_send_reply(&uart_handle, command, NO_ERROR, 2, (uint8_t*)(&value));
-                       break;
-               case PKT_TYPE_GET_DISTANCES:
-                       dtplug_protocol_send_reply(&uart_handle, command, NO_ERROR, (2 * NUM_PULSE_SENSORS), (uint8_t*)(&distances));
-                       break;
-               case PKT_TYPE_SET_RGB_LED:
-                       for (i = 0; i < head->data.size; i += 4) {
-                               ws2812_set_pixel(data[i], data[i + 1], data[i + 2], data[i + 3]);
-                               uprintf(UART_DEBUG, "Set led %d to {%d, %d, %d}.\n", data[i], data[i + 1], data[i + 2], data[i + 3]);
-                       }
-                       uprintf(UART_DEBUG, "Set %d leds.\n", (i / 4));
-                       break;
-               case PKT_TYPE_CLEAR_LEDS:
-                       uprintf(UART_DEBUG, "All leds cleared.\n");
-                       ws2812_clear();
-                       break;
-               case PKT_TYPE_SET_DIRECTION:
-                       if (data[0] > DIRECTION_CTRL_SERVO_MAX) {
-                               data[0] = DIRECTION_CTRL_SERVO_MAX;
-                       }
-                       if (data[0] < DIRECTION_CTRL_SERVO_MIN) {
-                               data[0] = DIRECTION_CTRL_SERVO_MIN;
-                       }
-                       set_servo(UART_DEBUG, DIRECTION_CTRL_SERVO, data[0]);
-                       uprintf(UART_DEBUG, "Set direction to %d.\n", data[0]);
-                       break;
-               case PKT_TYPE_SET_SPEED:
-                       if (data[0] > SPEED_CTRL_SERVO_MAX) {
-                               data[0] = SPEED_CTRL_SERVO_MAX;
-                       }
-                       if (data[0] < SPEED_CTRL_SERVO_MIN) {
-                               data[0] = SPEED_CTRL_SERVO_MIN;
-                       }
-                       if (data[0] > max_forward_speed) {
-                               data[0] = max_forward_speed;
-                       }
-                       set_servo(UART_DEBUG, SPEED_CTRL_SERVO, data[0]);
-                       uprintf(UART_DEBUG, "Set speed to %d.\n", data[0]);
-                       break;
-               case PKT_TYPE_SET_PWM_CHAN:
-                       set_servo(UART_DEBUG, 2, (distances[2] / 10));
-                       break;
-               default:
-                       /* FIXME : dtplug_protocol_common_handles(&uart_handle, command); */
-                       uprintf(UART_DEBUG, "Unknown packet type (%d): packet not handled\n", head->type);
-                       dtplug_protocol_send_reply(&uart_handle, command, ERROR_PKT_NOT_HANDLED, 0, NULL);
-                       status_led(red_on);
-                       break;
-       }
-       dtplug_protocol_release_old_packet(&uart_handle);
-}
-
-void dtplug_protocol_send_info(struct dtplug_protocol_handle* handle, uint8_t type, int len, uint8_t* data)
-{
-       struct packet sensors = {
-               .info = {
-                       .start = FIRST_PACKET_CHAR,
-                       .type = type,
-                       .seq_num = PACKET_NEEDS_REPLY,  /* Packet sequence number of 0 for unrequested packets */
-               },
-       };
-
-       dtplug_protocol_send_reply(handle, &sensors, NO_ERROR, len, data);
-}
-
-/***************************************************************************** */
-int main(void)
-{
-       system_init();
-
-       dtplug_protocol_set_dtplug_comm_uart(UART0, &uart_handle);
-       uart_on(UART1, 115200, NULL);
-
-       ssp_master_on(0, LPC_SSP_FRAME_SPI, 8, 4*1000*1000); /* bus_num, frame_type, data_width, rate */
-       i2c_on(I2C0, I2C_CLK_100KHz, I2C_MASTER);
-       adc_on(NULL);
-       status_led_config(&status_led_green, &status_led_red);
-
-       /* Radio */
-       rf_config();
-
-       /* Temperature sensor */
-       temp_config(UART_DEBUG);
-
-       /* Ultrasonic distance sensors */
-       ultrasound_sensors_config(UART_DEBUG);
-
-       /* Smoke sensor and ADCs */
-       adc_start_burst_conversion(ALL_BOARD_ADC, LPC_ADC_SEQ(0));
-
-       /* Servo motors */
-       msleep(2000);
-       servo_config(UART_DEBUG);
-
-       /* Config Leds for lights */
-       ws2812_config(&leds);
-
-       while (1) {
-               struct packet* pkt = NULL;
-               uint8_t status = 0;
-
-               /* Request a Temp conversion on I2C TMP101 temperature sensor */
-               tmp101_sensor_start_conversion(&tmp101_sensor); /* A conversion takes about 40ms */
-
-               /* Tell we are alive :) */
-               chenillard(10);
-
-               /* Read the temperature */
-               if (tmp101_sensor_read(&tmp101_sensor, NULL, &board_temp) != 0) {
-#if (DEBUG == 1)
-                       uprintf(UART_DEBUG, "Temp read error\n");
-               } else {
-                       uprintf(UART_DEBUG, "Temp read: %d,%d.\n", (board_temp / 10), (board_temp % 10));
-#endif
-               }
-
-               /* Get and display the smoke detector voltage */
-               if (adc_get_value(&adc_smoke, ADC_SMOKE) >= 0) {
-                       int milli_volts = ((adc_smoke * 32) / 5);
-                       adc_smoke = (uint16_t)milli_volts;
-#if (DEBUG == 1)
-                       uprintf(UART_DEBUG , "Vsmoke: %d\n", adc_smoke);
-#endif
-               }
-
-#if (DEBUG == 1)
-               uprintf(UART_DEBUG, "D: %d - %d - %d - %d - %d - %d\n",
-                                       byte_swap_16(distances[0]), byte_swap_16(distances[1]), byte_swap_16(distances[2]),
-                                       byte_swap_16(distances[3]), byte_swap_16(distances[4]), byte_swap_16(distances[5]));
-#endif
-               if ((distances[3] < DIST_STOP) || (distances[4] < DIST_STOP) || (distances[5] < DIST_STOP)) {
-                       max_forward_speed = HALT;
-               } else if ((distances[3] < DIST_SLOW) || (distances[4] < DIST_SLOW) || (distances[5] < DIST_SLOW)) {
-                       max_forward_speed = SLOW_MOTION;
-               } else {
-                       max_forward_speed = SPEED_CTRL_SERVO_MAX;
-               }
-
-               /* Handle commands */
-               pkt = dtplug_protocol_get_next_packet_ok(&uart_handle);
-               if (pkt != NULL) {
-                       handle_commands(pkt);
-               }
-
-               /* Send leds frame if leds changed */
-               ws2812_send_frame(0);
-
-               /* RF */
-               if (cc_tx == 1) {
-                       send_on_rf();
-                       cc_tx = 0;
-               }
-               /* Do not leave radio in an unknown or unwated state */
-        do {
-            status = (cc1101_read_status() & CC1101_STATE_MASK);
-        } while (status == CC1101_STATE_TX);
-
-               if (status != CC1101_STATE_RX) {
-                       if (cc1101_rx_fifo_state() != 0) {
-                               cc1101_flush_rx_fifo();
-                       }
-                       cc1101_enter_rx_mode();
-               }
-               if (check_rx == 1) {
-                       check_rx = 0;
-                       handle_rf_rx_data();
-               }
-       }
-       return 0;
-}
-
-
-
-
diff --git a/apps/cape_rccar/remote/Makefile b/apps/cape_rccar/remote/Makefile
deleted file mode 100644 (file)
index 41ae555..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-# Makefile for apps
-
-MODULE = $(shell basename $(shell cd .. && pwd && cd -))
-NAME = $(shell basename $(CURDIR))
-
-# Add this to your ~/.vimrc in order to get proper function of :make in vim :
-# let $COMPILE_FROM_IDE = 1
-ifeq ($(strip $(COMPILE_FROM_IDE)),)
-       PRINT_DIRECTORY = --no-print-directory
-else
-       PRINT_DIRECTORY =
-       LANG = C
-endif
-
-.PHONY: $(NAME).bin
-$(NAME).bin:
-       @make -C ../../.. ${PRINT_DIRECTORY} NAME=$(NAME) MODULE=$(MODULE) apps/$(MODULE)/$(NAME)/$@
-
-clean mrproper:
-       @make -C ../../.. ${PRINT_DIRECTORY} $@
-
diff --git a/apps/cape_rccar/remote/main.c b/apps/cape_rccar/remote/main.c
deleted file mode 100644 (file)
index f303d4a..0000000
+++ /dev/null
@@ -1,268 +0,0 @@
-/****************************************************************************
- *   apps/cape_rccar/remote//main.c
- *
- * Remote controller using sub1G_module
- *
- * Copyright 2016 Nathael Pajani <nathael.pajani@ed3l.fr>
- *
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- *************************************************************************** */
-
-
-#include "core/system.h"
-#include "core/systick.h"
-#include "core/pio.h"
-#include "lib/stdio.h"
-#include "drivers/serial.h"
-#include "drivers/gpio.h"
-#include "drivers/ssp.h"
-#include "drivers/adc.h"
-#include "drivers/timers.h"
-#include "extdrv/cc1101.h"
-#include "extdrv/status_led.h"
-
-
-#define MODULE_VERSION 0x02
-#define MODULE_NAME "RF Sub1G"
-
-
-#define RF_868MHz  1
-#define RF_915MHz  0
-#if ((RF_868MHz) + (RF_915MHz) != 1)
-#error Either RF_868MHz or RF_915MHz MUST be defined.
-#endif
-
-
-#define DEBUG 1
-#define BUFF_LEN 60
-
-#define SELECTED_FREQ  FREQ_SEL_48MHz
-
-/***************************************************************************** */
-/* Pins configuration */
-/* pins blocks are passed to set_pins() for pins configuration.
- * Unused pin blocks can be removed safely with the corresponding set_pins() call
- * All pins blocks may be safelly merged in a single block for single set_pins() call..
- */
-const struct pio_config common_pins[] = {
-       /* UART 0 */
-       { LPC_UART0_RX_PIO_0_1,  LPC_IO_DIGITAL },
-       { LPC_UART0_TX_PIO_0_2,  LPC_IO_DIGITAL },
-       /* SPI */
-       { LPC_SSP0_SCLK_PIO_0_14, LPC_IO_DIGITAL },
-       { LPC_SSP0_MOSI_PIO_0_17, LPC_IO_DIGITAL },
-       { LPC_SSP0_MISO_PIO_0_16, LPC_IO_DIGITAL },
-       /* ADC */
-       { LPC_ADC_AD0_PIO_0_30, LPC_IO_ANALOG },
-       { LPC_ADC_AD1_PIO_0_31, LPC_IO_ANALOG },
-       { LPC_ADC_AD2_PIO_1_0,  LPC_IO_ANALOG },
-       ARRAY_LAST_PIO,
-};
-
-const struct pio cc1101_cs_pin = LPC_GPIO_0_15;
-const struct pio cc1101_miso_pin = LPC_SSP0_MISO_PIO_0_16;
-const struct pio cc1101_gdo0 = LPC_GPIO_0_6;
-const struct pio cc1101_gdo2 = LPC_GPIO_0_7;
-
-const struct pio status_led_green = LPC_GPIO_0_28;
-const struct pio status_led_red = LPC_GPIO_0_29;
-
-
-#define ADC_VBAT  LPC_ADC(0)
-#define ADC_EXT1  LPC_ADC(1)
-#define ADC_EXT2  LPC_ADC(2)
-
-const struct wdt_config wdconf = {
-    .clk_sel = WDT_CLK_IRC,
-    .intr_mode_only = 0,
-    .callback = NULL,
-    .locks = 0,
-    .nb_clk = 0x04FFFF,
-    .wdt_window = 0,
-    .wdt_warn = 0x3FF,
-};
-
-
-/***************************************************************************** */
-void system_init()
-{
-       /* Stop the watchdog */
-       startup_watchdog_disable(); /* Do it right now, before it gets a chance to break in */
-       system_set_default_power_state();
-       clock_config(SELECTED_FREQ);
-       set_pins(common_pins);
-       gpio_on();
-       /* System tick timer MUST be configured and running in order to use the sleeping
-        * functions */
-       systick_timer_on(1); /* 1ms */
-       systick_start();
-}
-
-/* Define our fault handler. This one is not mandatory, the dummy fault handler
- * will be used when it's not overridden here.
- * Note : The default one does a simple infinite loop. If the watchdog is deactivated
- * the system will hang.
- */
-void fault_info(const char* name, uint32_t len)
-{
-       uprintf(UART0, name);
-       while (1);
-}
-
-
-
-/******************************************************************************/
-/* RF Communication */
-#define RF_BUFF_LEN  64
-#define RF_BROADCAST 0
-
-static volatile int check_rx = 0;
-void rf_rx_calback(uint32_t gpio)
-{
-       check_rx = 1;
-}
-
-static uint8_t rf_specific_settings[] = {
-       CC1101_REGS(gdo_config[2]), 0x07, /* GDO_0 - Assert on CRC OK | Disable temp sensor */
-       CC1101_REGS(gdo_config[0]), 0x2E, /* GDO_2 - FIXME : do something usefull with it for tests */
-       CC1101_REGS(pkt_ctrl[0]), 0x0F, /* Accept all sync, CRC err auto flush, Append, Addr check and Bcast */
-       CC1101_REGS(radio_stm[1]), 0x3F, /* CCA mode "if RSSI below threshold", Stay in RX, Go to RX (page 81) */
-       CC1101_REGS(agc_ctrl[1]), 0x20, /* LNA 2 gain decr first, Carrier sense relative threshold set to 10dB increase in RSSI value */
-#if (RF_915MHz == 1)
-       /* FIXME : Add here a define protected list of settings for 915MHz configuration */
-#endif
-};
-
-/* RF config */
-void rf_config(void)
-{
-       config_gpio(&cc1101_gdo0, LPC_IO_MODE_PULL_UP, GPIO_DIR_IN, 0);
-       cc1101_init(0, &cc1101_cs_pin, &cc1101_miso_pin); /* ssp_num, cs_pin, miso_pin */
-       /* Set default config */
-       cc1101_config();
-       /* And change application specific settings */
-       cc1101_update_config(rf_specific_settings, sizeof(rf_specific_settings));
-       set_gpio_callback(rf_rx_calback, &cc1101_gdo0, EDGE_RISING);
-
-#ifdef DEBUG
-       uprintf(UART0, "CC1101 RF link init done.\n");
-#endif
-}
-
-void send_on_RF(uint8_t addr, uint8_t type, uint8_t val)
-{
-       uint8_t cc_tx_data[8];
-       cc_tx_data[0] = 3;
-       cc_tx_data[1] = addr;
-       cc_tx_data[2] = type;
-       cc_tx_data[3] = val;
-       if (cc1101_tx_fifo_state() != 0) {
-               cc1101_flush_tx_fifo();
-       }
-       cc1101_send_packet(cc_tx_data, 4);
-}
-
-void handle_rf_rx_data(void)
-{
-       uint8_t data[RF_BUFF_LEN];
-       int8_t ret = 0;
-       uint8_t status = 0;
-
-       /* Check for received packet (and get it if any) */
-       ret = cc1101_receive_packet(data, RF_BUFF_LEN, &status);
-       /* Go back to RX mode */
-       cc1101_enter_rx_mode();
-
-#ifdef DEBUG
-       uprintf(UART0, "RF: ret:%d, st: %d.\n", ret, status);
-#endif
-
-}
-
-
-/***************************************************************************** */
-int main(void)
-{
-       system_init();
-       uart_on(UART0, 115200, NULL);
-       ssp_master_on(0, LPC_SSP_FRAME_SPI, 8, 4*1000*1000); /* bus_num, frame_type, data_width, rate */
-       adc_on(NULL);
-       status_led_config(&status_led_green, &status_led_red);
-
-       /* Radio */
-       rf_config();
-
-       /*      ADC */
-       adc_start_burst_conversion(ADC_MCH(ADC_EXT1) | ADC_MCH(ADC_EXT2), LPC_ADC_SEQ(0));
-
-       /* Config done, start watchdog */
-       watchdog_config(&wdconf);
-
-       while (1) {
-               uint8_t status = 0;
-               uint16_t val = 0;
-               uint8_t dir = 0, speed = 0;
-
-               status_led(none);
-               watchdog_feed();
-               /* Get current ADC values and compute new commands */
-               /* First axis : Direction */
-               adc_get_value(&val, ADC_EXT1);
-               dir = (val / 17) + 59; /* This gives a 90 as middle position, with a value between 60 and 120 */
-               send_on_RF(0, 'D', dir);
-#if 0
-               uprintf(UART0, "Direction : %d\n", dir);
-#endif
-               status_led(green_on);
-               msleep(10);
-
-               adc_get_value(&val, ADC_EXT2);
-               speed = ((1024 - val) / 12) + 50; /* About same result, inverting axis to match joystick output */
-               send_on_RF(0, 'S', speed);
-#if 0
-               uprintf(UART0, "Speed : %d\n", speed);
-#endif
-               status_led(red_on);
-               msleep(10);
-
-               /* RF */
-               /* Do not leave radio in an unknown or unwated state */
-               do {
-                       status = (cc1101_read_status() & CC1101_STATE_MASK);
-               } while (status == CC1101_STATE_TX);
-
-               if (status != CC1101_STATE_RX) {
-                       static uint8_t loop = 0;
-                       loop++;
-                       if (loop > 10) {
-                               if (cc1101_rx_fifo_state() != 0) {
-                                       cc1101_flush_rx_fifo();
-                               }
-                               cc1101_enter_rx_mode();
-                               loop = 0;
-                       }
-               }
-               if (check_rx == 1) {
-                       check_rx = 0;
-                       handle_rf_rx_data();
-               }
-       }
-       return 0;
-}
-
-
-
-