Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
contiki-ng
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
NATAF Emmanuel
contiki-ng
Commits
5c9785a7
Unverified
Commit
5c9785a7
authored
6 years ago
by
George Oikonomou
Committed by
GitHub
6 years ago
Browse files
Options
Downloads
Plain Diff
Merge branch 'develop' into bugfix/zoul-pm
parents
58ab4c0e
ff709d29
No related branches found
No related tags found
No related merge requests found
Changes
24
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
os/dev/leds.c
+30
-12
30 additions, 12 deletions
os/dev/leds.c
os/dev/leds.h
+9
-0
9 additions, 0 deletions
os/dev/leds.h
os/dev/spi.c
+2
-2
2 additions, 2 deletions
os/dev/spi.c
os/dev/spi.h
+24
-0
24 additions, 0 deletions
os/dev/spi.h
with
65 additions
and
14 deletions
os/dev/leds.c
+
30
−
12
View file @
5c9785a7
...
...
@@ -103,13 +103,20 @@ extern const leds_t leds_arch_leds[];
static
const
leds_t
*
leds_arch_leds
=
NULL
;
#endif
/*---------------------------------------------------------------------------*/
#if GPIO_HAL_PORT_PIN_NUMBERING
#define LED_PORT(led) (led).port
#else
#define LED_PORT(led) GPIO_HAL_NULL_PORT
#endif
/*---------------------------------------------------------------------------*/
void
leds_init
()
{
leds_num_t
led
;
for
(
led
=
0
;
led
<
LEDS_COUNT
;
led
++
)
{
gpio_hal_arch_pin_set_output
(
leds_arch_leds
[
led
].
pin
);
gpio_hal_arch_pin_set_output
(
LED_PORT
(
leds_arch_leds
[
led
]),
leds_arch_leds
[
led
].
pin
);
}
leds_off
(
LEDS_ALL
);
}
...
...
@@ -122,9 +129,11 @@ leds_single_on(leds_num_t led)
}
if
(
leds_arch_leds
[
led
].
negative_logic
)
{
gpio_hal_arch_clear_pin
(
leds_arch_leds
[
led
].
pin
);
gpio_hal_arch_clear_pin
(
LED_PORT
(
leds_arch_leds
[
led
]),
leds_arch_leds
[
led
].
pin
);
}
else
{
gpio_hal_arch_set_pin
(
leds_arch_leds
[
led
].
pin
);
gpio_hal_arch_set_pin
(
LED_PORT
(
leds_arch_leds
[
led
]),
leds_arch_leds
[
led
].
pin
);
}
}
/*---------------------------------------------------------------------------*/
...
...
@@ -136,9 +145,11 @@ leds_single_off(leds_num_t led)
}
if
(
leds_arch_leds
[
led
].
negative_logic
)
{
gpio_hal_arch_set_pin
(
leds_arch_leds
[
led
].
pin
);
gpio_hal_arch_set_pin
(
LED_PORT
(
leds_arch_leds
[
led
]),
leds_arch_leds
[
led
].
pin
);
}
else
{
gpio_hal_arch_clear_pin
(
leds_arch_leds
[
led
].
pin
);
gpio_hal_arch_clear_pin
(
LED_PORT
(
leds_arch_leds
[
led
]),
leds_arch_leds
[
led
].
pin
);
}
}
/*---------------------------------------------------------------------------*/
...
...
@@ -149,7 +160,8 @@ leds_single_toggle(leds_num_t led)
return
;
}
gpio_hal_arch_toggle_pin
(
leds_arch_leds
[
led
].
pin
);
gpio_hal_arch_toggle_pin
(
LED_PORT
(
leds_arch_leds
[
led
]),
leds_arch_leds
[
led
].
pin
);
}
/*---------------------------------------------------------------------------*/
void
...
...
@@ -160,9 +172,11 @@ leds_on(leds_mask_t leds)
for
(
led
=
0
;
led
<
LEDS_COUNT
;
led
++
)
{
if
((
1
<<
led
)
&
leds
)
{
if
(
leds_arch_leds
[
led
].
negative_logic
)
{
gpio_hal_arch_clear_pin
(
leds_arch_leds
[
led
].
pin
);
gpio_hal_arch_clear_pin
(
LED_PORT
(
leds_arch_leds
[
led
]),
leds_arch_leds
[
led
].
pin
);
}
else
{
gpio_hal_arch_set_pin
(
leds_arch_leds
[
led
].
pin
);
gpio_hal_arch_set_pin
(
LED_PORT
(
leds_arch_leds
[
led
]),
leds_arch_leds
[
led
].
pin
);
}
}
}
...
...
@@ -176,9 +190,11 @@ leds_off(leds_mask_t leds)
for
(
led
=
0
;
led
<
LEDS_COUNT
;
led
++
)
{
if
((
1
<<
led
)
&
leds
)
{
if
(
leds_arch_leds
[
led
].
negative_logic
)
{
gpio_hal_arch_set_pin
(
leds_arch_leds
[
led
].
pin
);
gpio_hal_arch_set_pin
(
LED_PORT
(
leds_arch_leds
[
led
]),
leds_arch_leds
[
led
].
pin
);
}
else
{
gpio_hal_arch_clear_pin
(
leds_arch_leds
[
led
].
pin
);
gpio_hal_arch_clear_pin
(
LED_PORT
(
leds_arch_leds
[
led
]),
leds_arch_leds
[
led
].
pin
);
}
}
}
...
...
@@ -191,7 +207,8 @@ leds_toggle(leds_mask_t leds)
for
(
led
=
0
;
led
<
LEDS_COUNT
;
led
++
)
{
if
((
1
<<
led
)
&
leds
)
{
gpio_hal_arch_toggle_pin
(
leds_arch_leds
[
led
].
pin
);
gpio_hal_arch_toggle_pin
(
LED_PORT
(
leds_arch_leds
[
led
]),
leds_arch_leds
[
led
].
pin
);
}
}
}
...
...
@@ -211,7 +228,8 @@ leds_get()
uint8_t
pin_state
;
for
(
led
=
0
;
led
<
LEDS_COUNT
;
led
++
)
{
pin_state
=
gpio_hal_arch_read_pin
(
leds_arch_leds
[
led
].
pin
);
pin_state
=
gpio_hal_arch_read_pin
(
LED_PORT
(
leds_arch_leds
[
led
]),
leds_arch_leds
[
led
].
pin
);
if
((
leds_arch_leds
[
led
].
negative_logic
==
false
&&
pin_state
==
1
)
||
(
leds_arch_leds
[
led
].
negative_logic
==
true
&&
pin_state
==
0
))
{
...
...
This diff is collapsed.
Click to expand it.
os/dev/leds.h
+
9
−
0
View file @
5c9785a7
...
...
@@ -208,10 +208,19 @@ void leds_arch_set(leds_mask_t leds);
* \e pin corresponds to the GPIO pin a LED is driven by, using GPIO HAL pin
* representation.
*
* \e port corresponds to the GPIO port that the pin is connected to. This
* only makes sense if GPIO_HAL_CONF_PORT_PIN_NUMBERING is non-zero.
*
* \e negative_logic should be set to false if the LED is active low.
*
* \note Do not access the \e port member of this struct direct, use the
* LED_PORT() macro instead.
*/
typedef
struct
leds_s
{
gpio_hal_pin_t
pin
;
#if GPIO_HAL_PORT_PIN_NUMBERING
gpio_hal_port_t
port
;
#endif
bool
negative_logic
;
}
leds_t
;
/*---------------------------------------------------------------------------*/
...
...
This diff is collapsed.
Click to expand it.
os/dev/spi.c
+
2
−
2
View file @
5c9785a7
...
...
@@ -71,7 +71,7 @@ spi_select(const spi_device_t *dev)
return
SPI_DEV_STATUS_BUS_NOT_OWNED
;
}
gpio_hal_arch_clear_pin
(
dev
->
pin_spi_cs
);
gpio_hal_arch_clear_pin
(
SPI_DEVICE_PORT
(
cs
,
dev
),
dev
->
pin_spi_cs
);
return
SPI_DEV_STATUS_OK
;
}
...
...
@@ -79,7 +79,7 @@ spi_select(const spi_device_t *dev)
spi_status_t
spi_deselect
(
const
spi_device_t
*
dev
)
{
gpio_hal_arch_set_pin
(
dev
->
pin_spi_cs
);
gpio_hal_arch_set_pin
(
SPI_DEVICE_PORT
(
cs
,
dev
),
dev
->
pin_spi_cs
);
return
SPI_DEV_STATUS_OK
;
}
...
...
This diff is collapsed.
Click to expand it.
os/dev/spi.h
+
24
−
0
View file @
5c9785a7
...
...
@@ -92,10 +92,18 @@ typedef enum {
*
* This is a structure to an architecture-independent SPI configuration.
*
* \note Do not access the port_spi_foo members directly. Access them by using
* the SPI_DEVICE_PORT() macro instead
* @{
*/
typedef
struct
spi_device
{
#if GPIO_HAL_PORT_PIN_NUMBERING
gpio_hal_port_t
port_spi_sck
;
/* SPI SCK port */
gpio_hal_port_t
port_spi_miso
;
/* SPI MISO port */
gpio_hal_port_t
port_spi_mosi
;
/* SPI MOSI port */
gpio_hal_port_t
port_spi_cs
;
/* SPI Chip Select port */
#endif
gpio_hal_pin_t
pin_spi_sck
;
/* SPI SCK pin */
gpio_hal_pin_t
pin_spi_miso
;
/* SPI MISO pin */
gpio_hal_pin_t
pin_spi_mosi
;
/* SPI MOSI pin */
...
...
@@ -107,6 +115,22 @@ typedef struct spi_device {
}
spi_device_t
;
/** @} */
/*---------------------------------------------------------------------------*/
/**
* \brief Retrieve the SPI device's port number if applicable
* \param member Retrieve struct member port_spi_member (e.g. port_spi_miso)
* \param device A pointer the a variable of type spi_device_t
*
* The same macro is used for all four port_spi_foo members of the struct. So
* to retrieve port_spi_cs, use SPI_DEVICE_PORT(cs, device). Replace cs with
* mosi to retrieve port_spi_mosi.
*
*/
#if GPIO_HAL_PORT_PIN_NUMBERING
#define SPI_DEVICE_PORT(member, device) (device)->port_spi_##member
#else
#define SPI_DEVICE_PORT(member, device) GPIO_HAL_NULL_PORT
#endif
/*---------------------------------------------------------------------------*/
/* These are architecture-independent functions to be used by SPI devices. */
/*---------------------------------------------------------------------------*/
/**
...
...
This diff is collapsed.
Click to expand it.
Prev
1
2
Next
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment