예제 #1
0
int app_batt_alert_timer_handler(ke_msg_id_t const msgid,
                                        void const *param,
										ke_task_id_t const dest_id,
										ke_task_id_t const src_id)
{
		
	
		//Read LED GPIO state
    if(bat_lvl_alert_used)
    {		
#if 0
			if (bat_led_state)
			{
				if(GPIO_GetPinStatus(GPIO_ALERT_PWR_PORT,GPIO_ALERT_PWR_PIN)==false)
				{
					//正在充电
				}
				else
				{
					GPIO_SetActive( bat_led_port, bat_led_pin);  //V3.2版本后将黄灯逻辑电平反向
					bat_led_state = 0;
				}
				app_timer_set(APP_BATT_ALERT_TIMER, dest_id, 50);//20,电池电量低,报警灯闪烁速度,,delay延时
			}
			else
			{
				GPIO_SetInactive( bat_led_port, bat_led_pin);//V3.2版本后将黄灯逻辑电平反向
				bat_led_state = 1;
				app_timer_set(APP_BATT_ALERT_TIMER, dest_id, 50);//5,电池电量低,报警灯闪烁速度,delay延时
			}
#endif
    }
		
    return (KE_MSG_CONSUMED);
}
예제 #2
0
const struct rwip_eif_api* rwip_eif_get_func(uint8_t type)
{
    const struct rwip_eif_api* ret = NULL;
    switch(type)
    {
        case RWIP_EIF_AHI:
        case RWIP_EIF_HCIC:
        {
#ifdef CFG_HCI_BOTH_EIF
            if (GPIO_GetPinStatus(HCI_EIF_SELECT_PORT,HCI_EIF_SELECT_PIN))
                ret = &uart_api;
            else
                ret = &spi_api;
#else
  #ifdef CFG_HCI_SPI
            ret = &spi_api;     // select spi api
  #else
            ret = &uart_api;    // select uart api
  #endif
#endif
        }
        break;
        default:
        {
            ASSERT_ERR(0);
        }
        break;
    }
    return ret;
}
예제 #3
0
void gpio0_callback(void)
{
    NVIC_DisableIRQ(GPIO0_IRQn);    // Disable this interrupt
    
    if(GPIO_GetPinStatus(UART1_CTS_PORT, UART1_CTS_PIN)==FALSE)
    {
        app_override_ble_xon();
        //Set interrupt to detect rising edge of CTS
        GPIO_EnableIRQ(UART1_CTS_PORT, UART1_CTS_PIN, GPIO0_IRQn, 0, 1, 0);
    }
    else if(GPIO_GetPinStatus(UART1_CTS_PORT, UART1_CTS_PIN)==TRUE)
    {
        app_override_ble_xoff();
        //Set interrupt to detect falling edge of CTS
        GPIO_EnableIRQ(UART1_CTS_PORT, UART1_CTS_PIN, GPIO0_IRQn, 1, 0, 0);
    }
    NVIC_ClearPendingIRQ(GPIO0_IRQn);
	NVIC_EnableIRQ(GPIO0_IRQn);     // Enable this interrupt
}
예제 #4
0
/**
 ****************************************************************************************
 * @brief Enable pad's and peripheral clocks assuming that peripherals' power domain is down. The Uart and SPi clocks are set.
 *
 * @return void
 ****************************************************************************************
 */
void periph_init(void) 
{
	// Power up peripherals' power domain
    SetBits16(PMU_CTRL_REG, PERIPH_SLEEP, 0);
    while (!(GetWord16(SYS_STAT_REG) & PER_IS_UP)) ; 
    
	
	//rom patch
	patch_func();
	
	//Init pads
	set_pad_functions();
    
    SetBits16(CLK_PER_REG, UART1_ENABLE, 1);    // enable clock - always @16MHz
	
    // baudr=9-> 115k2
    // mode=3-> no parity, 1 stop bit 8 data length

    uart_sps_init(UART_SPS_BAUDRATE, 3); //exact baud rate defined in uart.h

   // Enable the pads
	SetBits16(SYS_CTRL_REG, PAD_LATCH_EN, 1);

#if (EXT_SLEEP_ENABLED)
    app_scheduler_reinit();
#endif //EXT_SLEEP_ENABLED

#if ((UART_HW_FLOW_ENABLED) && !defined(GPIO_DRV_IRQ_HANDLING_DISABLED))
    GPIO_RegisterCallback(GPIO0_IRQn, gpio0_callback);
    if(GPIO_GetPinStatus(UART1_CTS_PORT,UART1_CTS_PIN)==FALSE)
    {
        GPIO_EnableIRQ(UART1_CTS_PORT, UART1_CTS_PIN, GPIO0_IRQn, 0, 1, 0);
    }
    else if(GPIO_GetPinStatus(UART1_CTS_PORT,UART1_CTS_PIN)==TRUE)
    {
        GPIO_EnableIRQ(UART1_CTS_PORT, UART1_CTS_PIN, GPIO0_IRQn, 1, 0, 0);
    }
#endif //((UART_HW_FLOW_ENABLED) && !defined(GPIO_DRV_IRQ_HANDLING_DISABLED))
}