Lazuli
Loading...
Searching...
No Matches
arch.c
Go to the documentation of this file.
1/*
2 * SPDX-License-Identifier: GPL-3.0-only
3 * This file is part of Lazuli.
4 */
5
17#include <stdint.h>
18
19#include <Lazuli/common.h>
20#include <Lazuli/config.h>
23
24#include "avr_arch.h"
25
26void
28{
29#if LZ_CONFIG_ON_IDLE_SLEEP && \
30 ((LZ_CONFIG_AVR_SLEEP_WITH_IDLE_MODE + \
31 LZ_CONFIG_AVR_SLEEP_WITH_ADC_NOISE_REDUCTION_MODE + \
32 LZ_CONFIG_AVR_SLEEP_WITH_POWER_DOWN_MODE + \
33 LZ_CONFIG_AVR_SLEEP_WITH_POWER_SAVE_MODE + \
34 LZ_CONFIG_AVR_SLEEP_WITH_STANDBY_MODE + \
35 LZ_CONFIG_AVR_SLEEP_WITH_EXTENDED_STANDBY_MODE) > 1)
36#error "Idle mode for architecture AVR must be unique."
37#endif
38
40 return;
41 }
42
44 SMCR = 0x02;
46 SMCR = 0x04;
48 SMCR = 0x06;
50 SMCR = 0x0c;
52 SMCR = 0x0e;
53 } else {
54 /* Default value : LZ_CONFIG_AVR_SLEEP_WITH_IDLE_MODE */
55 SMCR = 0x00;
56 }
57}
58
59void
66
67/* TODO: Put that in a module */
68void
70{
72 return;
73 }
74
75 /* Direction of the pin */
76 /* WARNING: This is very specific to the AVR ATmega328p. */
78 uint8_t,
81 uint8_t,
83}
unsigned char uint8_t
Represents a unsigned integer type with width of exactly 8 bits.
Definition stdint.h:89
void Arch_InitIdleCpuMode(void)
Initialize idle CPU modes.
Definition arch.c:27
void Arch_CpuSleep(void)
Put the CPU to sleep according to the sleep settings.
Definition arch.c:60
void Arch_InitInstrumentation(void)
Initialize the context switch instrumentation.
Definition arch.c:69
Architecture Abstraction API.
Header file specific to the AVR arch module.
void cpu_sleep(void)
Put the AVR CPU to sleep according to the sleep settings.
Basic type definitions and useful macros.
#define DIRECT(X)
Define a direct read/write register at an absolute address.
Definition common.h:194
#define SET_BITS(V, T, X)
Set the corresponding bits of X in the value V of type T.
Definition common.h:145
#define CLEAR_BITS(V, T, X)
Clear the corresponding bits of X in the value V of type T.
Definition common.h:158
#define POSITION(X)
Define a constant bit at position X, starting from index 0.
Definition common_asm.h:30
Include appropriate config file.
uint8_t LZ_CONFIG_AVR_INSTRUMENT_POSITION
The position in the port used for instrumentation on AVR machines.
const bool LZ_CONFIG_AVR_SLEEP_WITH_POWER_SAVE_MODE
Enter "Power-save Mode" when sleeping.
const bool LZ_CONFIG_AVR_SLEEP_WITH_ADC_NOISE_REDUCTION_MODE
Enter "ADC Noise Reduction Mode" when sleeping.
const bool LZ_CONFIG_AVR_SLEEP_WITH_STANDBY_MODE
Enter "Standby Mode" when sleeping.
const bool LZ_CONFIG_ON_IDLE_SLEEP
When 1, put the CPU to sleep when it's idle.
const bool LZ_CONFIG_INSTRUMENT_CONTEXT_SWITCHES
When set, add instrumentation code to measure context switches.
const bool LZ_CONFIG_AVR_SLEEP_WITH_POWER_DOWN_MODE
Enter "Power-down Mode" when sleeping.
const bool LZ_CONFIG_AVR_SLEEP_WITH_EXTENDED_STANDBY_MODE
Enter "Extended Standby Mode" when sleeping.
uint16_t LZ_CONFIG_AVR_INSTRUMENT_PORT
The port used for instrumentation on AVR machines.
ATmega328P registers.
#define SMCR
Sleep Mode Control Register
Definition registers.h:58