For sensor project
This commit is contained in:
@@ -10,6 +10,15 @@
|
||||
|
||||
#define EXTI_PENDING_REG(line) ((line) < 32 ? EXTI->PR1 : EXTI->PR2)
|
||||
|
||||
static inline SHAL_EXTI_Control_Register getEXTIControlRegister(uint32_t line){
|
||||
uint8_t maskOffset = line % 4; //Each register has four 4-bit wide fields
|
||||
uint8_t registerOffset = line / 4; //Composed of four registers with 4 fields each
|
||||
|
||||
SHAL_EXTI_Control_Register res = {&SYSCFG->EXTICR[registerOffset], maskOffset};
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static inline SHAL_EXTI_Interrupt_Mask_Register getEXTIInterruptMaskRegister(uint32_t line){
|
||||
volatile uint32_t* reg = line < 32 ? &EXTI->IMR1 : &EXTI->IMR2;
|
||||
return {reg};;
|
||||
|
||||
@@ -19,4 +19,9 @@ struct SHAL_EXTI_Falling_Trigger_Selection_Register {
|
||||
volatile uint32_t* reg;
|
||||
};
|
||||
|
||||
struct SHAL_EXTI_Control_Register {
|
||||
volatile uint32_t* reg;
|
||||
uint32_t offset;
|
||||
};
|
||||
|
||||
#endif //SHMINGO_HAL_SHAL_EXTI_TYPES_H
|
||||
|
||||
@@ -71,6 +71,10 @@ constexpr uint8_t getGPIOPinNumber(GPIO_Key key){
|
||||
return static_cast<uint8_t>(key) % 16;
|
||||
}
|
||||
|
||||
constexpr uint8_t getGPIOPortNUmber(GPIO_Key key){
|
||||
return static_cast<uint8_t>(key) / 16;
|
||||
}
|
||||
|
||||
constexpr SHAL_GPIO_EXTI_Register getGPIOEXTICR(const GPIO_Key g){
|
||||
switch(g) {
|
||||
case GPIO_Key::A0: return {&SYSCFG->EXTICR[0],SYSCFG_EXTICR1_EXTI0_PA,EXTI0_IRQn};
|
||||
@@ -158,6 +162,12 @@ static inline SHAL_GPIO_Output_Data_Register getGPIOOutputDataRegister(const GPI
|
||||
return {reg,offset};
|
||||
}
|
||||
|
||||
static inline SHAL_GPIO_Input_Data_Register getGPIOInputDataRegister(const GPIO_Key key){
|
||||
volatile uint32_t* reg = &GPIO_TABLE[static_cast<uint8_t>(key) / 16]->IDR;
|
||||
uint32_t offset = static_cast<uint8_t>(key) % 16;
|
||||
return {reg,offset};
|
||||
}
|
||||
|
||||
constexpr SHAL_GPIO_Port_Info getGPIOPortInfo(GPIO_Key key){
|
||||
switch(key){
|
||||
case GPIO_Key::A0:
|
||||
|
||||
@@ -29,6 +29,7 @@ public:
|
||||
/// \return ADC result
|
||||
uint16_t analogRead(SHAL_ADC_SampleTime sampleTime = SHAL_ADC_SampleTime::C8);
|
||||
|
||||
uint16_t digitalRead();
|
||||
|
||||
void setAlternateFunction(GPIO_Alternate_Function AF) volatile;
|
||||
void setAlternateFunction(GPIO_Alternate_Function_Mapping AF) volatile;
|
||||
|
||||
@@ -50,6 +50,11 @@ struct SHAL_GPIO_Output_Data_Register {
|
||||
uint32_t offset;
|
||||
};
|
||||
|
||||
struct SHAL_GPIO_Input_Data_Register {
|
||||
volatile uint32_t* reg;
|
||||
uint32_t offset;
|
||||
};
|
||||
|
||||
struct SHAL_GPIO_Port_Info{
|
||||
uint8_t number;
|
||||
SHAL_ADC_Channel ADCChannel;
|
||||
|
||||
Reference in New Issue
Block a user