Contiki-NG
platform.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2022 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 gecko-platforms
33 * @{
34 *
35 * \file
36 * Platform implementation for gecko
37 * \author
38 * Yago Fontoura do Rosario <yago.rosario@hotmail.com.br>
39 */
40/*---------------------------------------------------------------------------*/
41#include "contiki.h"
42
43#include "em_chip.h"
44#include "sl_device_init_nvic.h"
45#include "sl_board_init.h"
46#include "sl_device_init_dcdc.h"
47#include "sl_device_init_hfxo.h"
48#include "sl_device_init_lfxo.h"
49#include "sl_device_init_clocks.h"
50#include "sl_device_init_emu.h"
51#include "sl_board_control.h"
52#include "sl_power_manager.h"
53#include "sl_sleeptimer.h"
54
55#include "dev/gpio-hal.h"
56#include "dev/button-hal.h"
57#include "dev/leds.h"
58#include "dev/serial-line.h"
59#include "lib/random.h"
60#include "dev/uart-arch.h"
61#include "sys/linkaddr-arch.h"
62/*---------------------------------------------------------------------------*/
63/* Log configuration */
64#include "sys/log.h"
65#define LOG_MODULE "GECKO"
66#define LOG_LEVEL LOG_LEVEL_MAIN
67/*---------------------------------------------------------------------------*/
68static void
69sl_platform_init_stage_one(void)
70{
71 CHIP_Init();
72 sl_device_init_nvic();
73 sl_board_preinit();
74 sl_device_init_dcdc();
75 sl_device_init_hfxo();
76 sl_device_init_lfxo();
77 sl_device_init_clocks();
78 sl_device_init_emu();
79 sl_board_init();
80 sl_power_manager_init();
81}
82/*---------------------------------------------------------------------------*/
83static void
84sl_platform_init_stage_two(void)
85{
86 sl_board_configure_vcom();
87 sl_sleeptimer_init();
88}
89/*---------------------------------------------------------------------------*/
90void
92{
93 sl_platform_init_stage_one();
94
96 leds_init();
97}
98/*---------------------------------------------------------------------------*/
99void
101{
102 sl_platform_init_stage_two();
103
105
106 random_init(0x5678);
107
108 uart_init();
109 serial_line_init();
110
111#if BUILD_WITH_SHELL
113#endif /* BUILD_WITH_SHELL */
114
116}
117/*---------------------------------------------------------------------------*/
118void
120{
121}
122/*---------------------------------------------------------------------------*/
123void
125{
126 sl_power_manager_sleep();
127}
128/*---------------------------------------------------------------------------*/
129/**
130 * @}
131 */
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 uart_set_input(uint8_t uart, int(*input)(unsigned char c))
Assigns a callback to be called when the UART receives a byte.
Definition: uart.c:334
void uart_init(uint8_t uart)
Initialises the UART controller, configures I/O control and interrupts.
Definition: uart.c:241
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 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
Header file for the LED HAL.
Header file for the logging system.
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
UART header file for the gecko.