Contiki-NG
Toggle main menu visibility
Loading...
Searching...
No Matches
gpio.c
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2012, 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
*
14
* 3. Neither the name of the copyright holder nor the names of its
15
* contributors may be used to endorse or promote products derived
16
* from this software without specific prior written permission.
17
*
18
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
23
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
27
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
29
* OF THE POSSIBILITY OF SUCH DAMAGE.
30
*/
31
/**
32
* \addtogroup cc2538-gpio
33
* @{
34
*
35
* \file
36
* Implementation of the cc2538 GPIO controller
37
*/
38
#include "contiki.h"
39
#include "
dev/leds.h
"
40
#include "
dev/gpio-hal.h
"
41
#include "
dev/gpio.h
"
42
#include "
dev/nvic.h
"
43
#include "
reg.h
"
44
#include "lpm.h"
45
46
#include <string.h>
47
/*---------------------------------------------------------------------------*/
48
/** \brief Interrupt service routine for Port \a port
49
* \param port Number between 0 and 3. Port A: 0, Port B: 1, etc.
50
*/
51
static
void
52
gpio_port_isr
(uint8_t port)
53
{
54
uint32_t base;
55
uint8_t
int_status
, power_up_int_status;
56
57
lpm_exit();
58
59
base =
GPIO_PORT_TO_BASE
(port);
60
int_status
=
GPIO_GET_MASKED_INT_STATUS
(base);
61
power_up_int_status =
GPIO_GET_POWER_UP_INT_STATUS
(port);
62
63
gpio_hal_event_handler((
int_status
| power_up_int_status) << (port << 3));
64
65
GPIO_CLEAR_INTERRUPT
(base,
int_status
);
66
GPIO_CLEAR_POWER_UP_INTERRUPT
(port, power_up_int_status);
67
}
68
/*---------------------------------------------------------------------------*/
69
#define GPIO_PORT_ISR(lowercase_port, uppercase_port) \
70
void \
71
gpio_port_##lowercase_port##_isr(void) \
72
{ \
73
gpio_port_isr(GPIO_##uppercase_port##_NUM); \
74
}
75
GPIO_PORT_ISR(a, A)
76
GPIO_PORT_ISR(b, B)
77
GPIO_PORT_ISR(c, C)
78
GPIO_PORT_ISR(d, D)
79
/*---------------------------------------------------------------------------*/
80
/** @} */
gpio-hal.h
Header file for the GPIO HAL.
gpio.h
Header file with register and macro declarations for the cc2538 GPIO module.
gpio_port_isr
static void gpio_port_isr(uint8_t port)
Interrupt service routine for Port port.
Definition
gpio.c:52
GPIO_GET_POWER_UP_INT_STATUS
#define GPIO_GET_POWER_UP_INT_STATUS(PORT)
Get power-up interrupt status of port PORT.
Definition
gpio.h:302
GPIO_PORT_TO_BASE
#define GPIO_PORT_TO_BASE(PORT)
Converts a port number to the port base address.
Definition
gpio.h:328
GPIO_CLEAR_INTERRUPT
#define GPIO_CLEAR_INTERRUPT(PORT_BASE, PIN_MASK)
Clear interrupt triggering for pins with PIN_MASK of port with PORT_BASE.
Definition
gpio.h:242
GPIO_GET_MASKED_INT_STATUS
#define GPIO_GET_MASKED_INT_STATUS(PORT_BASE)
Get masked interrupt status of port with PORT_BASE.
Definition
gpio.h:234
GPIO_CLEAR_POWER_UP_INTERRUPT
#define GPIO_CLEAR_POWER_UP_INTERRUPT(PORT, PIN_MASK)
Clear power-up interrupt triggering for pins with PIN_MASK of port PORT.
Definition
gpio.h:310
int_status
static uint8_t int_status(void)
Check whether a data or wake on motion interrupt has occurred.
Definition
mpu-9250-sensor.c:347
leds.h
Header file for the LED HAL.
nvic.h
Header file for the ARM Nested Vectored Interrupt Controller.
reg.h
Header file with register manipulation macro definitions.
arch
cpu
cc2538
dev
gpio.c
Generated on
for Contiki-NG by
1.17.0