summaryrefslogtreecommitdiff
path: root/bsp/microblaze/board.c
diff options
context:
space:
mode:
Diffstat (limited to 'bsp/microblaze/board.c')
-rwxr-xr-xbsp/microblaze/board.c158
1 files changed, 79 insertions, 79 deletions
diff --git a/bsp/microblaze/board.c b/bsp/microblaze/board.c
index 1de9171151..817666999c 100755
--- a/bsp/microblaze/board.c
+++ b/bsp/microblaze/board.c
@@ -33,83 +33,83 @@
#include "serial.h"
#endif
-#define TIMER_CNTR_0 0
-#define PIV (XPAR_PROC_BUS_0_FREQ_HZ / RT_TICK_PER_SECOND)
-#define LEDS_DEVICE_ID XPAR_LEDS_4BITS_DEVICE_ID
-#define RS232_DEVICE_ID XPAR_USB_UART_DEVICE_ID
+#define TIMER_CNTR_0 0
+#define PIV (XPAR_PROC_BUS_0_FREQ_HZ / RT_TICK_PER_SECOND)
+#define LEDS_DEVICE_ID XPAR_LEDS_4BITS_DEVICE_ID
+#define RS232_DEVICE_ID XPAR_USB_UART_DEVICE_ID
#ifdef RT_USING_UART1
-#define USB_UART_BASE ((struct uartport *)XPAR_USB_UART_BASEADDR)
+#define USB_UART_BASE ((struct uartport *)XPAR_USB_UART_BASEADDR)
#endif
/* Global Variables: */
-XTmrCtr timer; /* The instance of the timer */
-XGpio gpio_output; /* The driver instance for GPIO Device configured as O/P */
-XUartLite uart_lite; /* Instance of the UartLite device */
-XIntc int_ctl; /* The instance of the Interrupt Controller */
-static rt_uint32_t led_data;
+XTmrCtr timer; /* The instance of the timer */
+XGpio gpio_output; /* The driver instance for GPIO Device configured as O/P */
+XUartLite uart_lite; /* Instance of the UartLite device */
+XIntc int_ctl; /* The instance of the Interrupt Controller */
+static rt_uint32_t led_data;
static int cnt;
static void rt_hw_board_led_init(void);
-/**
+/**
* This function will init led on the board
*/
static void rt_hw_board_led_init()
{
- rt_uint32_t status;
- led_data = 0;
- cnt = 0;
- status = XGpio_Initialize(&gpio_output, LEDS_DEVICE_ID);
- if (status != XST_SUCCESS)
- {
- return;
- }
+ rt_uint32_t status;
+ led_data = 0;
+ cnt = 0;
+ status = XGpio_Initialize(&gpio_output, LEDS_DEVICE_ID);
+ if (status != XST_SUCCESS)
+ {
+ return;
+ }
- /*
- * Set the direction for all signals to be outputs
- */
- XGpio_SetDataDirection(&gpio_output, 1, 0x0);
- /*
- * Set the GPIO outputs to high
- */
- XGpio_DiscreteWrite(&gpio_output, 1, 3);
+ /*
+ * Set the direction for all signals to be outputs
+ */
+ XGpio_SetDataDirection(&gpio_output, 1, 0x0);
+ /*
+ * Set the GPIO outputs to high
+ */
+ XGpio_DiscreteWrite(&gpio_output, 1, 3);
}
-/**
+/**
* This function will take the led on board on.
*
* @param n the number nth led
*/
void rt_hw_board_led_on(rt_uint32_t led)
{
- led_data |= led;
- XGpio_DiscreteWrite(&gpio_output, 1, led_data);
+ led_data |= led;
+ XGpio_DiscreteWrite(&gpio_output, 1, led_data);
}
-/**
+/**
* This function will take the led on board off.
*
* @param n the number nth led
*/
void rt_hw_board_led_off(rt_uint32_t led)
{
- led_data &= ~led;
- XGpio_DiscreteWrite(&gpio_output, 1, led_data);
+ led_data &= ~led;
+ XGpio_DiscreteWrite(&gpio_output, 1, led_data);
}
void rt_hw_led_flash(void)
{
- volatile rt_uint32_t i;
+ volatile rt_uint32_t i;
- rt_hw_board_led_off(1);
- for (i = 0; i < 20000; i ++);
+ rt_hw_board_led_off(1);
+ for (i = 0; i < 20000; i ++);
- rt_hw_board_led_on(1);
- for (i = 0; i < 20000; i ++);
+ rt_hw_board_led_on(1);
+ for (i = 0; i < 20000; i ++);
}
@@ -126,30 +126,30 @@ void rt_hw_led_flash(void)
*/
void rt_hw_console_output(const char* str)
{
- while (*str)
- {
+ while (*str)
+ {
- /* Transmit Character */
+ /* Transmit Character */
- XUartLite_SendByte(STDOUT_BASEADDRESS, *str);
- if (*str == '\n')
- XUartLite_SendByte(STDOUT_BASEADDRESS, '\r');
- str++;
- }
+ XUartLite_SendByte(STDOUT_BASEADDRESS, *str);
+ if (*str == '\n')
+ XUartLite_SendByte(STDOUT_BASEADDRESS, '\r');
+ str++;
+ }
}
static void rt_hw_console_init()
{
- rt_uint32_t status;
+ rt_uint32_t status;
- /*
- * Initialize the UartLite driver so that it is ready to use.
- */
- status = XUartLite_Initialize(&uart_lite, RS232_DEVICE_ID);
- if (status != XST_SUCCESS)
- {
- return;
- }
+ /*
+ * Initialize the UartLite driver so that it is ready to use.
+ */
+ status = XUartLite_Initialize(&uart_lite, RS232_DEVICE_ID);
+ if (status != XST_SUCCESS)
+ {
+ return;
+ }
}
#endif
@@ -157,16 +157,16 @@ static void rt_hw_console_init()
void rt_hw_timer_handler(void)
{
- rt_uint32_t csr;
- csr = XTmrCtr_ReadReg(timer.BaseAddress, TIMER_CNTR_0, XTC_TCSR_OFFSET);
- /*
- * Check if timer expired and interrupt occured
- */
- if (csr & XTC_CSR_INT_OCCURED_MASK)
- {
- rt_tick_increase();
- XTmrCtr_WriteReg(timer.BaseAddress, TIMER_CNTR_0, XTC_TCSR_OFFSET, csr | XTC_CSR_INT_OCCURED_MASK);
- }
+ rt_uint32_t csr;
+ csr = XTmrCtr_ReadReg(timer.BaseAddress, TIMER_CNTR_0, XTC_TCSR_OFFSET);
+ /*
+ * Check if timer expired and interrupt occured
+ */
+ if (csr & XTC_CSR_INT_OCCURED_MASK)
+ {
+ rt_tick_increase();
+ XTmrCtr_WriteReg(timer.BaseAddress, TIMER_CNTR_0, XTC_TCSR_OFFSET, csr | XTC_CSR_INT_OCCURED_MASK);
+ }
}
@@ -192,24 +192,24 @@ void rt_intc_init (void)
status = XIntc_Initialize(&int_ctl, XPAR_INTC_0_DEVICE_ID);
- /* install interrupt handler */
+ /* install interrupt handler */
rt_hw_interrupt_install(XPAR_INTC_0_TMRCTR_0_VEC_ID, (rt_isr_handler_t)rt_hw_timer_handler, RT_NULL);
- rt_hw_interrupt_umask(XPAR_INTC_0_TMRCTR_0_VEC_ID);
+ rt_hw_interrupt_umask(XPAR_INTC_0_TMRCTR_0_VEC_ID);
- XIntc_Start(&int_ctl, XIN_REAL_MODE);
+ XIntc_Start(&int_ctl, XIN_REAL_MODE);
}
void rt_tmr_init (void)
{
- rt_uint32_t ctl;
- XStatus status;
+ rt_uint32_t ctl;
+ XStatus status;
status = XTmrCtr_Initialize(&timer,XPAR_AXI_TIMER_0_DEVICE_ID);
- XTmrCtr_WriteReg(timer.BaseAddress, TIMER_CNTR_0, XTC_TLR_OFFSET, PIV);
+ XTmrCtr_WriteReg(timer.BaseAddress, TIMER_CNTR_0, XTC_TLR_OFFSET, PIV);
ctl = XTC_CSR_ENABLE_TMR_MASK | XTC_CSR_ENABLE_INT_MASK | XTC_CSR_AUTO_RELOAD_MASK | XTC_CSR_DOWN_COUNT_MASK;
- XTmrCtr_WriteReg(timer.BaseAddress, TIMER_CNTR_0, XTC_TCSR_OFFSET, ctl);
+ XTmrCtr_WriteReg(timer.BaseAddress, TIMER_CNTR_0, XTC_TCSR_OFFSET, ctl);
}
@@ -219,15 +219,15 @@ void rt_tmr_init (void)
*/
void rt_hw_board_init()
{
- microblaze_disable_icache();
- microblaze_disable_dcache();
- /* init hardware console */
- rt_hw_console_init();
+ microblaze_disable_icache();
+ microblaze_disable_dcache();
+ /* init hardware console */
+ rt_hw_console_init();
- /* init led */
- rt_hw_board_led_init();
+ /* init led */
+ rt_hw_board_led_init();
- /* init intc */
+ /* init intc */
rt_intc_init();
/* timer init */