Beispiel #1
0
int main(void)
{
    // board setup stuff
    led_init();
    uart_init();
    floppy_low_init();
    sdpin_init();
    spi_low_cs_init();
    spi_low_mst_init();
    //timer_init();

    // say hello
    uart_send_string((u08 *)"--- dfx-sampler sam7x/SPI ---");
    uart_send_crlf();

    // do initial setup
    rtc_init();
    memory_init();
    floppy_select_on();
    track_init();
    floppy_select_off();
    net_init();

    // print current RTC
    uart_send_string((u08 *)"rtc:  ");
    uart_send_string((u08 *)rtc_get_time_str());
    uart_send_crlf();

    // show network info
    net_info();

    while(1) {
        uart_send_string((u08 *)"> ");
        
        led_green(1);
        
        // get next command via SPI
        u08 *cmd;
        u08 len = cmd_uart_get_next(&cmd);

        led_green(0);
        
        if(len>0) {
            u08 result[CMD_MAX_SIZE];
            u08 res_size = CMD_MAX_SIZE;
            
            // parse and execute command
            cmd_parse(len, cmd, &res_size, result);
            
            // report result
            if(res_size > 0) {
                uart_send_data(result, res_size);
                uart_send_crlf();
            }
        }
    }
}
Beispiel #2
0
// diagnose commands
static void cmd_diagnose(void)
{
  u08 cmd, res;
  u08 exit = 0;
  while((cmd = get_char()) != 0) {
     switch(cmd) {
     case 'b': // buttons -> returns 0=no button  1=button2  2=button2  3=both buttons
       res = button1_pressed() | (button2_pressed() << 1);
       set_result(res);
       break;
     case 'l': // led: param: 1=green  2=yellow  3=both
       {
         cmd = parse_hex_byte(3);
         led_green(cmd  & 1);
         led_yellow(cmd & 2);
         set_result(cmd);
         delay_ms(1000);
       }
       break;
     case 'i': // io sd diagnose: show sd detect and sd protect
       {
         res = sdpin_no_card() ? 1 :0;
         res |= sdpin_write_protect() ? 2:0;
         set_result(res);
       }
       break;
     default:
       set_result(ERROR_SYNTAX);
     case '.':
       exit = 1;
       break;
     }
     if(exit) break;
   }
}
Beispiel #3
0
/*
 * Blink the status LEDs a little to indicate that the device has just
 * booted. This is useful to see if an error is making the device reboot
 * when not supposed to. And it looks cool. 
 */
void boot_msg(void)
{
    int i = 0;
    LED_PORT |= LED_GREEN;
    for (i = 0; i < 2; i++) {
	/* blinky */
	delay_ms(1000);
	led_green(0x00);
	led_red(0x01);
	/* blink */
	delay_ms(1000);
	led_red(0x00);
	led_green(0x01);
    }
    delay_ms(1000);
    led_green(0x00);
}
Beispiel #4
0
static void initialisation(void){
	PCONP |= (1 << 12); 					// Enable power to AD block
	for (i = 0; i < 20000000; i++); 		// Wait for initial display
	IODIR0 |= 0x00000C00; 					// config touch LED pins as outputs
	led_green(); 							// make the LED green

	PINMODE4 &= ~(0xFFFF); 					// P2[7:0]pullups
	PINSEL4 &= ~(0xFFFF); 					// P2[7:0]are GPIO
	FIO2DIR0 = 0xFF; 						// P2[7:0]are outputs
	FIO2MASK0 = 0x00; 						// P2[7:0]enabled for fast I/O

	touch_detect();							// setup for touch detection
	install_irq(17, (void*)detected, 1); 	// setup interrupt vector
	IO0_INT_EN_F = X_plus;					// enable falling edge X-plus interrupt
}
Beispiel #5
0
int main(int argc, char **argv)
{
	initialize();
	clear_array();
	
	//Message to display on serial console. 
	//USART_SendString("\tHello world.\r\n"); 
	
	
	char str [33];
	
	while(1){
		PORTC = PINA;
		//Creating the "X":
		int i, j, k;
		
		//printf("\tHello \r\n");
		

		
			
		//IF no button pressed, light up as green
		if (PORTC != 0b00000001) {
			//clear_array();
			for (i = 7; i >= 0; i--) {
				PORTE = i;
				led_green(7-i, 7-i);
				led_green(7-i, i);
				_delay_ms(0.1);
				
				#ifdef DEBUG
					USART_SendString("\t\r\nX: ");
					USART_Transmit(itoa(7-i, str, 10));
					USART_SendString("\t\r\nY(top): ");
					USART_Transmit(itoa(7-i, str, 10));
					USART_SendString("\t\r\nY(bottom): ");
					USART_Transmit(itoa(i, str, 10));
				#endif
				
				set_array_green(0);
				
			}
		}
		
		//IF button 1 is pressed, light up as red
		if (PORTC & 0b00000010) {
			clear_array();
			for (i = 7; i >= 0; i--) {
				PORTE = i;
				led_red(7-i, 7-i);
				led_red(7-i, i);
				_delay_ms(0.1);
				
				#ifdef DEBUG
					USART_SendString("\t\r\nX: ");
					USART_Transmit(itoa(7-i, str, 10));
					USART_SendString("\t\r\nY(top): ");
					USART_Transmit(itoa(7-i, str, 10));
					USART_SendString("\t\r\nY(bottom): ");
					USART_Transmit(itoa(i, str, 10));
				#endif
				
				set_array_red(0);
				
			}
		}
		
		//IF button 5 is pressed, light up as blue.
		if (PORTC & 0b00100000) {
			clear_array();
			for (i = 7; i >= 0; i--) {
				PORTE = i;
				led_blue(7-i, 7-i);
				led_blue(7-i, i);
				_delay_ms(0.1);
				
				#ifdef DEBUG
					USART_SendString("\t\r\nX: ");
					USART_Transmit(itoa(7-i, str, 10));
					USART_SendString("\t\r\nY(top): ");
					USART_Transmit(itoa(7-i, str, 10));
					USART_SendString("\t\r\nY(bottom): ");
					USART_Transmit(itoa(i, str, 10));
				#endif
				
				set_array_blue(0);
			}
		}	
	}
}