编译通过 仿真启动 请知悉 改处理器没有csr
This commit is contained in:
40
tb/sw/axi_gpio/gpio.c
Normal file
40
tb/sw/axi_gpio/gpio.c
Normal file
@@ -0,0 +1,40 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include "gpio.h"
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef GPIO_BASE
|
||||
#error GPIO Base address not define!!!
|
||||
#endif
|
||||
|
||||
|
||||
// for 8 bit gpio
|
||||
|
||||
volatile uint32_t *gpio_dat_reg = (uint32_t*)( GPIO_BASE + GPIO_DATA );
|
||||
volatile uint32_t *gpio_tri_reg = (uint32_t*)( GPIO_BASE + GPIO_TRI );
|
||||
|
||||
|
||||
uint8_t gpio_read()
|
||||
{
|
||||
*gpio_tri_reg = 0xff;
|
||||
return (uint8_t)(*gpio_dat_reg);
|
||||
}
|
||||
|
||||
|
||||
uint32_t gpio_write( uint32_t data )
|
||||
{
|
||||
*gpio_tri_reg = 0x00;
|
||||
(*gpio_dat_reg) = data;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
24
tb/sw/axi_gpio/gpio.h
Normal file
24
tb/sw/axi_gpio/gpio.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#ifndef _GPIO_H_
|
||||
#define _GPIO_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define GPIO_BASE 0x20000000U
|
||||
|
||||
|
||||
|
||||
#define GPIO_DATA 0x0000
|
||||
#define GPIO_TRI 0x0004
|
||||
#define GPIO2_DATA 0x0008
|
||||
#define GPIO2_TRI 0x000C
|
||||
#define GIER 0x011C
|
||||
#define IP_IER 0x0128
|
||||
#define IP_ISR 0x0120
|
||||
|
||||
|
||||
extern uint8_t gpio_read();
|
||||
extern uint32_t gpio_write( uint32_t data );
|
||||
|
||||
void gpio_test();
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user