Ejemplo n.º 1
0
/**
 * e_compass_detect - Device detection callback for automatic device creation
 * return value:  
 *                    = 0; success;
 *                    < 0; err
 */
static int e_compass_detect(struct i2c_client *client, struct i2c_board_info *info)
{
	struct i2c_adapter *adapter = client->adapter;
	int ret;

	dprintk(DEBUG_INIT, "enter func %s. \n", __FUNCTION__);
	printk("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
	if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
		return -ENODEV;

	if(1 == adapter->nr){
		dprintk(DEBUG_INIT,"%s: addr= %x\n",__func__,client->addr);
		ret = i2c_test(client);
		if(!ret){
			printk("%s:I2C connection might be something wrong \n",__func__);
			return -ENODEV;
		}else{
			strlcpy(info->type, AKM_I2C_NAME, I2C_NAME_SIZE);
			return 0;
		}

	}else{
		return -ENODEV;
	}
}
Ejemplo n.º 2
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);
}
Ejemplo n.º 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;
}
Ejemplo n.º 4
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);
}
Ejemplo n.º 5
0
/**
 * ctp_detect - Device detection callback for automatic device creation
 * return value:  
 *                    = 0; success;
 *                    < 0; err
 */
static int ctp_detect(struct i2c_client *client, struct i2c_board_info *info)
{
	struct i2c_adapter *adapter = client->adapter;
        int  ret = -1;
      
        if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)){
        	printk("======return=====\n");
                return -ENODEV;
        }
        
        if(twi_id == adapter->nr){
                dprintk(DEBUG_INIT,"%s: addr = %x\n", __func__, client->addr);
                ret = i2c_test(client);
                if(!ret){
        		printk("%s:I2C connection might be something wrong \n", __func__);
        		return -ENODEV;
        	}else{           	    
            	        strlcpy(info->type, CTP_NAME, I2C_NAME_SIZE);
    		    return 0;	
	        }
	}else{
	        return -ENODEV;
	}
}
Ejemplo n.º 6
0
/*===========================================================================*/
int main(void)
{
	/*
	 * System initializations.
	 * - HAL initialization, this also initializes the configured device drivers
	 *   and performs the board-specific initializations.
	 * - Kernel initialization, the main() function becomes a thread and the
	 *   RTOS is active.
	 */

	halInit();
	chSysInit();


	/*
	 * kruciální řádek protože pokud se to zapne bez debugru tak je tam
	 * jenom bordel a když se to pak srovnává s NULL tak se to cely
	 * vymrdá a skoči do unhandled exception
	 */
	uint8_t i;
	for (i = 0 ; i< 60 ; i++)
		logic_pointery[i] = NULL;

	//test_logic_fill();

	chThdSleepMilliseconds(100);

	/*
	 * Activates the USB driver and then the USB bus pull-up on D+.
	 */
	usb_user_init();

	/*
	 * Shell manager initialization.
	 */
	shellInit();

	/*
	 * Init tft display ssd1289 and gui
	 */
	gui_init();


	/**
	 * @brief start the whole bad thing
	 */
	logic_init();

	/*
	 * start external interrupt system
	 */
	extStart(&EXTD1, &extcfg);

	/*
	 * start wah thread
	 */
	wah_init();

	/*
	 * Normal main() thread activity, in this demo it does nothing except
	 * sleeping in a loop and check the button state.
	 */

	EventListener el;
	chEvtRegister(&event_touch, &el, TOUCH_PUSH);

#ifdef I2C_TEST
	i2c_test();
#endif

	gui_thread();

	while(TRUE);
}