rework structure
This commit is contained in:
89
hifive1-vp/riscv-bldc-forced-commutation/src/io/gpio.h
Normal file
89
hifive1-vp/riscv-bldc-forced-commutation/src/io/gpio.h
Normal file
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* gpio.h
|
||||
*
|
||||
* Created on: 29.07.2018
|
||||
* Author: eyck
|
||||
*/
|
||||
|
||||
#ifndef GPIO_H_
|
||||
#define GPIO_H_
|
||||
|
||||
#include <sifive/devices/gpio.h>
|
||||
#include <cstdint>
|
||||
|
||||
template<uint32_t BASE_ADDR>
|
||||
class gpio_regs {
|
||||
public:
|
||||
static inline uint32_t& value_reg(){
|
||||
return *reinterpret_cast<uint32_t*>(BASE_ADDR+GPIO_INPUT_VAL);
|
||||
}
|
||||
|
||||
static inline uint32_t& input_en_reg(){
|
||||
return *reinterpret_cast<uint32_t*>(BASE_ADDR+GPIO_INPUT_EN);
|
||||
}
|
||||
|
||||
static inline uint32_t& output_en_reg(){
|
||||
return *reinterpret_cast<uint32_t*>(BASE_ADDR+GPIO_OUTPUT_EN);
|
||||
}
|
||||
|
||||
static inline uint32_t& port_reg(){
|
||||
return *reinterpret_cast<uint32_t*>(BASE_ADDR+GPIO_OUTPUT_VAL);
|
||||
}
|
||||
|
||||
static inline uint32_t& pue_reg(){
|
||||
return *reinterpret_cast<uint32_t*>(BASE_ADDR+GPIO_PULLUP_EN);
|
||||
}
|
||||
|
||||
static inline uint32_t& ds_reg(){
|
||||
return *reinterpret_cast<uint32_t*>(BASE_ADDR+GPIO_DRIVE);
|
||||
}
|
||||
|
||||
static inline uint32_t& rise_ie_reg(){
|
||||
return *reinterpret_cast<uint32_t*>(BASE_ADDR+GPIO_RISE_IE);
|
||||
}
|
||||
|
||||
static inline uint32_t& rise_ip_reg(){
|
||||
return *reinterpret_cast<uint32_t*>(BASE_ADDR+GPIO_RISE_IP);
|
||||
}
|
||||
|
||||
static inline uint32_t& fall_ie_reg(){
|
||||
return *reinterpret_cast<uint32_t*>(BASE_ADDR+GPIO_FALL_IE);
|
||||
}
|
||||
|
||||
static inline uint32_t& fall_ip_reg(){
|
||||
return *reinterpret_cast<uint32_t*>(BASE_ADDR+GPIO_FALL_IP);
|
||||
}
|
||||
|
||||
static inline uint32_t& high_ie_reg(){
|
||||
return *reinterpret_cast<uint32_t*>(BASE_ADDR+GPIO_HIGH_IE);
|
||||
}
|
||||
|
||||
static inline uint32_t& high_ip_reg(){
|
||||
return *reinterpret_cast<uint32_t*>(BASE_ADDR+GPIO_HIGH_IP);
|
||||
}
|
||||
|
||||
static inline uint32_t& low_ie_reg(){
|
||||
return *reinterpret_cast<uint32_t*>(BASE_ADDR+GPIO_LOW_IE);
|
||||
}
|
||||
|
||||
static inline uint32_t& low_ip_reg(){
|
||||
return *reinterpret_cast<uint32_t*>(BASE_ADDR+GPIO_LOW_IP);
|
||||
}
|
||||
|
||||
static inline uint32_t& iof_en_reg(){
|
||||
return *reinterpret_cast<uint32_t*>(BASE_ADDR+GPIO_IOF_EN);
|
||||
}
|
||||
|
||||
static inline uint32_t& iof_sel_reg(){
|
||||
return *reinterpret_cast<uint32_t*>(BASE_ADDR+GPIO_IOF_SEL);
|
||||
}
|
||||
|
||||
static inline uint32_t& out_xor_reg(){
|
||||
return *reinterpret_cast<uint32_t*>(BASE_ADDR+GPIO_OUTPUT_XOR);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* GPIO_H_ */
|
Reference in New Issue
Block a user