•All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
periph_cpu.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015-2016 Freie Universität Berlin
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
19 #ifndef PERIPH_F1_PERIPH_CPU_H
20 #define PERIPH_F1_PERIPH_CPU_H
21 
22 #include "cpu_conf.h"
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 #ifndef DOXYGEN
29 
34 #if defined(CPU_LINE_STM32F103xB) || defined(CPU_LINE_STM32F103xE)
35 #define STM32_BOOTLOADER_ADDR (0x1FFFF000)
36 #endif
37 
41 #define STM32_OPTION_BYTES ((uint32_t*) 0x1FFFF800)
42 #define GET_RDP(x) (x & 0xFF)
43 
44 #endif /* ndef DOXYGEN */
45 
50 #define RTT_IRQ_PRIO 1
51 
52 #define RTT_DEV RTC
53 #define RTT_IRQ RTC_IRQn
54 #define RTT_ISR isr_rtc
55 
56 #define RTT_MAX_VALUE (0xffffffff)
57 #define RTT_CLOCK_FREQUENCY (32768U) /* in Hz */
58 #define RTT_MIN_FREQUENCY (1U) /* in Hz */
59 /* RTC frequency of 32kHz is not recommended, see RM0008 Rev 20, p490 */
60 #define RTT_MAX_FREQUENCY (RTT_CLOCK_FREQUENCY / 2) /* in Hz */
66 #define ADC_DEVS (2U)
67 
82 enum {
83  GPIO_CRL_MODE0_INPUT = (0x0 << GPIO_CRL_MODE0_Pos),
84  GPIO_CRL_MODE0_OUTPUT_10MHZ = (0x1 << GPIO_CRL_MODE0_Pos),
85  GPIO_CRL_MODE0_OUTPUT_2MHZ = (0x2 << GPIO_CRL_MODE0_Pos),
86  GPIO_CRL_MODE0_OUTPUT_50MHZ = (0x3 << GPIO_CRL_MODE0_Pos),
87 };
88 
99 enum {
100  GPIO_CRL_CNF0_INPUT_ANALOG = (0x0 << GPIO_CRL_CNF0_Pos),
101  GPIO_CRL_CNF0_INPUT_FLOATING = (0x1 << GPIO_CRL_CNF0_Pos),
102  GPIO_CRL_CNF0_INPUT_PULL = (0x2 << GPIO_CRL_CNF0_Pos),
103  GPIO_CRL_CNF0_OUTPUT_PUSH_PULL = (0x0 << GPIO_CRL_CNF0_Pos),
104  GPIO_CRL_CNF0_OUTPUT_OPEN_DRAIN = (0x1 << GPIO_CRL_CNF0_Pos),
105  GPIO_CRL_CNF0_AF_PUSH_PULL = (0x2 << GPIO_CRL_CNF0_Pos),
106  GPIO_CRL_CNF0_AF_OPEN_DRAIN = (0x3 << GPIO_CRL_CNF0_Pos),
107 };
116 typedef enum {
125  SWJ_CFG_NO_NJTRST = AFIO_MAPR_SWJ_CFG_NOJNTRST,
129  SWJ_CFG_NO_JTAG_DP = AFIO_MAPR_SWJ_CFG_JTAGDISABLE,
134  SWJ_CFG_DISABLED = AFIO_MAPR_SWJ_CFG_DISABLE,
136 
137 #ifndef CONFIG_AFIO_MAPR_SWJ_CFG
145 #define CONFIG_AFIO_MAPR_SWJ_CFG SWJ_CFG_NO_JTAG_DP
146 #endif
147 
154 static inline uint32_t afio_mapr_read(void)
155 {
156  return AFIO->MAPR & (~(AFIO_MAPR_SWJ_CFG_Msk));
157 }
158 
166 static inline void afio_mapr_write(uint32_t new_value)
167 {
168  AFIO->MAPR = CONFIG_AFIO_MAPR_SWJ_CFG | new_value;
169 }
170 
171 #ifdef __cplusplus
172 }
173 #endif
174 
175 #endif /* PERIPH_F1_PERIPH_CPU_H */
static uint32_t afio_mapr_read(void)
Read the current value of the AFIO->MAPR register reproducibly.
Definition: periph_cpu.h:154
afio_mapr_swj_cfg_t
Possible values of the SWJ_CFG field in the AFIO->MAPR register.
Definition: periph_cpu.h:116
@ SWJ_CFG_NO_JTAG_DP
Only SW-DP enabled, JTAG pins usable as GPIOS.
Definition: periph_cpu.h:129
@ SWJ_CFG_NO_NJTRST
Both JTAG-DP and SW-DP enabled, but NJTRST disabled and pin usable as GPIO.
Definition: periph_cpu.h:125
@ SWJ_CFG_DISABLED
Neither JTAG-DP nor SW-DP enabled, JTAG and SWD pins usable as GPIOS.
Definition: periph_cpu.h:134
@ SWJ_CFG_FULL_SWJ
Both JTAG-DP and SW-DP enabled, reset state.
Definition: periph_cpu.h:120
#define CONFIG_AFIO_MAPR_SWJ_CFG
By default, disable JTAG and keep only SWD.
Definition: periph_cpu.h:145
static void afio_mapr_write(uint32_t new_value)
Write to the AFIO->MAPR register apply the SWJ configuration specified via CONFIG_AFIO_MAPR_SWJ_CFG.
Definition: periph_cpu.h:166