1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

cpu/atmega_common: Add PM on peripherals

Add PM blocks to adc/i2c/spi peripherals.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
This commit is contained in:
Gerson Fernando Budke 2022-10-20 19:35:17 +02:00 committed by Marian Buschsieweke
parent 549e2b4de1
commit 9dfdedcaf7
No known key found for this signature in database
GPG Key ID: 77AA882EC78084E6
3 changed files with 9 additions and 0 deletions

View File

@ -25,6 +25,7 @@
#include "cpu.h"
#include "mutex.h"
#include "periph/adc.h"
#include "periph/pm.h"
#include "periph_conf.h"
#define ADC_MAX_CLK (200000U)
@ -33,6 +34,7 @@ static mutex_t lock = MUTEX_INIT;
static inline void _prep(void)
{
pm_block(3); /* Require clkADC */
mutex_lock(&lock);
/* Enable ADC */
ADCSRA |= (1 << ADEN);
@ -43,6 +45,7 @@ static inline void _done(void)
/* Disable ADC */
ADCSRA &= ~(1 << ADEN);
mutex_unlock(&lock);
pm_unblock(3);
}
int adc_init(adc_t line)

View File

@ -31,6 +31,7 @@
#include "cpu.h"
#include "mutex.h"
#include "periph/i2c.h"
#include "periph/pm.h"
#include "periph_conf.h"
#define ENABLE_DEBUG 0
@ -226,6 +227,7 @@ void i2c_acquire(i2c_t dev)
{
assert(dev < I2C_NUMOF);
pm_block(4); /* Require clkIO */
mutex_lock(&locks[dev]);
}
@ -234,6 +236,7 @@ void i2c_release(i2c_t dev)
assert(dev < I2C_NUMOF);
mutex_unlock(&locks[dev]);
pm_unblock(4);
}
static void i2c_poweron(i2c_t dev)

View File

@ -31,6 +31,7 @@
#include "cpu.h"
#include "mutex.h"
#include "periph/spi.h"
#include "periph/pm.h"
/**
* @brief Extract BR0, BR1 and SPI2X bits from speed value
@ -89,6 +90,7 @@ void spi_acquire(spi_t bus, spi_cs_t cs, spi_mode_t mode, spi_clk_t clk)
assert(bus == SPI_DEV(0));
/* lock the bus and power on the SPI peripheral */
pm_block(4); /* Require clkIO */
mutex_lock(&lock);
#ifdef PRSPI
power_spi_enable();
@ -112,6 +114,7 @@ void spi_release(spi_t bus)
power_spi_disable();
#endif
mutex_unlock(&lock);
pm_unblock(4);
}
void spi_transfer_bytes(spi_t bus, spi_cs_t cs, bool cont,