Contiki-NG
Toggle main menu visibility
Loading...
Searching...
No Matches
board.c
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2014, Texas Instruments Incorporated - http://www.ti.com/
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 srf06-common-peripherals
33
* @{
34
*
35
* \file
36
* Board-initialisation for the Srf06EB with a CC13xx/CC26xx EM.
37
*/
38
/*---------------------------------------------------------------------------*/
39
#include "contiki.h"
40
#include "
ti-lib.h
"
41
#include "lpm.h"
42
#include "prcm.h"
43
#include "hw_sysctl.h"
44
45
#include <stdint.h>
46
#include <string.h>
47
/*---------------------------------------------------------------------------*/
48
static
void
49
lpm_handler(uint8_t mode)
50
{
51
/* Ambient light sensor (off, output low) */
52
ti_lib_ioc_pin_type_gpio_output(BOARD_IOID_ALS_PWR);
53
ti_lib_gpio_clear_dio(BOARD_IOID_ALS_PWR);
54
ti_lib_ioc_pin_type_gpio_input(BOARD_IOID_ALS_OUT);
55
ti_lib_ioc_io_port_pull_set(BOARD_IOID_ALS_OUT, IOC_NO_IOPULL);
56
}
57
/*---------------------------------------------------------------------------*/
58
static
void
59
wakeup_handler(
void
)
60
{
61
/* Turn on the PERIPH PD */
62
ti_lib_prcm_power_domain_on(PRCM_DOMAIN_PERIPH);
63
while
((ti_lib_prcm_power_domain_status(PRCM_DOMAIN_PERIPH)
64
!= PRCM_DOMAIN_POWER_ON));
65
}
66
/*---------------------------------------------------------------------------*/
67
/*
68
* Declare a data structure to register with LPM.
69
* We don't care about what power mode we'll drop to, we don't care about
70
* getting notified before deep sleep. All we need is to be notified when we
71
* wake up so we can turn power domains back on
72
*/
73
LPM_MODULE
(srf_module, NULL, lpm_handler, wakeup_handler, LPM_DOMAIN_NONE);
74
/*---------------------------------------------------------------------------*/
75
static
void
76
configure_unused_pins(
void
)
77
{
78
/* Turn off 3.3-V domain (lcd/sdcard power, output low) */
79
ti_lib_ioc_pin_type_gpio_output(BOARD_IOID_3V3_EN);
80
ti_lib_gpio_clear_dio(BOARD_IOID_3V3_EN);
81
82
/* Accelerometer (PWR output low, CSn output, high) */
83
ti_lib_ioc_pin_type_gpio_output(BOARD_IOID_ACC_PWR);
84
ti_lib_gpio_clear_dio(BOARD_IOID_ACC_PWR);
85
}
86
/*---------------------------------------------------------------------------*/
87
void
88
board_init
()
89
{
90
uint8_t int_disabled = ti_lib_int_master_disable();
91
92
/* Turn on relevant PDs */
93
wakeup_handler();
94
95
/* Enable GPIO peripheral */
96
ti_lib_prcm_peripheral_run_enable(PRCM_PERIPH_GPIO);
97
98
/* Apply settings and wait for them to take effect */
99
ti_lib_prcm_load_set();
100
while
(!ti_lib_prcm_load_get());
101
102
lpm_register_module
(&srf_module);
103
104
configure_unused_pins();
105
106
/* Re-enable interrupt if initially enabled. */
107
if
(!int_disabled) {
108
ti_lib_int_master_enable();
109
}
110
}
111
/*---------------------------------------------------------------------------*/
112
/** @} */
LPM_MODULE
#define LPM_MODULE(n, m, s, w, l)
Declare a variable to be used in order to get notifications from LPM.
Definition
lpm.h:96
lpm_register_module
void lpm_register_module(lpm_registered_module_t *module)
Register a module for LPM notifications.
Definition
lpm.c:545
board_init
void board_init()
Board specific iniatialisation.
Definition
board.c:80
ti-lib.h
Header file with macros which rename TI CC26xxware functions.
arch
platform
cc26x0-cc13x0
srf06
board.c
Generated on
for Contiki-NG by
1.17.0