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 
57 /*---------------------------------------------------------------------------*/
58 /* Log configuration */
59 #include "sys/log.h"
60 #define LOG_MODULE "NRF"
61 #define LOG_LEVEL LOG_LEVEL_MAIN
62 /*---------------------------------------------------------------------------*/
63 void
65 {
66  gpio_hal_init();
67  leds_init();
68 }
69 /*---------------------------------------------------------------------------*/
70 void
72 {
74 
75  /* Seed value is ignored since hardware RNG is used. */
76  random_init(0x5678);
77 
78 #if PLATFORM_HAS_UARTE
79  uarte_init();
80  serial_line_init();
81 #if BUILD_WITH_SHELL
83 #endif /* BUILD_WITH_SHELL */
84 #endif /* PLATFORM_HAS_UARTE */
86 
87  reset_debug();
88 }
89 /*---------------------------------------------------------------------------*/
90 void
92 {
93  process_start(&sensors_process, NULL);
94 }
95 /*---------------------------------------------------------------------------*/
96 void
98 {
99  lpm_drop();
100 }
101 /*---------------------------------------------------------------------------*/
102 /**
103  * @}
104  */
void platform_init_stage_two()
Stage 2 of platform driver initialisation.
Definition: platform.c:123
void populate_link_address(void)
Populates the link address using factory information.
Definition: linkaddr-arch.c:62
void platform_idle()
The platform&#39;s idle/sleep function.
Definition: platform.c:185
void leds_init(void)
Initialise the LED HAL.
Definition: minileds.c:44
UARTE header file for the nRF.
void reset_debug(void)
Logs the reset reason.
Definition: reset-arch.c:60
void gpio_hal_init()
Initialise the GPIO HAL.
Definition: gpio-hal.c:95
Reset reason implementation for the nRF.
void lpm_drop()
Drop the cortex to sleep / deep sleep and shut down peripherals.
Definition: lpm.c:525
int serial_line_input_byte(unsigned char c)
Get one byte of input from the serial driver.
Definition: serial-line.c:64
void uarte_init(void)
Initializa the UARTE driver.
Link address implementation for the nRF.
void platform_init_stage_three()
Final stage of platform driver initialisation.
Definition: platform.c:169
void random_init(unsigned short seed)
Seed the cc2538 random number generator.
Definition: random.c:84
void uarte_set_input(int(*input)(unsigned char c))
Sets the input handler called in the event handler.
Configuration for the nrf platform.
Generic serial I/O process header filer.
Header file for the GPIO HAL.
void button_hal_init()
Initialise the button HAL.
Definition: button-hal.c:213
Header file for the logging system
Header file for the LED HAL.
void platform_init_stage_one(void)
Basic (Stage 1) platform driver initialisation.
Definition: platform.c:114
Header file for the button HAL.
void process_start(struct process *p, process_data_t data)
Start a process.
Definition: process.c:99