libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
common/periph.h File Reference
Include dependency graph for common/periph.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define PERIPH_CLOCK_ID   (0x00)
 
#define PERIPH_POWER_ID   (0x00)
 
#define PERIPH_MPU_ID   (0x00)
 
#define PERIPH_RADIO_ID   (0x01)
 
#define PERIPH_UART_ID   (0x02)
 
#define PERIPH_SPI0_ID   (0x03)
 
#define PERIPH_TWI0_ID   (0x03)
 
#define PERIPH_I2C0_ID   (0x03)
 
#define PERIPH_SPI1_ID   (0x04)
 
#define PERIPH_SPIS1_ID   (0x04)
 
#define PERIPH_TWI1_ID   (0x04)
 
#define PERIPH_I2C1_ID   (0x04)
 
#define PERIPH_GPIOTE_ID   (0x06)
 
#define PERIPH_ADC_ID   (0x07)
 
#define PERIPH_TIMER0_ID   (0x08)
 
#define PERIPH_TIMER1_ID   (0x09)
 
#define PERIPH_TIMER2_ID   (0x0a)
 
#define PERIPH_RTC0_ID   (0x0b)
 
#define PERIPH_TEMP_ID   (0x0c)
 
#define PERIPH_RNG_ID   (0x0d)
 
#define PERIPH_ECB_ID   (0x0e)
 
#define PERIPH_AAR_ID   (0x0f)
 
#define PERIPH_CCM_ID   (0x0f)
 
#define PERIPH_WDT_ID   (0x10)
 
#define PERIPH_RTC1_ID   (0x11)
 
#define PERIPH_QDEC_ID   (0x12)
 
#define PERIPH_LPCOMP_ID   (0x13)
 
#define PERIPH_SWI0_ID   (0x14)
 
#define PERIPH_SWI1_ID   (0x15)
 
#define PERIPH_SWI2_ID   (0x16)
 
#define PERIPH_SWI3_ID   (0x17)
 
#define PERIPH_SWI4_ID   (0x18)
 
#define PERIPH_SWI5_ID   (0x19)
 
#define PERIPH_NVMC_ID   (0x1e)
 
#define PERIPH_PPI_ID   (0x1f)
 
#define PERIPH_BASE_FROM_ID(periph_id)   (ABP_BASE + 0x1000 * (periph_id))
 
#define PERIPH_ID_FROM_BASE(base)   (((base) - APB_BASE) >> 12)
 
#define PERIPH_BASE_FROM_REG(reg)   (((uint32_t) &(reg)) & 0xfffff000)
 
#define PERIPH_TASK_OFFSET   (0x000)
 Starting address of all the tasks in the peripheral. More...
 
#define PERIPH_EVENT_OFFSET   (0x100)
 Starting address of all the events in the peripheral. More...
 
#define PERIPH_TRIGGER_TASK(task)   (task) = (1)
 
#define PERIPH_ENABLE_IRQ(base)   nvic_enable_irq(periph_id_from_base(base))
 
#define PERIPH_DISABLE_IRQ(base)   nvic_disable_irq(periph_id_from_base(base))
 
#define PERIPH_SHORTS_OFFSET   (0x200)
 
#define PERIPH_INTEN_OFFSET   (0x300)
 
#define PERIPH_INTENSET_OFFSET   (0x304)
 
#define PERIPH_INTENCLR_OFFSET   (0x308)
 
#define _PERIPH_SHORTS(base)   MMIO32((base) + PERIPH_SHORTS_OFFSET)
 
#define _PERIPH_INTEN(base)   MMIO32((base) + PERIPH_INTEN_OFFSET)
 
#define _PERIPH_INTENSET(base)   MMIO32((base) + PERIPH_INTENSET_OFFSET)
 
#define _PERIPH_INTENCLR(base)   MMIO32((base) + PERIPH_INTENCLR_OFFSET)
 
#define periph_enable_shorts(base, shorts)   periph_shorts(base) |= (shorts)
 
#define periph_disable_shorts(base, shorts)   periph_shorts(base) &= (~(shorts))
 
#define periph_clear_shorts(base)   periph_shorts(base) = (0)
 
#define periph_enable_interrupts(base, mask)   periph_intenset(base) |= (mask)
 
#define periph_disable_interrupts(base, mask)   periph_intenclr(base) = (mask)
 
#define periph_clear_interrupts(base)   periph_intenclr(base) = (0xffffffff)
 
#define GPIO_UNCONNECTED   0xFFFFFFFFU
 Mark the signal as not connected to any pin. More...
 
#define __GPIO2PIN(x)   (31 - __builtin_clz((uint32_t) (x)))
 This is an approximation of log2. More...
 

Macro Definition Documentation

◆ __GPIO2PIN

#define __GPIO2PIN (   x)    (31 - __builtin_clz((uint32_t) (x)))

