Commit 2f4d90a3 authored by liubryan's avatar liubryan
Browse files

Update main.c

parent 008d4beb
......@@ -26,11 +26,8 @@ void __FINISHED_INTERRUPT_HANDLER__() {
}
*/
uint8_t arrow_pos = 0;
uint8_t tab_state = 0;
int progress=0;
int temp=0;
uint8_t g_rx_buff[6];
uint8_t g_rx_buff[8];
//clock/baudrate/16-1
#define BAUD_VALUE_115200 53
#define COREUARTAPB0_BASE_ADDR 0x40050000
......@@ -46,14 +43,19 @@ uint8_t tab_state = 0;
delay(3000000);
MSS_GPIO_clear_irq( MSS_GPIO_0 ); //clear interrupt and resume
}
void __attribute__ ((interrupt)) GPIO1_IRQHandler( void )
{
//UART_send(&g_uart,"B2\r\n",sizeof("B2\r\n"));
if (!is_selecting) {
is_selecting = 1;
clear_screen();
arrow_pos = 0;
tab_state = 0;
show_options();
}
delay(3000000);
MSS_GPIO_clear_irq( MSS_GPIO_1 ); //clear interrupt and resume
}
void __attribute__ ((interrupt)) GPIO2_IRQHandler( void )
{
//UART_send(&g_uart,"B3\r\n",sizeof("B3\r\n"));
......@@ -69,7 +71,6 @@ uint8_t tab_state = 0;
delay(3000000);
MSS_GPIO_clear_irq( MSS_GPIO_2 ); //clear interrupt and resume
}
void __attribute__ ((interrupt)) GPIO3_IRQHandler( void )
{
//UART_send(&g_uart,"B4\r\n",sizeof("B4\r\n"));
......@@ -80,39 +81,43 @@ uint8_t tab_state = 0;
delay(3000000);
MSS_GPIO_clear_irq( MSS_GPIO_3 ); //clear interrupt and resume
}
void __attribute__ ((interrupt)) GPIO4_IRQHandler( void )
{
//UART_send(&g_uart,"B5\r\n",sizeof("B5\r\n"));
delay(3000000);
MSS_GPIO_clear_irq( MSS_GPIO_4 ); //clear interrupt and resume
}
void uart1_rx_handler( mss_uart_instance_t * this_uart )
{
int i=0;
for(i=0;i<500000;++i);
MSS_UART_get_rx( this_uart, g_rx_buff, sizeof(g_rx_buff) );
erase_block( BARSTART_X, BARSTART_Y, BARSTART_X+100,BAREND_Y);
progress=g_rx_buff[0];
temp=g_rx_buff[1];
if(tab_state==0){
MSS_UART_get_rx( this_uart, g_rx_buff, sizeof(g_rx_buff) );
erase_block( BARSTART_X, BARSTART_Y, BARSTART_X+100,BAREND_Y);
if(atoi(g_rx_buff[0])<100)
fill(BARSTART_X, BARSTART_X+atoi(g_rx_buff[0]));
else if(atoi(g_rx_buff[0])>=100){
fill(BARSTART_X, BARSTART_X+100);
display_completed();
}
write_temp(g_rx_buff[1]);
}
signed char odox=g_rx_buff[2];
signed char odoy=g_rx_buff[3];
signed char mousex=g_rx_buff[4];
signed char mousey=g_rx_buff[5];
{
int i=0;
for(i=0;i<1000000;++i);
MSS_UART_get_rx( this_uart, g_rx_buff, sizeof(g_rx_buff) );
//erase_block( BARSTART_X, BARSTART_Y, BARSTART_X+100,BAREND_Y);
progress=g_rx_buff[0];
if(tab_state==0 && !is_selecting){
//MSS_UART_get_rx( this_uart, g_rx_buff, sizeof(g_rx_buff) );
erase_block( BARSTART_X+1, BARSTART_Y+1, BARSTART_X+99,BAREND_Y-1);
if(atoi(g_rx_buff[0])<100)
fill(BARSTART_X, BARSTART_X+atoi(g_rx_buff[0]));
else if(atoi(g_rx_buff[0])>=100){
fill(BARSTART_X, BARSTART_X+100);
display_completed();
}
display_temp(g_rx_buff[1]);
display_stepper((int8_t)g_rx_buff[2], (int8_t)g_rx_buff[3]);
display_mouse((int8_t)g_rx_buff[4], (int8_t)g_rx_buff[5]);
display_orientation((uint16_t)g_rx_buff[6] | (uint16_t)g_rx_buff[7] << 8);
}
/*
signed char odox=g_rx_buff[2]; //cent
signed char odoy=g_rx_buff[3];
signed char mousex=g_rx_buff[4]; //cent/1000
signed char mousey=g_rx_buff[5];
uint16_t orientation = (g_rx_buff[6]) | ((uint16_t)g_rx_buff[7] << 8); //deg
*/
}
}
void initInterrupts(){
NVIC_EnableIRQ(GPIO0_IRQn);
MSS_GPIO_config( MSS_GPIO_0, MSS_GPIO_INPUT_MODE | MSS_GPIO_IRQ_EDGE_POSITIVE );
......@@ -133,16 +138,24 @@ void initInterrupts(){
int main() {
initialize(40);
initialize(20);
initInterrupts();
/*
uint8_t i = 1;
display_inprogress();
*/
MSS_UART_set_rx_handler( &g_mss_uart1, uart1_rx_handler, MSS_UART_FIFO_SINGLE_BYTE );
UART_init(&g_uart,COREUARTAPB0_BASE_ADDR,BAUD_VALUE_115200,(DATA_8_BITS|NO_PARITY));
init_tabs(0);
delay(100000);
/*
display_temp(23);
display_stepper(23, 23);
display_mouse(23, 23);
display_orientation(23);
*/
show_options();
while(1){}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment