Provide boot sequence hooks (OpenMote)

This commit is contained in:
George Oikonomou 2017-10-15 01:14:45 +01:00 committed by George Oikonomou
parent 61d9ec3c35
commit 47f02608c3
3 changed files with 41 additions and 85 deletions

View File

@ -14,7 +14,7 @@ CONTIKI_TARGET_DIRS += . dev
PLATFORM_ROOT_DIR = $(CONTIKI)/arch/platform/$(TARGET)
### Include
CONTIKI_TARGET_SOURCEFILES += contiki-main.c board.c
CONTIKI_TARGET_SOURCEFILES += platform.c board.c
CONTIKI_TARGET_SOURCEFILES += leds-arch.c button-sensor.c openmote-sensors.c
CONTIKI_TARGET_SOURCEFILES += antenna.c adxl346.c max44009.c sht21.c tps62730.c

View File

@ -173,8 +173,8 @@ typedef uint32_t rtimer_clock_t;
*
* @{
*/
#ifndef STARTUP_CONF_VERBOSE
#define STARTUP_CONF_VERBOSE 1 /**< Set to 0 to decrease startup verbosity */
#ifndef PLATFORM_CONF_STARTUP_VERBOSE
#define PLATFORM_CONF_STARTUP_VERBOSE 1 /**< Set to 0 to decrease startup verbosity */
#endif
/** @} */
/*---------------------------------------------------------------------------*/
@ -269,8 +269,8 @@ typedef uint32_t rtimer_clock_t;
#undef UART_CONF_ENABLE
#define UART_CONF_ENABLE 0
#undef STARTUP_CONF_VERBOSE
#define STARTUP_CONF_VERBOSE 0
#undef PLATFORM_CONF_STARTUP_VERBOSE
#define PLATFORM_CONF_STARTUP_VERBOSE 0
#endif /* CC2538_CONF_QUIET */
/**

View File

@ -47,12 +47,8 @@
/*---------------------------------------------------------------------------*/
#include "contiki.h"
#include "dev/leds.h"
#include "dev/sys-ctrl.h"
#include "dev/nvic.h"
#include "dev/uart.h"
#include "dev/i2c.h"
#include "dev/watchdog.h"
#include "dev/ioc.h"
#include "dev/button-sensor.h"
#include "dev/serial-line.h"
#include "dev/slip.h"
@ -62,28 +58,20 @@
#include "usb/usb-serial.h"
#include "lib/random.h"
#include "net/netstack.h"
#include "net/queuebuf.h"
#include "net/ipv6/tcpip.h"
#include "net/ipv6/uip.h"
#include "net/mac/framer/frame802154.h"
#include "net/linkaddr.h"
#include "sys/platform.h"
#include "soc.h"
#include "cpu.h"
#include "reg.h"
#include "ieee-addr.h"
#include "lpm.h"
#if BUILD_WITH_ORCHESTRA
#include "orchestra.h"
#endif /* BUILD_WITH_ORCHESTRA */
#if BUILD_WITH_SHELL
#include "serial-shell.h"
#endif /* BUILD_WITH_SHELL */
#include <stdint.h>
#include <string.h>
#include <stdio.h>
/*---------------------------------------------------------------------------*/
#if STARTUP_CONF_VERBOSE
#if PLATFORM_STARTUP_VERBOSE
#define PRINTF(...) printf(__VA_ARGS__)
#else
#define PRINTF(...)
@ -133,7 +121,7 @@ set_rf_params(void)
/* Populate linkaddr_node_addr. Maintain endianness */
memcpy(&linkaddr_node_addr, &ext_addr[8 - LINKADDR_SIZE], LINKADDR_SIZE);
#if STARTUP_CONF_VERBOSE
#if PLATFORM_STARTUP_VERBOSE
{
int i;
printf("Contiki configured with address ");
@ -150,24 +138,18 @@ set_rf_params(void)
NETSTACK_RADIO.set_object(RADIO_PARAM_64BIT_ADDR, ext_addr, 8);
}
/*---------------------------------------------------------------------------*/
/**
* \brief Main routine for the OpenMote-CC2538 platforms
*/
int
main(void)
void
platform_init_stage_one(void)
{
nvic_init();
ioc_init();
sys_ctrl_init();
clock_init();
lpm_init();
rtimer_init();
gpio_init();
soc_init();
leds_init();
fade(LEDS_RED);
process_init();
watchdog_init();
}
/*---------------------------------------------------------------------------*/
void
platform_init_stage_two()
{
#if UART_CONF_ENABLE
uart_init(0);
uart_init(1);
@ -183,72 +165,46 @@ main(void)
serial_line_init();
INTERRUPTS_ENABLE();
fade(LEDS_BLUE);
PUTS(CONTIKI_VERSION_STRING);
PUTS(BOARD_STRING);
#if STARTUP_CONF_VERBOSE
soc_print_info();
#endif
/* Initialise the H/W RNG engine. */
random_init(0);
udma_init();
process_start(&etimer_process, NULL);
ctimer_init();
board_init();
#if CRYPTO_CONF_INIT
crypto_init();
crypto_disable();
#endif
netstack_init();
INTERRUPTS_ENABLE();
fade(LEDS_BLUE);
}
/*---------------------------------------------------------------------------*/
void
platform_init_stage_three()
{
PUTS(BOARD_STRING);
board_init();
set_rf_params();
PRINTF("Net: ");
PRINTF("%s\n", NETSTACK_NETWORK.name);
PRINTF("MAC: ");
PRINTF("%s\n", NETSTACK_MAC.name);
#if NETSTACK_CONF_WITH_IPV6
memcpy(&uip_lladdr.addr, &linkaddr_node_addr, sizeof(uip_lladdr.addr));
queuebuf_init();
process_start(&tcpip_process, NULL);
#endif /* NETSTACK_CONF_WITH_IPV6 */
#if PLATFORM_STARTUP_VERBOSE
soc_print_info();
#endif
process_start(&sensors_process, NULL);
SENSORS_ACTIVATE(button_sensor);
energest_init();
ENERGEST_ON(ENERGEST_TYPE_CPU);
#if BUILD_WITH_ORCHESTRA
orchestra_init();
#endif /* BUILD_WITH_ORCHESTRA */
#if BUILD_WITH_SHELL
serial_shell_init();
#endif /* BUILD_WITH_SHELL */
autostart_start(autostart_processes);
watchdog_start();
fade(LEDS_GREEN);
while(1) {
uint8_t r;
do {
watchdog_periodic();
r = process_run();
} while(r > 0);
lpm_enter();
}
}
/*---------------------------------------------------------------------------*/
void
platform_idle()
{
/* We have serviced all pending events. Enter a Low-Power mode. */
lpm_enter();
}
/*---------------------------------------------------------------------------*/
/**