Contiki-NG
Toggle main menu visibility
Loading...
Searching...
No Matches
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 "
dev/uart-arch.h
"
60
#include "sys/linkaddr-arch.h"
61
/*---------------------------------------------------------------------------*/
62
/* Log configuration */
63
#include "
sys/log.h
"
64
#define LOG_MODULE "GECKO"
65
#define LOG_LEVEL LOG_LEVEL_MAIN
66
/*---------------------------------------------------------------------------*/
67
static
void
68
sl_platform_init_stage_one(
void
)
69
{
70
CHIP_Init();
71
sl_device_init_nvic();
72
sl_board_preinit();
73
sl_device_init_dcdc();
74
sl_device_init_hfxo();
75
sl_device_init_lfxo();
76
sl_device_init_clocks();
77
sl_device_init_emu();
78
sl_board_init();
79
sl_power_manager_init();
80
}
81
/*---------------------------------------------------------------------------*/
82
static
void
83
sl_platform_init_stage_two(
void
)
84
{
85
sl_board_configure_vcom();
86
sl_sleeptimer_init();
87
}
88
/*---------------------------------------------------------------------------*/
89
void
90
platform_init_stage_one
(
void
)
91
{
92
sl_platform_init_stage_one();
93
94
gpio_hal_init
();
95
leds_init
();
96
}
97
/*---------------------------------------------------------------------------*/
98
void
99
platform_init_stage_two
(
void
)
100
{
101
sl_platform_init_stage_two();
102
103
button_hal_init
();
104
105
uart_init
();
106
serial_line_init();
107
108
#if BUILD_WITH_SHELL
109
uart_set_input
(serial_line_input_byte);
110
#endif
/* BUILD_WITH_SHELL */
111
112
populate_link_address
();
113
}
114
/*---------------------------------------------------------------------------*/
115
void
116
platform_init_stage_three
(
void
)
117
{
118
}
119
/*---------------------------------------------------------------------------*/
120
void
121
platform_idle
()
122
{
123
sl_power_manager_sleep();
124
}
125
/*---------------------------------------------------------------------------*/
126
/**
127
* @}
128
*/
button-hal.h
Header file for the button HAL.
gpio-hal.h
Header file for the GPIO HAL.
button_hal_init
void button_hal_init()
Initialise the button HAL.
Definition
button-hal.c:213
uart_set_input
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
platform_init_stage_three
void platform_init_stage_three()
Final stage of platform driver initialisation.
Definition
platform.c:165
platform_init_stage_one
void platform_init_stage_one(void)
Basic (Stage 1) platform driver initialisation.
Definition
platform.c:113
platform_idle
void platform_idle()
The platform's idle/sleep function.
Definition
platform.c:181
platform_init_stage_two
void platform_init_stage_two()
Stage 2 of platform driver initialisation.
Definition
platform.c:122
leds_init
void leds_init(void)
Initialise the LED HAL.
Definition
minileds.c:44
populate_link_address
void populate_link_address(void)
Populates the link address using factory information.
Definition
linkaddr-arch.c:64
uart_init
void uart_init(void)
Initializa the UART driver.
Definition
uart-arch.c:87
gpio_hal_init
void gpio_hal_init()
Initialise the GPIO HAL.
Definition
gpio-hal.c:95
leds.h
Header file for the LED HAL.
log.h
Header file for the logging system.
serial-line.h
Generic serial I/O process header filer.
uart-arch.h
UART header file for the gecko.
arch
platform
gecko
platform.c
Generated on
for Contiki-NG by
1.17.0