This is an approximation of log2.

As used here, works correctly only for single bit set, which should be the case when used to. convert above GPIOxy macros to pin numbers as needed for PSEL registers of peripherals.

Definition at line 146 of file common/periph.h.

◆ _PERIPH_INTEN

#define _PERIPH_INTEN (   base)    MMIO32((base) + PERIPH_INTEN_OFFSET)

Definition at line 125 of file common/periph.h.

◆ _PERIPH_INTENCLR

#define _PERIPH_INTENCLR (   base)    MMIO32((base) + PERIPH_INTENCLR_OFFSET)

Definition at line 127 of file common/periph.h.

◆ _PERIPH_INTENSET

#define _PERIPH_INTENSET (   base)    MMIO32((base) + PERIPH_INTENSET_OFFSET)

Definition at line 126 of file common/periph.h.

◆ _PERIPH_SHORTS

#define _PERIPH_SHORTS (   base)    MMIO32((base) + PERIPH_SHORTS_OFFSET)

Definition at line 124 of file common/periph.h.

◆ GPIO_UNCONNECTED

#define GPIO_UNCONNECTED   0xFFFFFFFFU

Mark the signal as not connected to any pin.

Definition at line 139 of file common/periph.h.

◆ PERIPH_AAR_ID

#define PERIPH_AAR_ID   (0x0f)

Definition at line 61 of file common/periph.h.

◆ PERIPH_ADC_ID

#define PERIPH_ADC_ID   (0x07)

Definition at line 53 of file common/periph.h.

◆ PERIPH_BASE_FROM_ID

#define PERIPH_BASE_FROM_ID (   periph_id)    (ABP_BASE + 0x1000 * (periph_id))

Definition at line 76 of file common/periph.h.

◆ PERIPH_BASE_FROM_REG

#define PERIPH_BASE_FROM_REG (   reg)    (((uint32_t) &(reg)) & 0xfffff000)

Definition at line 78 of file common/periph.h.

◆ PERIPH_CCM_ID

#define PERIPH_CCM_ID   (0x0f)

Definition at line 62 of file common/periph.h.

◆ periph_clear_interrupts

#define periph_clear_interrupts (   base)    periph_intenclr(base) = (0xffffffff)

Definition at line 136 of file common/periph.h.

◆ periph_clear_shorts

#define periph_clear_shorts (   base)    periph_shorts(base) = (0)

Definition at line 132 of file common/periph.h.

◆ PERIPH_CLOCK_ID

#define PERIPH_CLOCK_ID   (0x00)

Definition at line 40 of file common/periph.h.

◆ periph_disable_interrupts

#define periph_disable_interrupts (   base,
  mask 
)    periph_intenclr(base) = (mask)

Definition at line 135 of file common/periph.h.

◆ PERIPH_DISABLE_IRQ

#define PERIPH_DISABLE_IRQ (   base)    nvic_disable_irq(periph_id_from_base(base))

Definition at line 114 of file common/periph.h.

◆ periph_disable_shorts

#define periph_disable_shorts (   base,
  shorts 
)    periph_shorts(base) &= (~(shorts))

Definition at line 131 of file common/periph.h.

◆ PERIPH_ECB_ID

#define PERIPH_ECB_ID   (0x0e)

Definition at line 60 of file common/periph.h.

◆ periph_enable_interrupts

#define periph_enable_interrupts (   base,
  mask 
)    periph_intenset(base) |= (mask)

Definition at line 134 of file common/periph.h.

◆ PERIPH_ENABLE_IRQ

#define PERIPH_ENABLE_IRQ (   base)    nvic_enable_irq(periph_id_from_base(base))

Definition at line 113 of file common/periph.h.

◆ periph_enable_shorts

#define periph_enable_shorts (   base,
  shorts 
)    periph_shorts(base) |= (shorts)

Definition at line 130 of file common/periph.h.

◆ PERIPH_EVENT_OFFSET

#define PERIPH_EVENT_OFFSET   (0x100)

Starting address of all the events in the peripheral.

Definition at line 103 of file common/periph.h.

◆ PERIPH_GPIOTE_ID

#define PERIPH_GPIOTE_ID   (0x06)

Definition at line 52 of file common/periph.h.

◆ PERIPH_I2C0_ID

#define PERIPH_I2C0_ID   (0x03)

Definition at line 47 of file common/periph.h.

◆ PERIPH_I2C1_ID

#define PERIPH_I2C1_ID   (0x04)

Definition at line 51 of file common/periph.h.

◆ PERIPH_ID_FROM_BASE

#define PERIPH_ID_FROM_BASE (   base)    (((base) - APB_BASE) >> 12)

Definition at line 77 of file common/periph.h.

◆ PERIPH_INTEN_OFFSET

#define PERIPH_INTEN_OFFSET   (0x300)

