summaryrefslogtreecommitdiff
path: root/bsp/raspberry-pi/raspi4-32/driver/drv_gpio.c
diff options
context:
space:
mode:
authorbigamgic <[email protected]>2020-07-04 22:32:02 +0800
committerbigamgic <[email protected]>2020-07-04 22:32:02 +0800
commitf333dcabe39b529e5a7cc0b02daef49ca2caa855 (patch)
treef09d89e1b63c92942e6c0aa47ee2f8f59aa44af9 /bsp/raspberry-pi/raspi4-32/driver/drv_gpio.c
parent7e5373e733d8ca779883a88377a3860ec4f8cb41 (diff)
raspi4 spi0 driver can run
Diffstat (limited to 'bsp/raspberry-pi/raspi4-32/driver/drv_gpio.c')
-rw-r--r--bsp/raspberry-pi/raspi4-32/driver/drv_gpio.c53
1 files changed, 29 insertions, 24 deletions
diff --git a/bsp/raspberry-pi/raspi4-32/driver/drv_gpio.c b/bsp/raspberry-pi/raspi4-32/driver/drv_gpio.c
index e342032d55..b45fb8574f 100644
--- a/bsp/raspberry-pi/raspi4-32/driver/drv_gpio.c
+++ b/bsp/raspberry-pi/raspi4-32/driver/drv_gpio.c
@@ -120,6 +120,34 @@ void prev_raspi_pin_mode(GPIO_PIN pin, GPIO_FUNC mode)
raspi_set_pin_state(fselnum, gpfsel);
}
+void prev_raspi_pin_write(GPIO_PIN pin, int pin_value)
+{
+ uint32_t num = pin / 32;
+
+ if(num == 0)
+ {
+ if(pin_value == 1)
+ {
+ GPIO_REG_GPSET0(GPIO_BASE) = 1 << (pin % 32);
+ }
+ else
+ {
+ GPIO_REG_GPCLR0(GPIO_BASE) = 1 << (pin % 32);
+ }
+ }
+ else
+ {
+ if(pin_value == 1)
+ {
+ GPIO_REG_GPSET1(GPIO_BASE) = 1 << (pin % 32);
+ }
+ else
+ {
+ GPIO_REG_GPCLR1(GPIO_BASE) = 1 << (pin % 32);
+ }
+ }
+}
+
static void raspi_pin_mode(struct rt_device *dev, rt_base_t pin, rt_base_t mode)
{
GPIO_FUNC raspi_mode = OUTPUT;
@@ -149,30 +177,7 @@ static void raspi_pin_mode(struct rt_device *dev, rt_base_t pin, rt_base_t mode)
static void raspi_pin_write(struct rt_device *dev, rt_base_t pin, rt_base_t value)
{
- uint32_t num = pin / 32;
-
- if(num == 0)
- {
- if(value == 0)
- {
- GPIO_REG_GPSET0(GPIO_BASE) = 1 << (pin % 32);
- }
- else
- {
- GPIO_REG_GPCLR0(GPIO_BASE) = 1 << (pin % 32);
- }
- }
- else
- {
- if(value == 0)
- {
- GPIO_REG_GPSET1(GPIO_BASE) = 1 << (pin % 32);
- }
- else
- {
- GPIO_REG_GPCLR1(GPIO_BASE) = 1 << (pin % 32);
- }
- }
+ prev_raspi_pin_write(pin, value);
}
static int raspi_pin_read(struct rt_device *device, rt_base_t pin)