Contiki-NG
Toggle main menu visibility
Loading...
Searching...
No Matches
leds-arch.c
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2026, RISE Research Institutes of Sweden AB
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 Institute nor the names of its contributors
14
* may be used to endorse or promote products derived from this software
15
* without specific prior written permission.
16
*
17
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
18
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
21
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27
* SUCH DAMAGE.
28
*/
29
30
/**
31
* \file
32
* LED driver for MSP-EXP430FR5969 LaunchPad
33
*
34
* LED1 (Red): P1.0
35
* LED2 (Green): P4.6
36
*/
37
38
#include "contiki.h"
39
#include "
dev/leds.h
"
40
#include <msp430.h>
41
42
/*---------------------------------------------------------------------------*/
43
/* LED pin definitions */
44
#define LED_RED_BIT (1 << 0)
/* P1.0 */
45
#define LED_GREEN_BIT (1 << 6)
/* P4.6 */
46
47
/*---------------------------------------------------------------------------*/
48
void
49
leds_arch_init(
void
)
50
{
51
/* Set LED pins as outputs */
52
P1DIR |= LED_RED_BIT;
53
P4DIR |= LED_GREEN_BIT;
54
55
/* Turn off all LEDs initially */
56
P1OUT &= ~LED_RED_BIT;
57
P4OUT &= ~LED_GREEN_BIT;
58
}
59
/*---------------------------------------------------------------------------*/
60
leds_mask_t
61
leds_arch_get(
void
)
62
{
63
leds_mask_t
leds = 0;
64
65
if
(P1OUT & LED_RED_BIT) {
66
leds |= LEDS_RED;
67
}
68
if
(P4OUT & LED_GREEN_BIT) {
69
leds |= LEDS_GREEN;
70
}
71
72
return
leds;
73
}
74
/*---------------------------------------------------------------------------*/
75
void
76
leds_arch_set(
leds_mask_t
leds)
77
{
78
/* Red LED on P1.0 */
79
if
(leds & LEDS_RED) {
80
P1OUT |= LED_RED_BIT;
81
}
else
{
82
P1OUT &= ~LED_RED_BIT;
83
}
84
85
/* Green LED on P4.6 */
86
if
(leds & LEDS_GREEN) {
87
P4OUT |= LED_GREEN_BIT;
88
}
else
{
89
P4OUT &= ~LED_GREEN_BIT;
90
}
91
}
92
/*---------------------------------------------------------------------------*/
leds_mask_t
uint8_t leds_mask_t
An OR mask datatype to represents multiple LEDs.
Definition
leds.h:164
leds.h
Header file for the LED HAL.
arch
platform
msp-exp430fr5969
dev
leds-arch.c
Generated on
for Contiki-NG by
1.17.0