Contiki-NG
platform.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2020 Yago Fontoura do Rosario <yago.rosario@hotmail.com.br>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the copyright holder nor the names of its
14 * contributors may be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
20 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
28 * OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30/*---------------------------------------------------------------------------*/
31/**
32 * \addtogroup nrf-platforms
33 * @{
34 *
35 * \file
36 * Platform implementation for nRF
37 * \author
38 * Yago Fontoura do Rosario <yago.rosario@hotmail.com.br>
39 */
40/*---------------------------------------------------------------------------*/
41#include "contiki.h"
42
43#include "dev/gpio-hal.h"
44#include "dev/button-hal.h"
45#include "dev/leds.h"
46#include "dev/serial-line.h"
47
48#include "random.h"
49#include "int-master.h"
50#include "sensors.h"
51#include "uarte-arch.h"
52#include "linkaddr-arch.h"
53#include "reset-arch.h"
54
55#include "lpm.h"
56#include "usb.h"
57
58/*---------------------------------------------------------------------------*/
59/* Log configuration */
60#include "sys/log.h"
61#define LOG_MODULE "NRF"
62#define LOG_LEVEL LOG_LEVEL_MAIN
63/*---------------------------------------------------------------------------*/
64void
66{
68 leds_init();
69}
70/*---------------------------------------------------------------------------*/
71void
73{
75
76 /* Seed value is ignored since hardware RNG is used. */
77 random_init(0x5678);
78
79#if NRF_HAS_UARTE
80 uarte_init();
81#endif /* NRF_HAS_UARTE */
82
83#if NRF_HAS_USB && defined(NRF_NATIVE_USB) && NRF_NATIVE_USB == 1
84 usb_init();
85#endif /* NRF_HAS_USB && defined(NRF_NATIVE_USB) && NRF_NATIVE_USB == 1 */
86
87 serial_line_init();
88
89#if BUILD_WITH_SHELL
90#if PLATFORM_DBG_CONF_USB
92#else /* PLATFORM_DBG_CONF_USB */
94#endif /* PLATFORM_DBG_CONF_USB */
95#endif /* BUILD_WITH_SHELL */
96
98
100}
101/*---------------------------------------------------------------------------*/
102void
104{
105 process_start(&sensors_process, NULL);
106}
107/*---------------------------------------------------------------------------*/
108void
110{
111 lpm_drop();
112}
113/*---------------------------------------------------------------------------*/
114/**
115 * @}
116 */
Header file for the button HAL.
Header file for the GPIO HAL.
void button_hal_init()
Initialise the button HAL.
Definition: button-hal.c:213
void random_init(unsigned short seed)
Seed the cc2538 random number generator.
Definition: random.c:84
void platform_init_stage_three()
Final stage of platform driver initialisation.
Definition: platform.c:169
void platform_init_stage_one(void)
Basic (Stage 1) platform driver initialisation.
Definition: platform.c:114
void platform_idle()
The platform's idle/sleep function.
Definition: platform.c:185
void platform_init_stage_two()
Stage 2 of platform driver initialisation.
Definition: platform.c:123
void lpm_drop()
Drop the cortex to sleep / deep sleep and shut down peripherals.
Definition: lpm.c:525
void leds_init(void)
Initialise the LED HAL.
Definition: minileds.c:44
void populate_link_address(void)
Populates the link address using factory information.
Definition: linkaddr-arch.c:64
void gpio_hal_init()
Initialise the GPIO HAL.
Definition: gpio-hal.c:95
void reset_debug(void)
Logs the reset reason.
Definition: reset-arch.c:60
void uarte_init(void)
Initializa the UARTE driver.
void uarte_set_input(int(*input)(unsigned char c))
Sets the input handler called in the event handler.
void usb_set_input(int(*input)(unsigned char c))
Sets the input handler called in the event handler.
Definition: usb.c:75
void usb_init(void)
Initialize the USB driver.
Definition: usb.c:81
void process_start(struct process *p, process_data_t data)
Start a process.
Definition: process.c:99
Header file for the LED HAL.
Header file for the logging system.
Configuration for the nrf platform.
Reset reason implementation for the nRF.
Generic serial I/O process header filer.
int serial_line_input_byte(unsigned char c)
Get one byte of input from the serial driver.
Definition: serial-line.c:64
UARTE header file for the nRF.