Beispiel #1
0
int main(int argc, char *argv[]) {
	int res;

	printf("SPI slave start!\n");

	//HAL_Init();

	init_leds();
	res = spi_init();
	if (res < 0) {
		return -1;
	}
    BSP_LED_Toggle(LED4);
	spi_test();

	return 0;
}
 /**
 ****************************************************************************************
 * @brief  Main routineof the DA14580 Peripheral Examples Functions
 * DA14580 Peripherals Udage Examples
 *        - UART
 *        - SPI Flash
 *        - Boot From SPI flash
 *        - EEPROM
 *        - Timers
 *        - Battery Level Indication - ADC
 *        - Quadrature
 *        - Buzzer
 * Due to HW Development Kit limitations, user must select one of the follwoing configuartion for UART, SPI, I2C.
 * Addicional Hardware (SPI, EEPROM boadrs) or Hardware modification may needed for some tof the tests. 
 * More information in the file periph_setup.h, Application Notes, and User Guide for DA14580
 *        - UART only  ( No HW modifications on rev C2 motherboard, No additional hardware)
 *        - SPI Flash with UART (HW modifications & additional Hardware needed , SPI_DI_PIN on the additional SPI / EEPROM daughterboard )
 *        - Boot From SPI Flash with UART  (HW modifications & additional Hardware needed, (UART TX) )
 *        - Boot From SPI Flash without UART (Additional Hardware needed)
 *        - Boot From EEPROM with UART (Additional Hardware needed)
 * 
 ****************************************************************************************
*/
int main (void)
{
	  short int index = 0;
	  char mchoice;
 
	  periph_init();
	  printf_string("\n\rDA14580 Peripheral Examples\n\r");
  	  printf_string(    "---------------------------\n\r");  
    printf_string("Before running the tests:\n\r");
    printf_string("  1) Make sure you have connected the appropriate peripheral(s).\n\r");
    printf_string("  2) Select the associated hardware configuration in 'periph_setup.h'.\n\r");
    printf_string("  3) Build.\n\r");
	printf_string("Please, refer to DA14580 Peripheral Examples User Manual\n\r");
    printf_string("for detailed instructions.\n\r");
    
	  print_menu();
	 	 
		while(1){
			if (index==1) break;
			mchoice = uart_receive_byte();
			switch (mchoice){
					case 'u': uart_test(); endtest_bridge(&index); break;
#ifdef SPI_ENABLED                 
					case 'f': spi_test(); endtest_bridge(&index); break;               
#endif //SPI_ENABLED
#ifdef EEPROM_ENABLED                
					case 'e': i2c_test(); endtest_bridge(&index); break;                
#endif //EEPROM_ENABLED                                
#ifdef QUADEC_ENABLED
					case 'q': quad_decoder_test(); endtest_bridge(&index); break;
#endif //QUADEC_ENABLED      

#ifdef BUZZER_ENABLED                
					case 't': timer0_test(); endtest_bridge(&index); break;
                    case 'p': timer2_test(); endtest_bridge(&index); break;        
#endif //BUZZER_ENABLED              
				  case 'b': batt_test(); endtest_bridge(&index); break;
				  case 'x': index=1;break;		
					default: print_input(); continue;
			};
		};
	
		printf_string("\n\r End of tests\n\r");
		while(1);
}
Beispiel #3
0
int main(int argc, char *argv[])
{
	if(1 != bcm2835_init())
		return FAIL;

	if(argc != 2)
	{
		uSage();
		return FAIL;
	}
	if (0 == strcasecmp(argv[1], "out"))
	{
		out_test();
	}
	else if (0 == strcasecmp(argv[1], "pud"))
	{
		pud_test();
	}
	else if (0 == strcasecmp(argv[1], "edge"))
	{
		edge_test();
	}
	else if(0 == strcasecmp(argv[1], "pwm"))
	{
		pwm_test();
	}
	else if(0 == strcasecmp(argv[1], "i2c"))
	{
		i2c_test();
	}
	else if(0 == strcasecmp(argv[1], "spi"))
	{
		spi_test();
	}
	else
	{
		uSage();
		return FAIL;
	}
	
	bcm2835_close();
	return 0;
}
 /**
 ****************************************************************************************
 * @brief  Main routineof the DA14580 Engineering Examples Functions
 * DA14580 Peripherals Udage Examples
 *        - UART
 *        - SPI Flash
 *        - Boot From SPI flash
 *        - EEPROM
 *        - Timers
 *        - Battery Level Indication - ADC
 *        - Quadrature
 *        - Buzzer
 * Due to HW Development Kit limitations, user must select one of the follwoing configuartion for UART, SPI, I2C.
 * Addicional Hardware (SPI, EEPROM boadrs) or Hardware modification may needed for some tof the tests. 
 * More information in the file periph_setup.h, Application Notes, and User Guide for DA14580
 *        - UART only  ( No HW modifications on rev C2 motherboard, No additional hardware)
 *        - SPI Flash with UART (HW modifications & additional Hardware needed , SPI_DI_PIN on the additional SPI / EEPROM daughterboard )
 *        - Boot From SPI Flash with UART  (HW modifications & additional Hardware needed, (UART TX) )
 *        - Boot From SPI Flash without UART (Additional Hardware needed)
 *        - Boot From EEPROM with UART (Additional Hardware needed)
 * 
 ****************************************************************************************
*/
int main (void)
{
	  short int index = 0;
	  char mchoice;
 
	  periph_init();
	  printf_string("DA14580 Engineering Examples\n\r");
 	  printf_string("Connect the appropriate peripheral before choosing each test\n\r\n\r");
	  printf_string("Refer to Engineering Examples User Guide\n\r\n\r");
    
	  print_menu();
	 	 
		while(1){
			if (index==1) break;
			mchoice = uart_receive_byte();
			switch (mchoice){
					case 'u': uart_test(); endtest_bridge(&index); break;
					case 'f': spi_test(); endtest_bridge(&index); break;
                    case 'i': spi_image(); endtest_bridge(&index); break;
					case 'e': i2c_test(); endtest_bridge(&index); break;
					case 'd': i2c_image(); endtest_bridge(&index); break;                
//					case 't': swt_test(); endtest_bridge(&index); break;
#ifdef QUADEC_ENABLED
					case 'q': quad_decoder_test(); endtest_bridge(&index); break;
#endif //QUADEC_ENABLED                
					case 't': timer0_test(); endtest_bridge(&index); break;
                    case 'p': timer2_test(); endtest_bridge(&index); break;        
				    case 'b': batt_test(); endtest_bridge(&index); break;
				    case 'x': index=1;break;		
					default: print_input(); continue;
			};
		};
	
		printf_string("\n\r End of tests\n\r");
		while(1);
}