Definition at line 120 of file common/periph.h.

◆ PERIPH_INTENCLR_OFFSET

#define PERIPH_INTENCLR_OFFSET   (0x308)

Definition at line 122 of file common/periph.h.

◆ PERIPH_INTENSET_OFFSET

#define PERIPH_INTENSET_OFFSET   (0x304)

Definition at line 121 of file common/periph.h.

◆ PERIPH_LPCOMP_ID

#define PERIPH_LPCOMP_ID   (0x13)

Definition at line 66 of file common/periph.h.

◆ PERIPH_MPU_ID

#define PERIPH_MPU_ID   (0x00)

Definition at line 42 of file common/periph.h.

◆ PERIPH_NVMC_ID

#define PERIPH_NVMC_ID   (0x1e)

Definition at line 73 of file common/periph.h.

◆ PERIPH_POWER_ID

#define PERIPH_POWER_ID   (0x00)

Definition at line 41 of file common/periph.h.

◆ PERIPH_PPI_ID

#define PERIPH_PPI_ID   (0x1f)

Definition at line 74 of file common/periph.h.

◆ PERIPH_QDEC_ID

#define PERIPH_QDEC_ID   (0x12)

Definition at line 65 of file common/periph.h.

◆ PERIPH_RADIO_ID

#define PERIPH_RADIO_ID   (0x01)

Definition at line 43 of file common/periph.h.

◆ PERIPH_RNG_ID

#define PERIPH_RNG_ID   (0x0d)

Definition at line 59 of file common/periph.h.

◆ PERIPH_RTC0_ID

#define PERIPH_RTC0_ID   (0x0b)

Definition at line 57 of file common/periph.h.

◆ PERIPH_RTC1_ID

#define PERIPH_RTC1_ID   (0x11)

Definition at line 64 of file common/periph.h.

◆ PERIPH_SHORTS_OFFSET

#define PERIPH_SHORTS_OFFSET   (0x200)

Definition at line 119 of file common/periph.h.

◆ PERIPH_SPI0_ID

#define PERIPH_SPI0_ID   (0x03)

Definition at line 45 of file common/periph.h.

◆ PERIPH_SPI1_ID

#define PERIPH_SPI1_ID   (0x04)

Definition at line 48 of file common/periph.h.

◆ PERIPH_SPIS1_ID

#define PERIPH_SPIS1_ID   (0x04)

Definition at line 49 of file common/periph.h.

◆ PERIPH_SWI0_ID

#define PERIPH_SWI0_ID   (0x14)

Definition at line 67 of file common/periph.h.

◆ PERIPH_SWI1_ID

#define PERIPH_SWI1_ID   (0x15)

Definition at line 68 of file common/periph.h.

◆ PERIPH_SWI2_ID

#define PERIPH_SWI2_ID   (0x16)

Definition at line 69 of file common/periph.h.

◆ PERIPH_SWI3_ID

#define PERIPH_SWI3_ID   (0x17)

Definition at line 70 of file common/periph.h.

◆ PERIPH_SWI4_ID

#define PERIPH_SWI4_ID   (0x18)

Definition at line 71 of file common/periph.h.

◆ PERIPH_SWI5_ID

#define PERIPH_SWI5_ID   (0x19)

Definition at line 72 of file common/periph.h.

◆ PERIPH_TASK_OFFSET

#define PERIPH_TASK_OFFSET   (0x000)

Starting address of all the tasks in the peripheral.

Definition at line 91 of file common/periph.h.

◆ PERIPH_TEMP_ID

#define PERIPH_TEMP_ID   (0x0c)

Definition at line 58 of file common/periph.h.

◆ PERIPH_TIMER0_ID

#define PERIPH_TIMER0_ID   (0x08)

Definition at line 54 of file common/periph.h.

◆ PERIPH_TIMER1_ID

#define PERIPH_TIMER1_ID   (0x09)

Definition at line 55 of file common/periph.h.

◆ PERIPH_TIMER2_ID

#define PERIPH_TIMER2_ID   (0x0a)

Definition at line 56 of file common/periph.h.

◆ PERIPH_TRIGGER_TASK

#define PERIPH_TRIGGER_TASK (   task)    (task) = (1)

Definition at line 105 of file common/periph.h.

◆ PERIPH_TWI0_ID

#define PERIPH_TWI0_ID   (0x03)

Definition at line 46 of file common/periph.h.

◆ PERIPH_TWI1_ID

#define PERIPH_TWI1_ID   (0x04)

Definition at line 50 of file common/periph.h.

◆ PERIPH_UART_ID

#define PERIPH_UART_ID   (0x02)

Definition at line 44 of file common/periph.h.

◆ PERIPH_WDT_ID

#define PERIPH_WDT_ID   (0x10)

Definition at line 63 of file common/periph.h.