atmega_common: abstract Power Reduction Register
PR Register is PRR0 on atmega2560 and atmega1281 but PRR on atmega328p. this abstracts as atmega Power Reduction Register as MEGA_PRR.
This commit is contained in:
parent
4c3c0d9571
commit
2cd918a07a
@ -97,6 +97,7 @@ extern "C" {
|
|||||||
*/
|
*/
|
||||||
#define SPI_NUMOF 1 /* set to 0 to disable SPI */
|
#define SPI_NUMOF 1 /* set to 0 to disable SPI */
|
||||||
#define SPI_0_EN 1 /* remove once SPI rework is done */
|
#define SPI_0_EN 1 /* remove once SPI rework is done */
|
||||||
|
#define MEGA_PRR PRR0 /* Power Reduction Register is PRR0 */
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
@ -104,6 +104,7 @@ extern "C" {
|
|||||||
*/
|
*/
|
||||||
#define SPI_NUMOF 1 /* set to 0 to disable SPI */
|
#define SPI_NUMOF 1 /* set to 0 to disable SPI */
|
||||||
#define SPI_0_EN 1 /* remove once SPI rework is done */
|
#define SPI_0_EN 1 /* remove once SPI rework is done */
|
||||||
|
#define MEGA_PRR PRR0 /* Power Reduction Resgister */
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
@ -133,7 +133,9 @@ int gpio_init_int(gpio_t pin, gpio_mode_t mode, gpio_flank_t flank,
|
|||||||
uint8_t pin_num = _pin_num(pin);
|
uint8_t pin_num = _pin_num(pin);
|
||||||
|
|
||||||
if ((_port_num(pin) == PORT_D && pin_num > 3)
|
if ((_port_num(pin) == PORT_D && pin_num > 3)
|
||||||
|
#if defined (PORTE)
|
||||||
|| (_port_num(pin) == PORT_E && pin_num < 4)
|
|| (_port_num(pin) == PORT_E && pin_num < 4)
|
||||||
|
#endif
|
||||||
|| ((mode != GPIO_IN) && (mode != GPIO_IN_PU))) {
|
|| ((mode != GPIO_IN) && (mode != GPIO_IN_PU))) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -61,7 +61,7 @@ int spi_init_master(spi_t dev, spi_conf_t conf, spi_speed_t speed)
|
|||||||
DDRB |= ((1 << DDB2) | (1 << DDB1) | (1 << DDB0));
|
DDRB |= ((1 << DDB2) | (1 << DDB1) | (1 << DDB0));
|
||||||
|
|
||||||
/* make sure the SPI is not powered off */
|
/* make sure the SPI is not powered off */
|
||||||
PRR0 &= ~(1 << PRSPI);
|
MEGA_PRR &= ~(1 << PRSPI);
|
||||||
|
|
||||||
/* configure as master, with given mode and clock */
|
/* configure as master, with given mode and clock */
|
||||||
SPSR = (speed >> S2X_SHIFT);
|
SPSR = (speed >> S2X_SHIFT);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user