-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cpu/avr8: Enable PM periph to all SoC
This refactor the current xmega PM peripheral to avr8 common and extend PM to cpus families. Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
- Loading branch information
Showing
22 changed files
with
191 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
FEATURES_PROVIDED += arch_8bit | ||
FEATURES_PROVIDED += arch_avr8 | ||
FEATURES_PROVIDED += cpp | ||
FEATURES_PROVIDED += periph_pm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# All AVR-8 based CPUs provide PM | ||
CONFIG_MODULE_PM_LAYERED=y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
config MODULE_AVR8_COMMON_PERIPH | ||
bool | ||
depends on TEST_KCONFIG | ||
depends on CPU_COMMON_ATXMEGA | ||
default y | ||
help | ||
AVR8 common peripheral drivers. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
MODULE = avr8_common_periph | ||
|
||
include $(RIOTMAKE)/periph.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* Copyright (C) 2022-2023 Gerson Fernando Budke <nandojve@gmail.com> | ||
* | ||
* This file is subject to the terms and conditions of the GNU Lesser | ||
* General Public License v2.1. See the file LICENSE in the top level | ||
* directory for more details. | ||
*/ | ||
|
||
/** | ||
* @ingroup cpu_avr8_common | ||
* @ingroup cpu_avr8_common_periph | ||
* @{ | ||
* | ||
* @file | ||
* @brief Low-level PM driver implementation | ||
* | ||
* @author Gerson Fernando Budke <nandojve@gmail.com> | ||
* | ||
* @} | ||
*/ | ||
|
||
#include <avr/sleep.h> | ||
|
||
#include "irq.h" | ||
#include "periph_cpu.h" | ||
|
||
#define ENABLE_DEBUG 0 | ||
#include "debug.h" | ||
|
||
/** | ||
* @note: The pm_set assumes that interrupts are disable and there is no reason | ||
* to save SREG here. | ||
* | ||
* @note: DEBUG affects this routine. | ||
*/ | ||
void pm_set(unsigned mode) | ||
{ | ||
DEBUG("pm_set(%d)\n", mode); | ||
|
||
if (avr8_is_uart_tx_pending()) { | ||
mode = PM_NUM_MODES - 1; | ||
} | ||
|
||
switch (mode) { | ||
case 0: | ||
set_sleep_mode(AVR8_PM_SLEEP_MODE_0); | ||
break; | ||
#if PM_NUM_MODES > 1 | ||
case 1: | ||
set_sleep_mode(AVR8_PM_SLEEP_MODE_1); | ||
break; | ||
#endif | ||
#if PM_NUM_MODES > 2 | ||
case 2: | ||
set_sleep_mode(AVR8_PM_SLEEP_MODE_2); | ||
break; | ||
#endif | ||
#if PM_NUM_MODES > 3 | ||
case 3: | ||
set_sleep_mode(AVR8_PM_SLEEP_MODE_3); | ||
break; | ||
#endif | ||
default: | ||
set_sleep_mode(SLEEP_MODE_IDLE); | ||
break; | ||
} | ||
|
||
DEBUG("mode selected: %d\n", mode); | ||
|
||
/* | ||
* Critical Section to correct enable SLEEP instruction on RIOT-OS | ||
*/ | ||
#if (AVR8_PM_DISABLE_BOD_ON_SLEEP == 1) | ||
#ifdef sleep_bod_disable | ||
sleep_bod_disable(); | ||
#endif | ||
#endif | ||
sleep_enable(); | ||
sei(); | ||
sleep_cpu(); | ||
cli(); | ||
sleep_disable(); | ||
} |