Provide boot sequence hooks (OpenMote)
This commit is contained in:
parent
61d9ec3c35
commit
47f02608c3
@ -14,7 +14,7 @@ CONTIKI_TARGET_DIRS += . dev
|
|||||||
PLATFORM_ROOT_DIR = $(CONTIKI)/arch/platform/$(TARGET)
|
PLATFORM_ROOT_DIR = $(CONTIKI)/arch/platform/$(TARGET)
|
||||||
|
|
||||||
### Include
|
### 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 += leds-arch.c button-sensor.c openmote-sensors.c
|
||||||
CONTIKI_TARGET_SOURCEFILES += antenna.c adxl346.c max44009.c sht21.c tps62730.c
|
CONTIKI_TARGET_SOURCEFILES += antenna.c adxl346.c max44009.c sht21.c tps62730.c
|
||||||
|
|
||||||
|
@ -173,8 +173,8 @@ typedef uint32_t rtimer_clock_t;
|
|||||||
*
|
*
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
#ifndef STARTUP_CONF_VERBOSE
|
#ifndef PLATFORM_CONF_STARTUP_VERBOSE
|
||||||
#define STARTUP_CONF_VERBOSE 1 /**< Set to 0 to decrease startup verbosity */
|
#define PLATFORM_CONF_STARTUP_VERBOSE 1 /**< Set to 0 to decrease startup verbosity */
|
||||||
#endif
|
#endif
|
||||||
/** @} */
|
/** @} */
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
@ -269,8 +269,8 @@ typedef uint32_t rtimer_clock_t;
|
|||||||
#undef UART_CONF_ENABLE
|
#undef UART_CONF_ENABLE
|
||||||
#define UART_CONF_ENABLE 0
|
#define UART_CONF_ENABLE 0
|
||||||
|
|
||||||
#undef STARTUP_CONF_VERBOSE
|
#undef PLATFORM_CONF_STARTUP_VERBOSE
|
||||||
#define STARTUP_CONF_VERBOSE 0
|
#define PLATFORM_CONF_STARTUP_VERBOSE 0
|
||||||
#endif /* CC2538_CONF_QUIET */
|
#endif /* CC2538_CONF_QUIET */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -47,12 +47,8 @@
|
|||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
#include "contiki.h"
|
#include "contiki.h"
|
||||||
#include "dev/leds.h"
|
#include "dev/leds.h"
|
||||||
#include "dev/sys-ctrl.h"
|
|
||||||
#include "dev/nvic.h"
|
|
||||||
#include "dev/uart.h"
|
#include "dev/uart.h"
|
||||||
#include "dev/i2c.h"
|
#include "dev/i2c.h"
|
||||||
#include "dev/watchdog.h"
|
|
||||||
#include "dev/ioc.h"
|
|
||||||
#include "dev/button-sensor.h"
|
#include "dev/button-sensor.h"
|
||||||
#include "dev/serial-line.h"
|
#include "dev/serial-line.h"
|
||||||
#include "dev/slip.h"
|
#include "dev/slip.h"
|
||||||
@ -62,28 +58,20 @@
|
|||||||
#include "usb/usb-serial.h"
|
#include "usb/usb-serial.h"
|
||||||
#include "lib/random.h"
|
#include "lib/random.h"
|
||||||
#include "net/netstack.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/mac/framer/frame802154.h"
|
||||||
|
#include "net/linkaddr.h"
|
||||||
|
#include "sys/platform.h"
|
||||||
#include "soc.h"
|
#include "soc.h"
|
||||||
#include "cpu.h"
|
#include "cpu.h"
|
||||||
#include "reg.h"
|
#include "reg.h"
|
||||||
#include "ieee-addr.h"
|
#include "ieee-addr.h"
|
||||||
#include "lpm.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 <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
#if STARTUP_CONF_VERBOSE
|
#if PLATFORM_STARTUP_VERBOSE
|
||||||
#define PRINTF(...) printf(__VA_ARGS__)
|
#define PRINTF(...) printf(__VA_ARGS__)
|
||||||
#else
|
#else
|
||||||
#define PRINTF(...)
|
#define PRINTF(...)
|
||||||
@ -133,7 +121,7 @@ set_rf_params(void)
|
|||||||
/* Populate linkaddr_node_addr. Maintain endianness */
|
/* Populate linkaddr_node_addr. Maintain endianness */
|
||||||
memcpy(&linkaddr_node_addr, &ext_addr[8 - LINKADDR_SIZE], LINKADDR_SIZE);
|
memcpy(&linkaddr_node_addr, &ext_addr[8 - LINKADDR_SIZE], LINKADDR_SIZE);
|
||||||
|
|
||||||
#if STARTUP_CONF_VERBOSE
|
#if PLATFORM_STARTUP_VERBOSE
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
printf("Contiki configured with address ");
|
printf("Contiki configured with address ");
|
||||||
@ -150,24 +138,18 @@ set_rf_params(void)
|
|||||||
NETSTACK_RADIO.set_object(RADIO_PARAM_64BIT_ADDR, ext_addr, 8);
|
NETSTACK_RADIO.set_object(RADIO_PARAM_64BIT_ADDR, ext_addr, 8);
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/**
|
void
|
||||||
* \brief Main routine for the OpenMote-CC2538 platforms
|
platform_init_stage_one(void)
|
||||||
*/
|
|
||||||
int
|
|
||||||
main(void)
|
|
||||||
{
|
{
|
||||||
nvic_init();
|
soc_init();
|
||||||
ioc_init();
|
|
||||||
sys_ctrl_init();
|
|
||||||
clock_init();
|
|
||||||
lpm_init();
|
|
||||||
rtimer_init();
|
|
||||||
gpio_init();
|
|
||||||
leds_init();
|
leds_init();
|
||||||
fade(LEDS_RED);
|
fade(LEDS_RED);
|
||||||
process_init();
|
}
|
||||||
watchdog_init();
|
/*---------------------------------------------------------------------------*/
|
||||||
|
void
|
||||||
|
platform_init_stage_two()
|
||||||
|
{
|
||||||
#if UART_CONF_ENABLE
|
#if UART_CONF_ENABLE
|
||||||
uart_init(0);
|
uart_init(0);
|
||||||
uart_init(1);
|
uart_init(1);
|
||||||
@ -183,72 +165,46 @@ main(void)
|
|||||||
|
|
||||||
serial_line_init();
|
serial_line_init();
|
||||||
|
|
||||||
INTERRUPTS_ENABLE();
|
/* Initialise the H/W RNG engine. */
|
||||||
fade(LEDS_BLUE);
|
|
||||||
|
|
||||||
PUTS(CONTIKI_VERSION_STRING);
|
|
||||||
PUTS(BOARD_STRING);
|
|
||||||
#if STARTUP_CONF_VERBOSE
|
|
||||||
soc_print_info();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
random_init(0);
|
random_init(0);
|
||||||
|
|
||||||
udma_init();
|
udma_init();
|
||||||
|
|
||||||
process_start(&etimer_process, NULL);
|
|
||||||
ctimer_init();
|
|
||||||
|
|
||||||
board_init();
|
|
||||||
|
|
||||||
#if CRYPTO_CONF_INIT
|
#if CRYPTO_CONF_INIT
|
||||||
crypto_init();
|
crypto_init();
|
||||||
crypto_disable();
|
crypto_disable();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
netstack_init();
|
INTERRUPTS_ENABLE();
|
||||||
|
|
||||||
|
fade(LEDS_BLUE);
|
||||||
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
void
|
||||||
|
platform_init_stage_three()
|
||||||
|
{
|
||||||
|
PUTS(BOARD_STRING);
|
||||||
|
|
||||||
|
board_init();
|
||||||
|
|
||||||
set_rf_params();
|
set_rf_params();
|
||||||
|
|
||||||
PRINTF("Net: ");
|
#if PLATFORM_STARTUP_VERBOSE
|
||||||
PRINTF("%s\n", NETSTACK_NETWORK.name);
|
soc_print_info();
|
||||||
PRINTF("MAC: ");
|
#endif
|
||||||
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 */
|
|
||||||
|
|
||||||
process_start(&sensors_process, NULL);
|
process_start(&sensors_process, NULL);
|
||||||
|
|
||||||
SENSORS_ACTIVATE(button_sensor);
|
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);
|
fade(LEDS_GREEN);
|
||||||
|
}
|
||||||
while(1) {
|
/*---------------------------------------------------------------------------*/
|
||||||
uint8_t r;
|
void
|
||||||
do {
|
platform_idle()
|
||||||
watchdog_periodic();
|
{
|
||||||
|
/* We have serviced all pending events. Enter a Low-Power mode. */
|
||||||
r = process_run();
|
lpm_enter();
|
||||||
} while(r > 0);
|
|
||||||
|
|
||||||
lpm_enter();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/**
|
/**
|
Loading…
Reference in New Issue
Block a user