#include "mss_uart.h"
#include <stdio.h>
#include <stdlib.h>
//#define ACTEL_STDIO_THRU_UART
#define RxBufferSize 0x20
char RxBuffer0[RxBufferSize];
uint16_t RxCounter0 = 0;
void UART0_Putch(char tmp);
uint32_t UART0_get_Number(void);
void show_Menu(void);
/* Main function */
int main(void)
{
char KeyIn;
/* Initialize and configure UART0. */
MSS_UART_init(&g_mss_uart0,MSS_UART_115200_BAUD, MSS_UART_DATA_8_BITS | MSS_UART_NO_PARITY | MSS_UART_ONE_STOP_BIT);
MSS_UART_polled_tx_string(&g_mss_uart0, "Start FW -------------------------ver 0.0.1\r\n");
show_Menu();
while(1)
{
#if 1
KeyIn = UART0_get_Number();
switch(KeyIn){
case 1:
MSS_UART_polled_tx_string(&g_mss_uart0, "1. HELP : Show menu explanation\r\n");
break;
default :
MSS_UART_polled_tx_string(&g_mss_uart0, "Invalid input value\r\n");
break;
}
MSS_UART_polled_tx_string(&g_mss_uart0, "anonymous>");
#endif
}
return 0;
}
void UART0_Putch(char tmp){
g_mss_uart0.hw_reg->THR = tmp;
}
uint32_t UART0_get_Number(void){
uint32_t KeyIn, key_value, i;
uint8_t status = 0;
/* Receive a string (Max RxBufferSize bytes) from the Hyperterminal ended by '\r' (Enter key) */
do
{
status = g_mss_uart0.hw_reg->LSR;
g_mss_uart0.status |= status;
if(((status & 0x01) != 0)&&(RxCounter0 < RxBufferSize))
{
key_value = g_mss_uart0.hw_reg->RBR;
status = g_mss_uart0.hw_reg->LSR;
g_mss_uart0.status |= status;
UART0_Putch(key_value);
if(key_value == '\r'){
RxBuffer0[RxCounter0]='\0';
UART0_Putch('\n');
KeyIn = atoi(RxBuffer0);
RxCounter0 = 0;
for(i = 0; i < RxBufferSize; i++)
RxBuffer0[i] = 0;
g_mss_uart0.hw_reg->RBR;
status = g_mss_uart0.hw_reg->LSR;
g_mss_uart0.status |= status;
return KeyIn;
}
else{
RxBuffer0[RxCounter0++] = key_value;
}
}
}while((key_value != '\r')&&(RxCounter0 != RxBufferSize));
return -1;
}
void show_Menu(void){
MSS_UART_polled_tx_string(&g_mss_uart0, "1. HELP : Show menu explanation\r\n");
MSS_UART_polled_tx_string(&g_mss_uart0, "anonymous>");
}
아래와 같이 실행된다.
이 소스를 베이스로 Fabric과 ACE를 돌려봐야긋다.
댓글 없음:
댓글 쓰기