WB32L003 Standard Peripherals Firmware Library

wb32l003_owire.h
浏览该文件的文档.
1
10 /* Define to prevent recursive inclusion -------------------------------------*/
11 #ifndef __WB32L003_OWIRE_H
12 #define __WB32L003_OWIRE_H
13
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17
18 /* Includes ------------------------------------------------------------------*/
19 #include "wb32l003.h"
20
29 /* Exported types ------------------------------------------------------------*/
30
34 typedef struct
35 {
36 uint32_t ClockDiv;
40 uint32_t FirstBit;
43 uint32_t DataSize;
46 uint32_t ReadMode;
49 uint32_t NoiseFilterEn;
52 uint32_t NoiseFilterClk;
55 uint32_t ResetCounter;
58 uint32_t PresencePulseCounter;
61 uint32_t BitRateCounter;
64 uint32_t DriveCounter;
67 uint32_t ReadSamplingCounter;
70 uint32_t RecoverCounter;
72 } OWIRE_InitTypeDef;
73
74 /* Exported constants --------------------------------------------------------*/
75
83 #define OWIRE_DATASIZE_1BIT 0x00000000U
84 #define OWIRE_DATASIZE_8BIT OWIRE_CR_SIZE_Msk
85
93 #define OWIRE_FIRSTBIT_LSB 0x00000000U
94 #define OWIRE_FIRSTBIT_MSB OWIRE_CR_MSBFIRST_Msk
95
103 #define OWIRE_CLOCK_DIVIDER_1 0x00000000U
104 #define OWIRE_CLOCK_DIVIDER_2 (0x1U << OWIRE_CR_CLKDIV_Pos)
105 #define OWIRE_CLOCK_DIVIDER_4 (0x2U << OWIRE_CR_CLKDIV_Pos)
106 #define OWIRE_CLOCK_DIVIDER_16 (0x3U << OWIRE_CR_CLKDIV_Pos)
107
115 #define OWIRE_RDMODE_0 0x00000000U
116 #define OWIRE_RDMODE_1 OWIRE_CR_RDMODE_Msk
117
125 #define OWIRE_NOISE_FILTER_CLK_DIV_1 0x00000000U
126 #define OWIRE_NOISE_FILTER_CLK_DIV_2 (0x1U << OWIRE_NFCR_NFDIV_Pos)
127 #define OWIRE_NOISE_FILTER_CLK_DIV_4 (0x2U << OWIRE_NFCR_NFDIV_Pos)
128 #define OWIRE_NOISE_FILTER_CLK_DIV_8 (0x3U << OWIRE_NFCR_NFDIV_Pos)
129
137 #define OWIRE_NOISE_FILTER_ENABLE (0x1U << OWIRE_NFCR_NFEN_Pos)
138 #define OWIRE_NOISE_FILTER_DISABLE 0x00000000U
139
147 #define OWIRE_COMMAND_INIT (0x1U << OWIRE_CMD_CMD_Pos)
148 #define OWIRE_COMMAND_TX (0x2U << OWIRE_CMD_CMD_Pos)
149 #define OWIRE_COMMAND_RX (0x3U << OWIRE_CMD_CMD_Pos)
150
158 #define OWIRE_FLAG_ACKERROR ((uint32_t)OWIRE_SR_ACKERR_Msk)
159 #define OWIRE_FLAG_INITDONE ((uint32_t)OWIRE_SR_INITDONE_Msk)
160 #define OWIRE_FLAG_TXDONE ((uint32_t)OWIRE_SR_TXDONE_Msk)
161 #define OWIRE_FLAG_RXDONE ((uint32_t)OWIRE_SR_RXDONE_Msk)
162
170 #define OWIRE_IT_ACKERROR ((uint32_t)OWIRE_INTEN_ACKERREN_Msk)
171 #define OWIRE_IT_INIT ((uint32_t)OWIRE_INTEN_INITEN_Msk)
172 #define OWIRE_IT_TXDONE ((uint32_t)OWIRE_INTEN_TXDONEEN_Msk)
173 #define OWIRE_IT_RXDONE ((uint32_t)OWIRE_INTEN_RXDONEEN_Msk)
174
182 /* Exported macro ------------------------------------------------------------*/
183 /* Exported functions --------------------------------------------------------*/
184
185 void OWIRE_DeInit(void);
186 void OWIRE_Init(OWIRE_InitTypeDef *OWIRE_InitStruct);
187 void OWIRE_Cmd(FunctionalState NewState);
188 void OWIRE_ITConfig(uint32_t OWIRE_IT, FunctionalState NewState);
189 uint8_t OWIRE_ReadData(void);
190 void OWIRE_WriteData(uint8_t Data);
191 void OWIRE_WriteCommand(uint8_t Command);
192 FlagStatus OWIRE_GetFlagStatus(uint32_t OWIRE_FLAG);
193 void OWIRE_ClearFlag(uint32_t OWIRE_FLAG);
194 ITStatus OWIRE_GetITStatus(uint32_t OWIRE_IT);
195 void OWIRE_ClearITPendingBit(uint32_t OWIRE_IT);
196
205 #ifdef __cplusplus
206 }
207 #endif
208
209 #endif /*__WB32L003_OWIRE_H */
OWIRE_InitTypeDef::NoiseFilterEn
uint32_t NoiseFilterEn
Definition: wb32l003_owire.h:49
OWIRE_InitTypeDef::BitRateCounter
uint32_t BitRateCounter
Definition: wb32l003_owire.h:61
OWIRE_InitTypeDef::ReadSamplingCounter
uint32_t ReadSamplingCounter
Definition: wb32l003_owire.h:67
OWIRE_ClearFlag
void OWIRE_ClearFlag(uint32_t OWIRE_FLAG)
Clears the OWIRE's pending flags.
Definition: wb32l003_owire.c:193
OWIRE_InitTypeDef::DataSize
uint32_t DataSize
Definition: wb32l003_owire.h:43
OWIRE_WriteCommand
void OWIRE_WriteCommand(uint8_t Command)
Write command to CMD register.
Definition: wb32l003_owire.c:149
OWIRE_InitTypeDef::ReadMode
uint32_t ReadMode
Definition: wb32l003_owire.h:46
OWIRE_InitTypeDef::RecoverCounter
uint32_t RecoverCounter
Definition: wb32l003_owire.h:70
OWIRE_ReadData
uint8_t OWIRE_ReadData(void)
Read one data from DATA register.
Definition: wb32l003_owire.c:125
OWIRE_ITConfig
void OWIRE_ITConfig(uint32_t OWIRE_IT, FunctionalState NewState)
Enables or disables the specified OWIRE interrupts.
Definition: wb32l003_owire.c:104
OWIRE_WriteData
void OWIRE_WriteData(uint8_t Data)
Write one data to DATA register.
Definition: wb32l003_owire.c:135
OWIRE_Init
void OWIRE_Init(OWIRE_InitTypeDef *OWIRE_InitStruct)
Initializes the OWIRE mode according to the specified parameters in the OWIRE_InitTypeDef and create ...
Definition: wb32l003_owire.c:52
OWIRE_InitTypeDef::ResetCounter
uint32_t ResetCounter
Definition: wb32l003_owire.h:55
OWIRE_ClearITPendingBit
void OWIRE_ClearITPendingBit(uint32_t OWIRE_IT)
Clears the OWIRE's interrupt pending bits.
Definition: wb32l003_owire.c:239
OWIRE_Cmd
void OWIRE_Cmd(FunctionalState NewState)
Enables or disables the specified OWIRE peripheral.
Definition: wb32l003_owire.c:78
OWIRE_InitTypeDef::FirstBit
uint32_t FirstBit
Definition: wb32l003_owire.h:40
OWIRE_InitTypeDef::NoiseFilterClk
uint32_t NoiseFilterClk
Definition: wb32l003_owire.h:52
OWIRE_DeInit
void OWIRE_DeInit(void)
Deinitializes the OWIRE peripheral registers to their default reset values.
Definition: wb32l003_owire.c:38
OWIRE_GetFlagStatus
FlagStatus OWIRE_GetFlagStatus(uint32_t OWIRE_FLAG)
Checks whether the specified the OWIRE flag is set or not.
Definition: wb32l003_owire.c:164
OWIRE_InitTypeDef
OWIRE Init Structure definition
Definition: wb32l003_owire.h:34
OWIRE_InitTypeDef::ClockDiv
uint32_t ClockDiv
Definition: wb32l003_owire.h:36
OWIRE_GetITStatus
ITStatus OWIRE_GetITStatus(uint32_t OWIRE_IT)
Checks whether the OWIRE interrupt has occurred or not.
Definition: wb32l003_owire.c:209
OWIRE_InitTypeDef::PresencePulseCounter
uint32_t PresencePulseCounter
Definition: wb32l003_owire.h:58
OWIRE_InitTypeDef::DriveCounter
uint32_t DriveCounter
Definition: wb32l003_owire.h:64