int32_t SDRegisterSPI(void (*pselect)(void), char (*pxchg)(char val), void (*pdeselect)(void)) { uint32_t result; GenerateCRCTable(); // need to do at some point, here is as good as any select = pselect; xchg = pxchg; deselect = pdeselect; result = SDCARD_OK; // assume all pointers are at least believable registered = FALSE; if (select && xchg && deselect) registered = TRUE; if (!registered) result = SDCARD_REGFAIL; // missing function handle return result; }
/********************************************************************* * @fn HidKbdMouse_Init * * @brief Initialization function for the HidKbdMouse App Task. * This is called during initialization and should contain * any application specific initialization (ie. hardware * initialization/setup, table initialization, power up * notificaiton ... ). * * @param task_id - the ID assigned by OSAL. This ID should be * used to send messages and set timers. * * @return none */ void HidKbdMouse_Init( uint8 task_id ) { setupUART(); GenerateCRCTable(); //printf("%x\n",default_name_crc); device_name = osal_mem_alloc(20); device_name_length = osal_mem_alloc(1); device_name_crc = osal_mem_alloc(1); hidKbdMouseTaskId = task_id; // Setup the GAP VOID GAP_SetParamValue( TGAP_CONN_PAUSE_PERIPHERAL, DEFAULT_CONN_PAUSE_PERIPHERAL ); // Setup the GAP Peripheral Role Profile { uint8 initial_advertising_enable = TRUE; //previously FALSE // By setting this to zero, the device will go into the waiting state after // being discoverable for 30.72 second, and will not being advertising again // until the enabler is set back to TRUE uint16 gapRole_AdvertOffTime = 0; uint8 enable_update_request = DEFAULT_ENABLE_UPDATE_REQUEST; uint16 desired_min_interval = DEFAULT_DESIRED_MIN_CONN_INTERVAL; uint16 desired_max_interval = DEFAULT_DESIRED_MAX_CONN_INTERVAL; uint16 desired_slave_latency = DEFAULT_DESIRED_SLAVE_LATENCY; uint16 desired_conn_timeout = DEFAULT_DESIRED_CONN_TIMEOUT; // Set the GAP Role Parameters GAPRole_SetParameter( GAPROLE_ADVERT_ENABLED, sizeof( uint8 ), &initial_advertising_enable ); GAPRole_SetParameter( GAPROLE_ADVERT_OFF_TIME, sizeof( uint16 ), &gapRole_AdvertOffTime ); GAPRole_SetParameter( GAPROLE_ADVERT_DATA, sizeof( advData ), advData ); //name change - 21/12/2014 osal_snv_read(SNV_ID_DEVICE_NAME_CRC, 1, device_name_crc); osal_snv_read(SNV_ID_DEVICE_NAME_LENGTH, 1, device_name_length); osal_snv_read(SNV_ID_DEVICE_NAME, 20, device_name); if(*device_name_crc != getCRC(device_name, *device_name_length)) { printf("Using default scan response name\r\n"); GAPRole_SetParameter( GAPROLE_SCAN_RSP_DATA, sizeof ( default_scanData ), default_scanData ); } else { //make changes directly to the default_scanData. Since this variable is set at start-up, it should not matter uint8 len = *device_name_length; //uint8 default_name_length = default_scanData[0]; default_scanData[0] = len + 1; uint8 i; for(i = 0; i < len; i++) { default_scanData[i+2] = device_name[i]; } GAPRole_SetParameter( GAPROLE_SCAN_RSP_DATA, sizeof ( default_scanData ), default_scanData ); } GAPRole_SetParameter( GAPROLE_PARAM_UPDATE_ENABLE, sizeof( uint8 ), &enable_update_request ); GAPRole_SetParameter( GAPROLE_MIN_CONN_INTERVAL, sizeof( uint16 ), &desired_min_interval ); GAPRole_SetParameter( GAPROLE_MAX_CONN_INTERVAL, sizeof( uint16 ), &desired_max_interval ); GAPRole_SetParameter( GAPROLE_SLAVE_LATENCY, sizeof( uint16 ), &desired_slave_latency ); GAPRole_SetParameter( GAPROLE_TIMEOUT_MULTIPLIER, sizeof( uint16 ), &desired_conn_timeout ); } // Set the GAP Characteristics if(*device_name_crc != getCRC(device_name, *device_name_length)) { // printf("Using default device name"); GGS_SetParameter( GGS_DEVICE_NAME_ATT, GAP_DEVICE_NAME_LEN, (void *) attDeviceName ); } else { // printf("Using stored device name"); // printf("%s\r\n", device_name); GGS_SetParameter( GGS_DEVICE_NAME_ATT, *device_name_length + 1, (void *) device_name ); } //Allow device to change name uint8 devNamePermission = GATT_PERMIT_READ|GATT_PERMIT_WRITE; GGS_SetParameter( GGS_W_PERMIT_DEVICE_NAME_ATT, sizeof ( uint8 ), &devNamePermission ); // Setup the GAP Bond Manager { uint32 passkey = DEFAULT_PASSCODE; uint8 pairMode = DEFAULT_PAIRING_MODE; uint8 mitm = DEFAULT_MITM_MODE; uint8 ioCap = DEFAULT_IO_CAPABILITIES; uint8 bonding = DEFAULT_BONDING_MODE; GAPBondMgr_SetParameter( GAPBOND_DEFAULT_PASSCODE, sizeof( uint32 ), &passkey ); GAPBondMgr_SetParameter( GAPBOND_PAIRING_MODE, sizeof( uint8 ), &pairMode ); GAPBondMgr_SetParameter( GAPBOND_MITM_PROTECTION, sizeof( uint8 ), &mitm ); GAPBondMgr_SetParameter( GAPBOND_IO_CAPABILITIES, sizeof( uint8 ), &ioCap ); GAPBondMgr_SetParameter( GAPBOND_BONDING_ENABLED, sizeof( uint8 ), &bonding ); } // Setup Battery Characteristic Values { uint8 critical = DEFAULT_BATT_CRITICAL_LEVEL; Batt_SetParameter( BATT_PARAM_CRITICAL_LEVEL, sizeof (uint8), &critical ); } // Set up HID keyboard service HidKbM_AddService( ); // Register for HID Dev callback HidDev_Register( &hidKbdMouseCfg, &hidKbdMouseHidCBs ); // Register for all key events - This app will handle all key events RegisterForKeys( hidKbdMouseTaskId ); #if defined( CC2540_MINIDK ) // makes sure LEDs are off HalLedSet( (HAL_LED_1 | HAL_LED_2), HAL_LED_MODE_OFF ); // For keyfob board set GPIO pins into a power-optimized state // Note that there is still some leakage current from the buzzer, // accelerometer, LEDs, and buttons on the PCB. P0SEL = 0; // Configure Port 0 as GPIO P1SEL = 0; // Configure Port 1 as GPIO P2SEL = 0; // Configure Port 2 as GPIO P0DIR = 0xFC; // Port 0 pins P0.0 and P0.1 as input (buttons), // all others (P0.2-P0.7) as output P1DIR = 0xFF; // All port 1 pins (P1.0-P1.7) as output P2DIR = 0x1F; // All port 1 pins (P2.0-P2.4) as output P0 = 0x03; // All pins on port 0 to low except for P0.0 and P0.1 (buttons) P1 = 0; // All pins on port 1 to low P2 = 0; // All pins on port 2 to low #endif // #if defined( CC2540_MINIDK ) //init keyboard report manager KBD_Report_Init(); // Setup a delayed profile startup osal_set_event( hidKbdMouseTaskId, START_DEVICE_EVT ); }
CArchiveScanner::CArchiveScanner(void) : isDirty(false) { GenerateCRCTable(); }