7 #if (HAS_SOC_CONTEXT_RETENTION)
8 #include "power_states.h"
11 #define ENABLE_PCLK (0x1)
21 static void (*callback[QM_GPIO_NUM])(
void *, uint32_t);
22 static void *callback_data[QM_GPIO_NUM];
24 static void gpio_isr(
const qm_gpio_t gpio)
26 const uint32_t int_status = QM_GPIO[gpio]->gpio_intstatus;
28 #if (HAS_SOC_CONTEXT_RETENTION)
29 if (QM_SCSS_GP->gps0 & QM_GPS0_POWER_STATES_MASK) {
35 (*callback[gpio])(callback_data[gpio], int_status);
39 QM_GPIO[gpio]->gpio_porta_eoi = int_status;
42 QM_GPIO[gpio]->gpio_porta_eoi;
48 QM_ISR_EOI(QM_IRQ_GPIO_0_INT_VECTOR);
54 gpio_isr(QM_AON_GPIO_0);
55 QM_ISR_EOI(QM_IRQ_AON_GPIO_0_INT_VECTOR);
62 QM_CHECK(gpio < QM_GPIO_NUM, -EINVAL);
63 QM_CHECK(cfg != NULL, -EINVAL);
88 QM_CHECK(gpio < QM_GPIO_NUM, -EINVAL);
89 QM_CHECK(pin <= QM_NUM_GPIO_PINS, -EINVAL);
90 QM_CHECK(state != NULL, -EINVAL);
92 *state = ((QM_GPIO[gpio]->gpio_ext_porta) >> pin) & 1;
99 QM_CHECK(gpio < QM_GPIO_NUM, -EINVAL);
100 QM_CHECK(pin <= QM_NUM_GPIO_PINS, -EINVAL);
102 QM_GPIO[gpio]->gpio_swporta_dr |= (1 << pin);
109 QM_CHECK(gpio < QM_GPIO_NUM, -EINVAL);
110 QM_CHECK(pin <= QM_NUM_GPIO_PINS, -EINVAL);
112 QM_GPIO[gpio]->gpio_swporta_dr &= ~(1 << pin);
120 QM_CHECK(gpio < QM_GPIO_NUM, -EINVAL);
121 QM_CHECK(pin <= QM_NUM_GPIO_PINS, -EINVAL);
124 uint32_t reg = QM_GPIO[gpio]->gpio_swporta_dr;
125 reg ^= (-state ^ reg) & (1 << pin);
126 QM_GPIO[gpio]->gpio_swporta_dr = reg;
133 QM_CHECK(gpio < QM_GPIO_NUM, -EINVAL);
134 QM_CHECK(port != NULL, -EINVAL);
136 *port = QM_GPIO[gpio]->gpio_ext_porta;
143 QM_CHECK(gpio < QM_GPIO_NUM, -EINVAL);
145 QM_GPIO[gpio]->gpio_swporta_dr = val;
150 #if (ENABLE_RESTORE_CONTEXT)
153 QM_CHECK(gpio < QM_GPIO_NUM, -EINVAL);
154 QM_CHECK(ctx != NULL, -EINVAL);
158 if (gpio == QM_GPIO_0) {
177 QM_CHECK(gpio < QM_GPIO_NUM, -EINVAL);
178 QM_CHECK(ctx != NULL, -EINVAL);
182 if (gpio == QM_GPIO_0) {
QM_RW uint32_t gpio_inten
Interrupt Enable.
QM_ISR_DECLARE(qm_gpio_0_isr)
ISR for GPIO 0 interrupt.
int qm_gpio_clear_pin(const qm_gpio_t gpio, const uint8_t pin)
Clear a single pin on a given GPIO port.
void qm_power_soc_restore(void)
Restore system state after sleep or deep sleep.
uint32_t int_polarity
Interrupt polarity, 0b: low, 1b: high.
uint32_t gpio_swporta_ddr
Port A Data Direction.
uint32_t direction
GPIO direction, 0b: input, 1b: output.
uint32_t gpio_inttype_level
Interrupt Type.
int qm_gpio_read_pin(const qm_gpio_t gpio, const uint8_t pin, qm_gpio_state_t *const state)
Read the current state of a single pin on a given GPIO port.
int qm_gpio_set_pin(const qm_gpio_t gpio, const uint8_t pin)
Set a single pin on a given GPIO port.
int qm_gpio_write_port(const qm_gpio_t gpio, const uint32_t val)
Write a value to every pin on a GPIO port.
qm_gpio_reg_t * qm_gpio[QM_GPIO_NUM]
GPIO register block.
uint32_t gpio_ls_sync
Synchronization Level.
uint32_t gpio_intmask
Interrupt Mask.
QM_RW uint32_t gpio_swporta_ddr
Port A Data Direction.
uint32_t int_debounce
Interrupt debounce on/off.
QM_RW uint32_t gpio_debounce
Debounce Enable.
void(* callback)(void *data, uint32_t int_status)
Transfer callback.
uint32_t gpio_int_polarity
Interrupt Polarity.
QM_RW uint32_t gpio_swporta_dr
Port A Data.
uint32_t int_type
Interrupt type, 0b: level; 1b: edge.
uint32_t int_bothedge
Interrupt on rising and falling edges.
uint32_t gpio_int_bothedge
Interrupt both edge type.
int qm_gpio_save_context(const qm_gpio_t gpio, qm_gpio_context_t *const ctx)
Save GPIO context.
QM_RW uint32_t gpio_swporta_ctl
Port A Data Source.
QM_RW uint32_t gpio_intmask
Interrupt Mask.
int qm_gpio_set_pin_state(const qm_gpio_t gpio, const uint8_t pin, const qm_gpio_state_t state)
Set or clear a single GPIO pin using a state variable.
QM_RW uint32_t gpio_int_polarity
Interrupt Polarity.
uint32_t gpio_inten
Interrupt Enable.
uint32_t int_en
Interrupt enable.
qm_gpio_state_t
GPIO pin states.
uint32_t gpio_swporta_dr
Port A Data.
qm_gpio_t
Number of GPIO controllers.
QM_RW uint32_t gpio_ls_sync
Synchronization Level.
uint32_t gpio_debounce
Debounce Enable.
int qm_gpio_read_port(const qm_gpio_t gpio, uint32_t *const port)
Read the value of every pin on a GPIO port.
QM_RW uint32_t gpio_inttype_level
Interrupt Type.
int qm_gpio_restore_context(const qm_gpio_t gpio, const qm_gpio_context_t *const ctx)
Restore GPIO context.
void * callback_data
Callback user data.
GPIO port configuration type.
uint32_t gpio_swporta_ctl
Port A Data Source.
int qm_gpio_set_config(const qm_gpio_t gpio, const qm_gpio_port_config_t *const cfg)
Set GPIO port configuration.
QM_RW uint32_t gpio_int_bothedge
Interrupt both edge type.