static Component* createNewComponent (ComponentBuilder::TypeHandler& type, const ValueTree& state, Component* parent) { Component* const c = type.addNewComponentFromState (state, parent); jassert (c != nullptr && c->getParentComponent() == parent); c->setComponentID (getStateId (state)); return c; }
iCurveDataSet *glRenderer::createCurveDataSet(const char *name) { StateId sid = getStateId(name); if (sid != cAni::InvalidStateId) { name = this->_getStateTypeName(sid); } if (0 == strcmp("Image", name)) { return new glCurveDataSet<Image>; } else if (0 == strcmp("Float", name)) { return new glCurveDataSet<float>; } else if (0 == strcmp("Float2", name)) { return new glCurveDataSet<Point2f>; } else if (0 == strcmp("Float3", name)) { return new glCurveDataSet<Point3f>; } else if (0 == strcmp("Rect", name)) { return new glCurveDataSet<Rect>; } /* else if (0 == strcmp("CDS_gl_Int", name)) { return new glCurveDataSet<int>; } */ assert(0 && "unsupported curve data set."); return 0; }
/** * @brief This function handles I2C1 Event interrupt request. * @param None * @retval : None */ void I2C1_EV_IRQHandler(void) { __IO uint32_t SR1Register =0; __IO uint32_t SR2Register =0; #ifdef SLAVE_DMA_USE /* Read SR1 register */ SR1Register = I2C1->SR1; /* If ADDR is set */ if ((SR1Register & 0x0002) == 0x0002) { /* In slave Transmitter/Receiver mode, when using DMA, it is recommended to update the buffer base address and the buffer size before clearing ADDR flag. In fact, the only period when the slave has control on the bus(SCL is stretched so master can not initiate transfers) is the period between ADDR is set and ADDR is cleared. Otherwise, the master can initiate transfers and the buffer size & the buffer address have not yet been updated.*/ /* Update the DMA channels memory base address and count */ Buffer_Tx1[0]=getStateId(state); //Buffer_Tx1[1]=getBatteryLevel(4, 3300, 3600, state.batteryState, ((uint32_t)ADC_ConvertedValueTabPointer[1])*/*41*/ADC_TO_MV_CONSTANT); //Buffer_Tx1[1]=percent; Buffer_Tx1[1]=(uint8_t)((((uint32_t)ADC_ConvertedValueTabPointer[1])*ADC_TO_MV_CONSTANT)/1000); I2C_DMAConfig (I2C1, Buffer_Tx1, 0xFFFF, I2C_DIRECTION_TX); I2C_DMAConfig (I2C1, Buffer_Rx1, 0xFFFF, I2C_DIRECTION_RX); /* Clear ADDR by reading SR2 register */ SR2Register = I2C1->SR2; } #else /* Read the I2C1 SR1 and SR2 status registers */ SR1Register = I2C1->SR1; SR2Register = I2C1->SR2; /* If I2C1 is slave (MSL flag = 0) */ if ((SR2Register &0x0001) != 0x0001) { /* If ADDR = 1: EV1 */ if ((SR1Register & 0x0002) == 0x0002) { /* Clear SR1Register and SR2Register variables to prepare for next IT */ SR1Register = 0; SR2Register = 0; /* Initialize the transmit/receive counters for next transmission/reception using Interrupt */ Tx_Idx1 = 0; Rx_Idx1 = 0; /* Set the values in the buffer */ Buffer_Tx1[0]=getStateId(state); //Buffer_Tx1[1]=getBatteryLevel(4, 3300, 3600, state.batteryState, ((uint32_t)ADC_ConvertedValueTabPointer[1])*/*41*/ADC_TO_MV_CONSTANT); //Buffer_Tx1[1]=percent; Buffer_Tx1[1]=(uint8_t)((((uint32_t)ADC_ConvertedValueTabPointer[1])*ADC_TO_MV_CONSTANT)/1000); } /* If TXE = 1: EV3 */ if ((SR1Register & 0x0080) == 0x0080) { /* Write data in data register */ I2C1->DR = Buffer_Tx1[Tx_Idx1++]; SR1Register = 0; SR2Register = 0; } /* If RXNE = 1: EV2 */ //if ((SR1Register & 0x0040) == 0x0040) //{ // /* Read data from data register */ // Buffer_Rx1[Rx_Idx1++] = I2C1->DR; // SR1Register = 0; // SR2Register = 0; //} /* If STOPF =1: EV4 (Slave has detected a STOP condition on the bus */ if (( SR1Register & 0x0010) == 0x0010) { I2C1->CR1 |= CR1_PE_Set; SR1Register = 0; SR2Register = 0; } } /* End slave mode */ #endif /* If SB = 1, I2C1 master sent a START on the bus: EV5) */ if ((SR1Register &0x0001) == 0x0001) { /* Send the slave address for transmssion or for reception (according to the configured value in the write master write routine */ I2C1->DR = Address; SR1Register = 0; SR2Register = 0; } }
/** * @brief This function handles TIM2 global interrupt request. * @param None * @retval None */ void TIM2_IRQHandler(void) { if (TIM_GetITStatus(TIM2, TIM_IT_Update) != RESET) { if(goingOn) { TurnOnDelyTime--; if(TurnOnDelyTime<=0) { goingOn=false; } } if(goingOff) { TurnOffDelyTime--; if(TurnOffDelyTime<=0) { pcOn=false; goingOff=false; state.unregulatedOutputState=NOT_ACTIVE; GPIO_ResetBits(GPIOB,GPIO_Pin_14); if (state.externalPowerSourceState==DISCONNECTED) { /* Execute actions asociated */ /* Turn UnRegulatedOutput off */ //TurnPowerExternal(); /* PW_CTR to disabled state */ TurnPowerOff(); //It is possible to change the led status /* Change to the new state */ /* Turn RegulatedOutputDC off */ state.regulatedOutputState=OFF; /* The PWM control signal goes to off state afterwards, in the main loop */ #ifdef DEBUG_INFO_USART printf("Status number %d\n", getStateId(state)); #endif /* Disable Power Lines */ #ifdef TR_INVERSE GPIO_SetBits(GPIOA,GPIO_Pin_8); #else GPIO_ResetBits(GPIOA,GPIO_Pin_8); #endif GPIO_ResetBits(GPIOA,GPIO_Pin_11); /* Disabel devices */ TIM_SetCompare3(TIM3,0); /* Enter STOP mode */ #ifdef DEBUG_INFO_USART printf("Going to STOP mode\n"); #endif #ifndef DEBUG_NO_STOP TIM_ClearITPendingBit(TIM2, TIM_IT_Update); PWR_EnterSTOPMode(PWR_Regulator_LowPower, PWR_STOPEntry_WFI); #endif } } } if(batteryKoFlag) { BatteryKoTimeout--; } if(noCurrentFlag) { NoCurrentTimeout--; } if(sendPcPulse && pcPulseStarted) { GPIO_SetBits(GPIOB,GPIO_Pin_8); sendPcPulse=false; pcPulseStarted=false; } TIM_ClearITPendingBit(TIM2, TIM_IT_Update); } else if (TIM_GetITStatus(TIM2, TIM_IT_CC1) != RESET) { if(sendPcPulse) { GPIO_ResetBits(GPIOB,GPIO_Pin_8); pcPulseStarted=true; } TIM_ClearITPendingBit(TIM2, TIM_IT_CC1); } }
void EXTI15_10_IRQHandler(void) { if (EXTI_GetITStatus(EXTI_Line10) != RESET) { /* Wake up from STOP */ SYSCLKConfig_STOP(); EXTI_ClearITPendingBit(EXTI_Line10); } else if (EXTI_GetITStatus(EXTI_Line11) != RESET) { //Charger connector connected/disconnected /* Wake up from STOP */ SYSCLKConfig_STOP(); #ifdef DEBUG_INFO_USART printf("Charger connector present\n"); #endif #ifdef TEST_BOARD printf("Charger connector present\n"); #endif EXTI_ClearITPendingBit(EXTI_Line11); } else if (EXTI_GetITStatus(EXTI_Line12) != RESET) { //Charger pressent #ifdef DEBUG_INFO_USART printf("Charger with power "); #endif /* Execute actions asociated */ TurnPowerExternal(); TIM_SetCompare3(TIM3,320); /* Change to the new state */ state.externalPowerSourceState=CONNECTED; state.batteryState=CHARGING_CC; /* Turn RegulatedOutput on */ state.regulatedOutputState=ON; #ifdef DEBUG_INFO_USART printf("Status number %d\n", getStateId(state)); #endif EXTI_ClearITPendingBit(EXTI_Line12); } else if (EXTI_GetITStatus(EXTI_Line13) != RESET) { //Charger not pressent #ifdef DEBUG_INFO_USART printf("Charger disconnected "); #endif /* Execute actions asociated */ /* Change to the new state */ TurnPowerBattery(); state.externalPowerSourceState=DISCONNECTED; state.batteryState=DISCHARGING; #ifdef DEBUG_INFO_USART printf("Status number %d\n", getStateId(state)); #endif EXTI_ClearITPendingBit(EXTI_Line13); if(/*state.regulatedOutputState==OFF*/!pcOn) { state.regulatedOutputState=OFF; /* Disable Power Lines */ //TurnPowerExternal(); /* PW_CTR to disabled state */ TurnPowerOff(); state.unregulatedOutputState=NOT_ACTIVE; #ifdef TR_INVERSE GPIO_SetBits(GPIOA,GPIO_Pin_8); #else GPIO_ResetBits(GPIOA,GPIO_Pin_8); #endif GPIO_ResetBits(GPIOA,GPIO_Pin_11); GPIO_ResetBits(GPIOB,GPIO_Pin_14); /* Disabel devices */ TIM_SetCompare3(TIM3,0); /* Enter STOP mode */ #ifdef DEBUG_INFO_USART printf("Going to STOP mode\n"); #endif #ifndef DEBUG_NO_STOP PWR_EnterSTOPMode(PWR_Regulator_LowPower, PWR_STOPEntry_WFI); #endif } else { TIM_SetCompare3(TIM3,1440); } } if (EXTI_GetITStatus(EXTI_Line14) != RESET) { //Switch Button pressed #ifdef DEBUG_INFO_USART printf("Start/stop button pressed "); #endif #ifdef TEST_BOARD printf("Start/stop button pressed "); #endif if(/*state.regulatedOutputState==ON*/pcOn && !goingOff && !goingOn) { /* Generate "Turn OFF PC" signal */ sendPcPulse=true; /* Start timer to turn off the PC after X seconds */ TurnOffDelyTime=PC_OFF_TIMEOUT; goingOff=true; #ifdef DEBUG_INFO_USART printf("Going OFF\n"); #endif #ifdef TEST_BOARD printf("Going OFF\n"); #endif } else if(/*state.regulatedOutputState==OFF*/!pcOn && !goingOn) { /* Turn RegulatedOutput on */ state.regulatedOutputState=ON; pcOn=true; /* Turn UnRegulatedOutput on */ if(state.externalPowerSourceState==DISCONNECTED) { TurnPowerBattery(); /* PW_CTR to enable state */ TIM_SetCompare3(TIM3,1440); } else TurnPowerExternal(); state.unregulatedOutputState=ACTIVE; GPIO_SetBits(GPIOB,GPIO_Pin_14); /* Generate "Turn ON PC" signal */ sendPcPulse=true; /* Turn RegulatedOutput timeout On */ TurnOnDelyTime=PC_ON_TIMEOUT; goingOn=true; #ifdef DEBUG_INFO_USART printf("Going ON\n"); #endif #ifdef TEST_BOARD printf("Going ON\n"); #endif } EXTI_ClearITPendingBit(EXTI_Line14); } }
void EXTI9_5_IRQHandler(void) { if (EXTI_GetITStatus(EXTI_Line6) != RESET) { //Battery to KO status #ifdef DEBUG_INFO_USART printf("Battery to KO "); #endif /* Execute actions asociated */ //Send "Turn OFF PC" signal sendPcPulse=true; //Start timer to turn off the PC after PC_OFF_TIMEOUT seconds TurnOffDelyTime=PC_OFF_TIMEOUT; goingOff=true; /* Change to the new state */ state.batteryState=KO; #ifdef DEBUG_INFO_USART printf("Status number %d\n", getStateId(state)); #endif EXTI_ClearITPendingBit(EXTI_Line6); } else if (EXTI_GetITStatus(EXTI_Line7) != RESET) { //Battery charged #ifdef DEBUG_INFO_USART printf("Battery charged "); #endif /* Execute actions asociated */ /* Change to the new state */ state.batteryState=CHARGED; #ifdef DEBUG_INFO_USART printf("Status number %d\n", getStateId(state)); #endif TIM_SetCompare3(TIM3,1140); EXTI_ClearITPendingBit(EXTI_Line7); } else if (EXTI_GetITStatus(EXTI_Line8) != RESET) { //Battery to CV charging state #ifdef DEBUG_INFO_USART printf("Battery to charging at CV "); #endif /* Execute actions asociated */ /* Change to the new state */ state.batteryState=CHARGING_CV; #ifdef DEBUG_INFO_USART printf("Status number %d\n", getStateId(state)); #endif TIM_SetCompare3(TIM3,760); EXTI_ClearITPendingBit(EXTI_Line8); } else if (EXTI_GetITStatus(EXTI_Line9) != RESET) { //No current at Regulated output #ifdef DEBUG_INFO_USART printf("No load at Regulated Output "); #endif pcOn=false; state.unregulatedOutputState=NOT_ACTIVE; GPIO_ResetBits(GPIOB,GPIO_Pin_14); //Apago alimentacion PC //Espero 3seg //Enciendo alimentacion PC if (state.externalPowerSourceState==DISCONNECTED) { /* Execute actions asociated */ /* Turn UnRegulatedOutput off */ //TurnPowerExternal(); /* PW_CTR to disabled state */ TurnPowerOff(); goingOff=false; //It is possible to change the led status /* Change to the new state */ /* Turn RegulatedOutputDC off */ state.regulatedOutputState=OFF; /* The PWM control signal goes to off state afterwards, in the main loop */ #ifdef DEBUG_INFO_USART printf("Status number %d\n", getStateId(state)); #endif /* Disable Power Lines */ #ifdef TR_INVERSE GPIO_SetBits(GPIOA,GPIO_Pin_8); #else GPIO_ResetBits(GPIOA,GPIO_Pin_8); #endif GPIO_ResetBits(GPIOA,GPIO_Pin_11); /* Disabel devices */ TIM_SetCompare3(TIM3,0); /* Enter STOP mode */ #ifdef DEBUG_INFO_USART printf("Going to STOP mode\n"); #endif EXTI_ClearITPendingBit(EXTI_Line9); #ifndef DEBUG_NO_STOP PWR_EnterSTOPMode(PWR_Regulator_LowPower, PWR_STOPEntry_WFI); #endif } else { EXTI_ClearITPendingBit(EXTI_Line9); } } }