本文整理汇总了C++中STM_EVAL_LEDOff函数的典型用法代码示例。如果您正苦于以下问题:C++ STM_EVAL_LEDOff函数的具体用法?C++ STM_EVAL_LEDOff怎么用?C++ STM_EVAL_LEDOff使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了STM_EVAL_LEDOff函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update_temporized_LED
/* Function called by SysTick_Handler() */
void update_temporized_LED(Led_TypeDef Led)
{
BlueLED_counter--;
if (BlueLED_counter == 0) STM_EVAL_LEDOff(LED_Blue);
}
示例2: EXTI15_10_IRQHandler
/**
* @brief This function handles External lines 15 to 10 interrupt request.
* @param None
* @retval None
*/
void EXTI15_10_IRQHandler(void)
{
/* Checks whether the IOE EXTI line is asserted or not */
if(EXTI_GetITStatus(IOE_IT_EXTI_LINE) != RESET)
{
#ifdef IOE_INTERRUPT_MODE
/* Check if the interrupt source is the Touch Screen */
if (IOE_GetGITStatus(IOE_1_ADDR, IOE_TS_IT) & IOE_TS_IT)
{
static TS_STATE* TS_State;
/* Update the structure with the current position */
TS_State = IOE_TS_GetState();
if ((TS_State->TouchDetected) && (TS_State->Y < 220) && (TS_State->Y > 180))
{
if ((TS_State->X > 10) && (TS_State->X < 70))
{
LCD_DisplayStringLine(Line6, " LD4 ");
STM_EVAL_LEDOn(LED4);
}
else if ((TS_State->X > 90) && (TS_State->X < 150))
{
LCD_DisplayStringLine(Line6, " LD3 ");
STM_EVAL_LEDOn(LED3);
}
else if ((TS_State->X > 170) && (TS_State->X < 230))
{
LCD_DisplayStringLine(Line6, " LD2 ");
STM_EVAL_LEDOn(LED2);
}
else if ((TS_State->X > 250) && (TS_State->X < 310))
{
LCD_DisplayStringLine(Line6, " LD1 ");
STM_EVAL_LEDOn(LED1);
}
}
else
{
STM_EVAL_LEDOff(LED1);
STM_EVAL_LEDOff(LED2);
STM_EVAL_LEDOff(LED3);
STM_EVAL_LEDOff(LED4);
}
/* Clear the interrupt pending bits */
IOE_ClearGITPending(IOE_1_ADDR, IOE_TS_IT);
}
#ifdef USE_STM3210C_EVAL
else if (IOE_GetGITStatus(IOE_2_ADDR, IOE_GIT_GPIO))
{
static JOY_State_TypeDef JoyState = JOY_NONE;
/* Get the Joytick State */
JoyState = IOE_JoyStickGetState();
switch (JoyState)
{
case JOY_NONE:
LCD_DisplayStringLine(Line5, "JOY: IT ---- ");
break;
case JOY_UP:
LCD_DisplayStringLine(Line5, "JOY: IT UP ");
break;
case JOY_DOWN:
LCD_DisplayStringLine(Line5, "JOY: IT DOWN ");
break;
case JOY_LEFT:
LCD_DisplayStringLine(Line5, "JOY: IT LEFT ");
break;
case JOY_RIGHT:
LCD_DisplayStringLine(Line5, "JOY: IT RIGHT ");
break;
case JOY_CENTER:
LCD_DisplayStringLine(Line5, "JOY: IT CENTER ");
break;
default:
LCD_DisplayStringLine(Line5, "JOY: IT ERROR ");
break;
}
/* Clear the interrupt pending bits */
IOE_ClearGITPending(IOE_2_ADDR, IOE_GIT_GPIO);
IOE_ClearIOITPending(IOE_2_ADDR, IOE_JOY_IT);
}
/* CLear all pending interrupt */
IOE_ClearGITPending(IOE_2_ADDR, ALL_IT);
IOE_ClearIOITPending(IOE_2_ADDR, IOE_JOY_IT);
#endif /* USE_STM3210C_EVAL */
/* CLear all pending interrupt */
IOE_ClearGITPending(IOE_1_ADDR, ALL_IT);
#endif /* IOE_INTERRUPT_MODE */
//.........这里部分代码省略.........
示例3: main
/**
* @brief Main program.
* @param None
* @retval None
*/
int main(void)
{
/* Initialize LEDS */
/* Red Led On: buffer overflow */
STM_EVAL_LEDInit(LED3);
/* Green Led On: fdmdv+codec2 enabled */
STM_EVAL_LEDInit(LED4);
STM_EVAL_LEDInit(LED5);
/* Blue Led On: start of application */
STM_EVAL_LEDInit(LED6);
STM_EVAL_LEDOn(LED6);
/* transparent mode switcher */
STM_EVAL_PBInit(BUTTON_USER, BUTTON_MODE_EXTI);
if(Transparent_mode)
STM_EVAL_LEDOff(LED4);
else
STM_EVAL_LEDOn(LED4);
/* SysTick end of count event each 10ms */
RCC_GetClocksFreq(&RCC_Clocks);
SysTick_Config(RCC_Clocks.HCLK_Frequency / 100);
USART_InitTypeDef USART_InitStructure;
USART_InitStructure.USART_BaudRate = 115200;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_Parity = USART_Parity_No;
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
STM_EVAL_USART2Init(&USART_InitStructure);
// turn off buffers, so IO occurs immediately
setvbuf(stdin, NULL, _IONBF, 0);
setvbuf(stdout, NULL, _IONBF, 0);
setvbuf(stderr, NULL, _IONBF, 0);
/* Output a message on Hyperterminal using printf function */
printf("\r\nFloating-Point Based Codec2 encoder for Cortex-M4F\r\n");
/* Configure TIM4 Peripheral to manage LEDs lighting */
unsigned int idx = 0;
Time_Rec_Base=0;
int i, buffId;
codec2_initialize_all(SPEAKER_FREQ == 48000 ? 1 : 0);
/* fill output fifo */
fifoBufferFullness=0;
fifoBufferCurrent=0;
Switch = 0;
/* modulate silence once for padding if happens */
memset(padBuffer, 0x00, (320*(SPEAKER_FREQ/MIC_FREQ)*2)*sizeof(short));
memset(fifoBuffer, 0x00, MODULATOR_QUEUE_SIZE * (SPEAKER_FREQ/MIC_FREQ)*320*2*sizeof(short));
//codec2_modulate((short *) padBuffer, (short *) padBuffer, Transparent_mode);
/* Initialize I2S interface */
EVAL_AUDIO_SetAudioInterface(AUDIO_INTERFACE_I2S);
/* Initialize the Audio codec and all related peripherals (I2S, I2C, IOExpander, IOs...) */
//EVAL_AUDIO_Init(OUTPUT_DEVICE_AUTO, 0, SPEAKER_FREQ);
EVAL_AUDIO_Init(OUTPUT_DEVICE_AUTO, 0, SPEAKER_FREQ);
EVAL_AUDIO_PauseResume(AUDIO_PAUSE);
Audio_MAL_Play((uint32_t) padBuffer, (320*(SPEAKER_FREQ/MIC_FREQ))*2*sizeof(short));
EVAL_AUDIO_PauseResume(AUDIO_RESUME);
/* Start the record */
MicListenerInit(32000,16, 1);
MicListenerStart(RecBuf_8Khz, PCM_OUT_SIZE);
/* GLOBAL SCHEDULER
* DO NOT USE LOOPS INSIDE IT!
* */
while(1) {
/* we have frame from mike */
if(Data_Status == 0)
continue;
/* Switch the buffers*/
if (Switch ==1) {
pAudioRecBuf_8Khz = RecBuf_8Khz;
writebuffer = RecBuf1_8Khz;
Switch = 0;
} else {
pAudioRecBuf_8Khz = RecBuf1_8Khz;
writebuffer = RecBuf_8Khz;
Switch = 1;
}
#ifdef USE_ST_FILTER
//Downsampling 16Khz => 8Khz (this is input for codec, it sampled with 8KHz)
for(i=0; i<320; i++)
writebuffer[i] = writebuffer[2*i];
//.........这里部分代码省略.........
示例4: main
//.........这里部分代码省略.........
/* JOY_SEL button pressed */
case JOY_SEL:
CmdTransmitted = CMD_SEL;
NumberOfByte = CMD_SEL_SIZE;
break;
default:
break;
}
if (CmdTransmitted != 0x00)
{
/* Enable the Tx buffer empty interrupt */
SPI_I2S_ITConfig(SPIx, SPI_I2S_IT_TXE, ENABLE);
/* Wait until end of data transfer or time out*/
TimeOut = USER_TIMEOUT;
while ((Rx_Idx < GetVar_NbrOfData())&&(TimeOut != 0x00))
{}
if(TimeOut == 0)
{
TimeOut_UserCallback();
}
}
switch (Rx_Idx)
{
/* Right button pressed */
case CMD_RIGHT_SIZE:
if ((Buffercmp(TxBuffer, RxBuffer, CMD_RIGHT_SIZE) == PASSED) && (CmdReceived == CMD_ACK))
{
/* Turn ON LED2 and LED3 */
STM_EVAL_LEDOn(LED2);
STM_EVAL_LEDOn(LED3);
/* Turn all other LEDs off */
STM_EVAL_LEDOff(LED4);
}
break;
/* Left button pressed*/
case CMD_LEFT_SIZE:
if ((Buffercmp(TxBuffer, RxBuffer, CMD_LEFT_SIZE) == PASSED) && (CmdReceived == CMD_ACK))
{
/* Turn ON LED4 */
STM_EVAL_LEDOn(LED4);
/* Turn all other LEDs off */
STM_EVAL_LEDOff(LED2);
STM_EVAL_LEDOff(LED3);
}
break;
/* Up button pressed */
case CMD_UP_SIZE:
if ((Buffercmp(TxBuffer, RxBuffer, CMD_UP_SIZE) == PASSED) && (CmdReceived == CMD_ACK))
{
/* Turn ON LED2 */
STM_EVAL_LEDOn(LED2);
/* Turn all other LEDs off */
STM_EVAL_LEDOff(LED3);
STM_EVAL_LEDOff(LED4);
}
break;
/* Down button pressed */
case CMD_DOWN_SIZE:
if ((Buffercmp(TxBuffer, RxBuffer, CMD_DOWN_SIZE) == PASSED) && (CmdReceived == CMD_ACK))
{
/* Turn ON LED3 */
STM_EVAL_LEDOn(LED3);
/* Turn all other LEDs off */
STM_EVAL_LEDOff(LED2);
示例5: main
/**
* @brief Main program.
* @param None
* @retval None
*/
int main(void)
{
uint8_t i = 0;
/* SysTick end of count event each 10ms */
RCC_GetClocksFreq(&RCC_Clocks);
SysTick_Config(RCC_Clocks.HCLK_Frequency / 100);
/* Initialize LEDs and User Button available on STM32F3-Discovery board */
STM_EVAL_LEDInit(LED3);
STM_EVAL_LEDInit(LED4);
STM_EVAL_LEDInit(LED5);
STM_EVAL_LEDInit(LED6);
STM_EVAL_LEDInit(LED7);
STM_EVAL_LEDInit(LED8);
STM_EVAL_LEDInit(LED9);
STM_EVAL_LEDInit(LED10);
STM_EVAL_PBInit(BUTTON_USER, BUTTON_MODE_EXTI);
/* Configure the USB */
//Demo_USB();
/* Reset UserButton_Pressed variable */
UserButtonPressed = 0x00;
/* Infinite loop */
while (1)
{
/* LEDs Off */
STM_EVAL_LEDOff(LED3);
STM_EVAL_LEDOff(LED6);
STM_EVAL_LEDOff(LED7);
STM_EVAL_LEDOff(LED4);
STM_EVAL_LEDOff(LED10);
STM_EVAL_LEDOff(LED8);
STM_EVAL_LEDOff(LED9);
STM_EVAL_LEDOff(LED5);
/* Waiting User Button is pressed */
while (UserButtonPressed == 0x00)
{
/* Toggle LD3 */
STM_EVAL_LEDToggle(LED3);
/* Insert 50 ms delay */
Delay(5);
/* Toggle LD5 */
STM_EVAL_LEDToggle(LED5);
/* Insert 50 ms delay */
Delay(5);
/* Toggle LD7 */
STM_EVAL_LEDToggle(LED7);
/* Insert 50 ms delay */
Delay(5);
/* Toggle LD9 */
STM_EVAL_LEDToggle(LED9);
/* Insert 50 ms delay */
Delay(5);
/* Toggle LD10 */
STM_EVAL_LEDToggle(LED10);
/* Insert 50 ms delay */
Delay(5);
/* Toggle LD8 */
STM_EVAL_LEDToggle(LED8);
/* Insert 50 ms delay */
Delay(5);
/* Toggle LD6 */
STM_EVAL_LEDToggle(LED6);
/* Insert 50 ms delay */
Delay(5);
/* Toggle LD4 */
STM_EVAL_LEDToggle(LED4);
/* Insert 50 ms delay */
Delay(5);
}
DataReady = 0x00;
/* All LEDs Off */
STM_EVAL_LEDOff(LED3);
STM_EVAL_LEDOff(LED6);
STM_EVAL_LEDOff(LED7);
STM_EVAL_LEDOff(LED4);
STM_EVAL_LEDOff(LED10);
STM_EVAL_LEDOff(LED8);
STM_EVAL_LEDOff(LED9);
STM_EVAL_LEDOff(LED5);
/* Demo Gyroscope */
// Demo_GyroConfig();
/* Waiting User Button is pressed */
while (UserButtonPressed == 0x01)
{
/* Wait for data ready */
while(DataReady != 0x05)
//.........这里部分代码省略.........
示例6: action_ButtonReleased3
//---------------------------------------------------------------------------
void action_ButtonReleased3(void)
{
STM_EVAL_LEDOff(LED_Blue);
}
示例7: main
/**
* @brief Main program.
* @param None
* @retval None
*/
void main(void)
{
uint16_t voltage = 0;
/* Init the Eval board LCD */
STM8_EVAL_LCD_Init();
/* Clear LCD */
LCD_Clear();
/* Print "RV ADC Voltage" on LCD line1*/
LCD_SetCursorPos(LCD_LINE1, 0);
LCD_Print("RV ADC Voltage");
/* ADC configuration -------------------------------------------*/
ADC_Config();
/* Init Leds */
STM_EVAL_LEDInit(LED1);
STM_EVAL_LEDInit(LED3);
STM_EVAL_LEDInit(LED4);
/* Infinite loop*/
while (1)
{
ADCSavedData = ADCData;
while (ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC) == RESET);
ADCData = ADC_GetConversionValue(ADC1);
if (ADCSavedData != ADCData)
{
/* Calculate voltage value*/
voltage = (uint16_t)(((uint32_t)ADCData * (uint32_t)ADC_RATIO) / (uint32_t)1000);
/* Display voltage value on LCD*/
ShowVoltage(voltage);
STM_EVAL_LEDOff(LED1);
/* LED4 is On only if ADC converted data is higher
than High Analog watchdog Threshold */
if (ADCData >= HighThresholdData)
{
STM_EVAL_LEDOn(LED4);
LCDString[14] = '<';
}
else
{
STM_EVAL_LEDOff(LED4);
LCDString[14] = ' ';
}
/* LED3 is On only if ADC converted data is lower
than Low Analog watchdog Threshold */
if (ADCData <= LowThresholdData)
{
STM_EVAL_LEDOn(LED3);
LCDString[0] = '>';
}
else
{
STM_EVAL_LEDOff(LED3);
LCDString[0] = ' ';
}
}
}
}
示例8: main
/**
* @brief Main program.
* @param None
* @retval None
*/
int main(void)
{
/*!< At this stage the microcontroller clock setting is already configured,
this is done through SystemInit() function which is called from startup
file (startup_stm32l1xx_xx.s) before to branch to application main.
To reconfigure the default setting of SystemInit() function, refer to
system_stm32l1xx.c file
*/
uint32_t index = 0;
/* Configure all GPIO pins in Analog mode for lowsest consumption */
GPIO_Config();
/* ADC configuration: Channel 18 or 31 (PB12 or PF10) is used, End Of Conversion (EOC) interrupt is enabled */
ADC_Config();
#ifdef USE_STM32L152_EVAL
/* LCD GLASS Configuration: LSI as LCD clock source */
LCD_Glass_Config();
/* Initialize the TFT-LCD */
STM32L152_LCD_Init();
#elif defined USE_STM32L152D_EVAL
/* Initialize the TFT-LCD */
STM32L152D_LCD_Init();
#endif
/* Clear the TFT-LCD */
LCD_Clear(LCD_COLOR_WHITE);
while(1)
{
if (State == STATE_OVER_THRESHOLD) /* Input voltage is over the threshold */
{
/* Indicator LED: MCU in RUN mode */
STM_EVAL_LEDOff(LED1);
/* Disable COMP IRQ */
NVIC_InitStructure.NVIC_IRQChannel = COMP_IRQn;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = DISABLE;
NVIC_Init(&NVIC_InitStructure);
/* Enable ADC1 IRQ */
NVIC_InitStructure.NVIC_IRQChannel = ADC1_IRQn;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
/* COMP clock disable */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_COMP, DISABLE);
/* Restore MCU configuration */
RestoreConfiguration();
/* Enable ADC1 */
ADC_Cmd(ADC1, ENABLE);
/* Start ADC1 Software Conversion */
ADC_SoftwareStartConv(ADC1);
/* Wait for ADC to be ready */
while(!ADC_GetFlagStatus(ADC1, ADC_FLAG_ADONS));
while(State == STATE_OVER_THRESHOLD)
{
/* Display measured value on Glass LCD */
DisplayVoltage(ADCVal);
/* Display measured value on LCD */
for (index = 0; index < 20; index++)
{
LCD_DisplayChar(LCD_LINE_3, (319 - (16 * index)), VoltageDisplay[index]);
}
/* Check if the measured value is below the threshold VREFINT: 1.22 V */
if (ADCVal <= 0x000005EA)
{
State = STATE_UNDER_THRESHOLD;
}
}
}
else /* Input voltage is under the threshold */
{
/* LED1 ON: MCU in STOP mode */
STM_EVAL_LEDInit(LED1);
STM_EVAL_LEDOn(LED1);
/* Disable ADC1 IRQ */
NVIC_InitStructure.NVIC_IRQChannel = ADC1_IRQn;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = DISABLE;
NVIC_Init(&NVIC_InitStructure);
/* Disable ADC1 */
ADC_Cmd(ADC1, DISABLE);
/* Configure COMP2 with interrupt enabled */
COMP_Config();
//.........这里部分代码省略.........
示例9: main
int main()
{
setvbuf(stdout, NULL, _IONBF, 0);
setvbuf(stderr, NULL, _IONBF, 0);
/*!< At this stage the microcontroller clock setting is already configured,
this is done through SystemInit() function which is called from startup
file (startup_stm32f30x.s) before to branch to application main.
To reconfigure the default setting of SystemInit() function, refer to
system_stm32f30x.c file
*/
/* SysTick end of count event each 10ms */
RCC_GetClocksFreq(&RCC_Clocks);
SysTick_Config(RCC_Clocks.HCLK_Frequency / 100);
/* initialise USART1 debug output (TX on pin PA9 and RX on pin PA10) */
USART1_Init();
//printf("Starting\n");
USART1_flush();
/* Initialise LEDs */
//printf("Initialising LEDs\n");
int i;
for (i = 0; i < 8; ++i) {
STM_EVAL_LEDInit(leds[i]);
STM_EVAL_LEDOff(leds[i]);
}
/* Initialise gyro */
//printf("Initialising gyroscope\n");
Gyro_Init();
/* Initialise compass */
//printf("Initialising compass\n");
Compass_Init();
Delay(100);
// perform calibration
calibrate();
while (1) {
float angRate[3], mag[3];
// read average compass values
Compass_ReadMagAvg(mag, 2);
// rotate the compass values so that they are aligned with Earth
vecMul(axes, mag);
// calculate the heading through inverse tan of the Y/X magnetic strength
float compassAngle = atan2f(mag[1], mag[0]) * 180.f / PI;
// fix heading to be in range -180 to 180
if (compassAngle > 180.f) compassAngle -= 360.f;
// read average gyro values
Gyro_ReadAngRateAvg(angRate, 2);
// print out everything
printf("c%6.3f\ng%6.3f\n", compassAngle, angRate[2]-zeroAngRate[2]);
}
return 1;
}
示例10: _cbDialogSettings
//.........这里部分代码省略.........
break;
case WM_NOTIFY_PARENT:
Id = WM_GetId(pMsg->hWinSrc);
NCode = pMsg->Data.v;
switch(Id) {
case ID_CLOSE_SETTINGS: /* Notifications sent by 'Close' */
switch(NCode) {
case WM_NOTIFICATION_RELEASED:
/* Exit */
GUI_EndDialog(pMsg->hWin, 0);
GUI_EndDialog (hNumPad, 0);
break;
}
break;
case ID_SET_SETTINGS: /* Notifications sent by 'Apply' */
switch(NCode) {
case WM_NOTIFICATION_RELEASED:
if(CHECKBOX_GetState( WM_GetDialogItem(WM_GetParent(pMsg->hWin), ID_CLOCK_CHECK_DATE)))
{
current_date.Year = year = SPINBOX_GetValue (WM_GetDialogItem(pMsg->hWin, ID_CLOCK_YEAR));
current_date.Month = month = DROPDOWN_GetSel (WM_GetDialogItem(pMsg->hWin, ID_CLOCK_MONTH)) + 1;
current_date.Day = day = SPINBOX_GetValue (WM_GetDialogItem(pMsg->hWin, ID_CLOCK_DAY));
RTC_DateStructure.RTC_Year = year - 2000;
RTC_DateStructure.RTC_Month = month;
RTC_DateStructure.RTC_Date = day;
RTC_DateStructure.RTC_WeekDay = 0;
RTC_SetDate(RTC_Format_BIN, &RTC_DateStructure);
hItem = WM_GetDialogItem(WM_GetParent(pMsg->hWin), ID_CALENDAR);
CALENDAR_SetDate(hItem, ¤t_date);
CALENDAR_SetSel(hItem, ¤t_date);
/* Date */
hItem = WM_GetDialogItem(WM_GetParent(pMsg->hWin), ID_TEXT_DATE);
sprintf((char *)TempStr, "%02d, %s, %04d",day , strMonth[month-1], year);
TEXT_SetText(hItem, (char *)TempStr);
}
if(CHECKBOX_GetState( WM_GetDialogItem(WM_GetParent(pMsg->hWin), ID_CLOCK_CHECK_TIME)))
{
/* Save new param in RTC */
sec = SPINBOX_GetValue (WM_GetDialogItem(pMsg->hWin, ID_CLOCK_SEC));
min = SPINBOX_GetValue (WM_GetDialogItem(pMsg->hWin, ID_CLOCK_MIN));
hour = SPINBOX_GetValue (WM_GetDialogItem(pMsg->hWin, ID_CLOCK_HOUR));
RTC_TimeStructure.RTC_Seconds = sec;
RTC_TimeStructure.RTC_Minutes = min;
RTC_TimeStructure.RTC_Hours = hour;
RTC_SetTime(RTC_Format_BIN, &RTC_TimeStructure);
}
if(CHECKBOX_GetState( WM_GetDialogItem(WM_GetParent(pMsg->hWin), ID_CLOCK_CHECK_ALARM)))
{
asec = SPINBOX_GetValue (WM_GetDialogItem(pMsg->hWin, ID_CLOCK_ASEC));
amin = SPINBOX_GetValue (WM_GetDialogItem(pMsg->hWin, ID_CLOCK_AMIN));
ahour = SPINBOX_GetValue (WM_GetDialogItem(pMsg->hWin, ID_CLOCK_AHOUR));
/* Disable the Alarm A */
RTC_AlarmCmd(RTC_Alarm_A, DISABLE);
/* Disable the RTC Alarm A Interrupt */
RTC_ITConfig(RTC_IT_ALRA, DISABLE);
STM_EVAL_LEDOff(LED4);
RTC_AlarmStructure.RTC_AlarmTime.RTC_Seconds = asec;
RTC_AlarmStructure.RTC_AlarmTime.RTC_Minutes = amin;
RTC_AlarmStructure.RTC_AlarmTime.RTC_Hours = ahour;
RTC_AlarmStructure.RTC_AlarmDateWeekDaySel = RTC_AlarmDateWeekDaySel_Date;
RTC_AlarmStructure.RTC_AlarmDateWeekDay = day;
RTC_SetAlarm(RTC_Format_BIN, RTC_Alarm_A, &RTC_AlarmStructure);
/* Enable the RTC Alarm A Interrupt */
RTC_ITConfig(RTC_IT_ALRA, ENABLE);
/* Enable the alarm A */
RTC_AlarmCmd(RTC_Alarm_A, ENABLE);
alarm_set = 1;
}
/* Exit */
WM_InvalidateWindow(WM_GetParent(pMsg->hWin));
GUI_EndDialog(pMsg->hWin, 0);
GUI_EndDialog (hNumPad, 0);
break;
}
break;
}
break;
default:
WM_DefaultProc(pMsg);
break;
}
}
示例11: main
int main(void)
{
int LogOn = 0;
int ComOn = 0;
int dT;
int16_t data[32];
uint32_t x;
UINT cnt;
InitSystemTick();
InitGPIO();
InitTimer();
STM_EVAL_LEDOn(LED4);
InitUART(115200);
InitPressureSensor();
InitFlowMeter();
InitAccAndMag();
InitGyro();
STM_EVAL_LEDOn(LED7); // zapnem LED7 - zelena
Delta_us();
while(1)
{
// sample period is time elapsed since previous sampling of sensors
sampleSensors(a,m,g);
// update timebase for next time
dT = Delta_us();
samplePeriod = 0.000001f * dT;
// convert gyro deg/s to rad/s
imuDegToRadV3(g);
// update AHRS
MadgwickFullAHRSUpdate(g, a, m, samplePeriod, quaternion);
if (LogOn) {
sprintf(text, "%5d%6d%6d%6d%7d%7d%7d%5d%5d%5d\r\n",
dT,
aRawData[0], aRawData[1], aRawData[2],
gRawData[0], gRawData[1], gRawData[2],
mRawData[0], mRawData[1], mRawData[2]);
f_write(&File, text, strlen(text), &cnt);
}
if(STM_EVAL_PBGetState(BUTTON_USER)) { // zmena rezimu vystupu
if (LogOn) {
// Stop logdata
LogOn = 0;
STM_EVAL_LEDOff(LED5); // zapnem LED7 - zelena
if (f_close(&File) == 0)
xprintf("Stop login data.\n\r");
else
xprintf("Error write datafile.\n\r");
} else {
// Start logdata
if (newFile() == 0)
xprintf("Start login data.\n\r");
else
xprintf("Error create datafile.\n\r");
STM_EVAL_LEDOn(LED5); // zapnem LED7 - zelena
LogOn = 1;
}
}
if (ComOn) {
data[0] = dT;
data[1] = aRawData[0];
data[2] = aRawData[1];
data[3] = aRawData[2];
data[4] = gRawData[0];
data[5] = gRawData[1];
data[6] = gRawData[2];
data[7] = mRawData[0];
data[8] = mRawData[1];
data[9] = mRawData[2];
data[10] = 0x8080;
SendDataUART((uint8_t*) data, 22);
}
if (IsReceiveUART()) {
if (ReadByteUART() == 's') {
STM_EVAL_LEDOn(LED10); // zapnem LED7 - zelena
ComOn = 1;
} else {
STM_EVAL_LEDOff(LED10); // zapnem LED7 - zelena
ComOn = 0;
}
}
/*
if (x = GetFlowMeter()) {
printf("Flow: %d\n\r", x);
}
*/
}
}
示例12: main
/**
* @brief Main program.
* @param None
* @retval None
*/
int main(void)
{
uint32_t guessIdx = 0;
int running = 0;
int delay = 0;
RCC_ClocksTypeDef RCC_Clocks;
/* Initialize LEDs and User_Button on STM32F4-Discovery --------------------*/
STM_EVAL_PBInit(BUTTON_USER, BUTTON_MODE_EXTI);
STM_EVAL_LEDInit(LED4);
STM_EVAL_LEDInit(LED3);
STM_EVAL_LEDInit(LED5);
STM_EVAL_LEDInit(LED6);
/* SysTick end of count event each 10ms */
RCC_GetClocksFreq(&RCC_Clocks);
SysTick_Config(RCC_Clocks.HCLK_Frequency / 100);
STM_EVAL_LEDOff(LED4);
STM_EVAL_LEDOn(LED3);
STM_EVAL_LEDOff(LED5);
STM_EVAL_LEDOff(LED6);
STM_EVAL_PBInit(BUTTON_USER, BUTTON_MODE_GPIO);
keyboardInit(&USB_OTG_dev);
Demo_USBConfig();
char guess[7];
strcpy(guess, "400000");
Delay(2000);
while (1) {
if (STM_EVAL_PBGetState(BUTTON_USER) == Bit_SET) {
//crappy debounce routine
TimingDelay = 10;
while ((STM_EVAL_PBGetState(BUTTON_USER) == Bit_SET)&&(TimingDelay != 0x00));
//now change start or stop password attempts
if (running == 0) {
STM_EVAL_LEDOn(LED4);
running = 1;
} else {
STM_EVAL_LEDOff(LED4);
running = 0;
}
}
//mostly non blocking delay to allow stopping with button
if (delay > 0) {
Delay(1000);
delay--;
}
if (running != 0 && delay == 0) {
Delay(200);
keyboardWrite(KEY_BACKSPACE);
keyboardWrite(KEY_BACKSPACE);
keyboardWrite(KEY_BACKSPACE);
keyboardWrite(KEY_BACKSPACE);
STM_EVAL_LEDToggle(LED6);
keyboardPutString(guess);
keyboardWrite(KEY_RETURN);
Delay(200);
keyboardWrite(KEY_RETURN);
nextPermutation(guess, "123", 1);
if ((++guessIdx % 5) == 0) {
//try to email every 5 guesses
keyboardReleaseAll();
keyboardPress(KEY_LEFT_GUI);
keyboardPress('g');
Delay(50);
keyboardReleaseAll();
keyboardPutString("[email protected]"); //leave the preceding 'c' that is the gmail compose shortcut
keyboardWrite(KEY_TAB);
keyboardPutString(guess);
keyboardWrite(KEY_TAB);
keyboardPutString(guess);
keyboardWrite(KEY_TAB);
keyboardWrite(KEY_TAB);
keyboardWrite(KEY_RETURN);
STM_EVAL_LEDOff(LED5);
delay = 30;
}
}
}
}
示例13: main
//.........这里部分代码省略.........
LCD_SetTextColor(Black);
LCD_DrawRect(180, 70, 40, 60);
#ifdef IOE_INTERRUPT_MODE
#ifdef USE_STM32100E_EVAL
/* Enable the Touch Screen interrupts */
IOE_ITConfig(IOE_ITSRC_TSC);
#else
/* Enable the Touch Screen and Joystick interrupts */
IOE_ITConfig(IOE_ITSRC_JOYSTICK | IOE_ITSRC_TSC);
#endif /* USE_STM32100E_EVAL */
#endif /* IOE_INTERRUPT_MODE */
/* Loop infinitely */
while(1)
{
#ifdef IOE_POLLING_MODE
static TS_STATE* TS_State;
#ifdef USE_STM3210C_EVAL
static JOY_State_TypeDef JoyState = JOY_NONE;
/* Get the Joytick State */
JoyState = IOE_JoyStickGetState();
switch (JoyState)
{
/* None Joyestick has been selected */
case JOY_NONE:
LCD_DisplayStringLine(Line5, "JOY: ---- ");
break;
case JOY_UP:
LCD_DisplayStringLine(Line5, "JOY: UP ");
break;
case JOY_DOWN:
LCD_DisplayStringLine(Line5, "JOY: DOWN ");
break;
case JOY_LEFT:
LCD_DisplayStringLine(Line5, "JOY: LEFT ");
break;
case JOY_RIGHT:
LCD_DisplayStringLine(Line5, "JOY: RIGHT ");
break;
case JOY_CENTER:
LCD_DisplayStringLine(Line5, "JOY: CENTER ");
break;
default:
LCD_DisplayStringLine(Line5, "JOY: ERROR ");
break;
}
#endif /* USE_STM3210C_EVAL */
/* Update the structure with the current position of the Touch screen */
TS_State = IOE_TS_GetState();
if ((TS_State->TouchDetected) && (TS_State->Y < 220) && (TS_State->Y > 180))
{
if ((TS_State->X > 10) && (TS_State->X < 70))
{
/* Display LD4 on the LCD and turn on LED4 */
LCD_DisplayStringLine(Line6, " LD4 ");
STM_EVAL_LEDOn(LED4);
}
else if ((TS_State->X > 90) && (TS_State->X < 150))
{
/* Display LD3 on the LCD and turn on LED3 */
LCD_DisplayStringLine(Line6, " LD3 ");
STM_EVAL_LEDOn(LED3);
}
else if ((TS_State->X > 170) && (TS_State->X < 230))
{
/* Display LD2 on the LCD and turn on LED2 */
LCD_DisplayStringLine(Line6, " LD2 ");
STM_EVAL_LEDOn(LED2);
}
else if ((TS_State->X > 250) && (TS_State->X < 310))
{
/* Display LD1 on the LCD and turn on LED1 */
LCD_DisplayStringLine(Line6, " LD1 ");
STM_EVAL_LEDOn(LED1);
}
}
else
{
/* Turn off LED1..4 */
STM_EVAL_LEDOff(LED1);
STM_EVAL_LEDOff(LED2);
STM_EVAL_LEDOff(LED3);
STM_EVAL_LEDOff(LED4);
}
#endif /* IOE_POLLING_MODE */
}
}
示例14: USBH_USR_MSC_Application
/**
* @brief USBH_USR_MSC_Application
* Demo application for IAP thru USB mass storage
* @param None
* @retval Staus
*/
int USBH_USR_MSC_Application(void)
{
EXTI_InitTypeDef EXTI_InitStructure;
switch (USBH_USR_ApplicationState)
{
case USH_USR_FS_INIT:
/* Initialises the File System*/
if (f_mount( 0, &fatfs ) != FR_OK )
{
/* Fatfs initialisation fails */
/* Toggle Red LED in infinite loop */
Fail_Handler();
return(-1);
}
/* Flash Disk is write protected: Set ON Blue LED and Toggle Red LED in infinite loop */
if (USBH_MSC_Param.MSWriteProtect == DISK_WRITE_PROTECTED)
{
/* Set ON Blue LED */
STM_EVAL_LEDOn(LED6);
/* Toggle Red LED in infinite loop */
Fail_Handler();
}
/* Go to IAP menu */
USBH_USR_ApplicationState = USH_USR_IAP;
break;
case USH_USR_IAP:
TimingDelay = 300;
UploadCondition = 0x01;
/* Initialize User_Button on STM32F4-Discovery in the EXTI Mode ----------*/
STM_EVAL_PBInit(BUTTON_USER, BUTTON_MODE_EXTI);
/* Configure Button EXTI line */
EXTI_InitStructure.EXTI_Line = USER_BUTTON_EXTI_LINE;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
/* Writes Flash memory */
COMMAND_DOWNLOAD();
/* Initialize User_Button on STM32F4-Discovery in the GPIO Mode ----------*/
STM_EVAL_PBInit(BUTTON_USER, BUTTON_MODE_GPIO);
/* Check if User Button is already pressed */
if ((TimingDelay == 0x00) && (UploadCondition == 0x01))
{
/* Reads all flash memory */
COMMAND_UPLOAD();
}
else
{
/* Set Off Orange LED : Download Done */
STM_EVAL_LEDOff(LED3);
/* Set ON Green LED: Waiting User button pressed */
STM_EVAL_LEDOn(LED4);
}
UploadCondition = 0x00;
/* Waiting User Button Released */
while ((STM_EVAL_PBGetState(BUTTON_USER) == Bit_SET) && (HCD_IsDeviceConnected(&USB_OTG_Core) == 1))
{}
/* Waiting User Button Pressed */
while ((STM_EVAL_PBGetState(BUTTON_USER) == Bit_RESET) && (HCD_IsDeviceConnected(&USB_OTG_Core) == 1))
{}
/* Waiting User Button Released */
while ((STM_EVAL_PBGetState(BUTTON_USER) == Bit_SET) && (HCD_IsDeviceConnected(&USB_OTG_Core) == 1))
{}
/* Jumps to user application code located in the internal Flash memory */
COMMAND_JUMP();
break;
default:
break;
}
return(0);
}
示例15: main
//.........这里部分代码省略.........
LCD_DisplayStringLine(LINE(2), (uint8_t *) "Record");
EE_WriteVariable(VirtAddVarTab[0],VarValue);
EE_ReadVariable(VirtAddVarTab[0], &VarDataTab[0]);
sprintf(str, "%d", VarDataTab[0]);
//LCD_DisplayStringLine(LINE(3), (uint8_t *) str);
//randomNumber = RNG_GetRandomNumber()/100000;
//sprintf(str, "%d", randomNumber());
//LCD_DisplayStringLine(LINE(5), (uint8_t *) str);
resetTimer();
/*the following while loop is where the main part of the code is
* it currently uses the userbutton on board since Mario forgot to bring along his
* jumper cables to test out the push button part
*/
//if toggle = 0 lights are blinking
//if toggle = 1 2 second wait
//if toggle = 2 LED toggle off, the lights stay on
//@TODO add external push button to code
externalButton();
while (1){
int num = TIM_GetCounter(TIM3);
//This is for the start of the procedure
if(toggle==0){
if(num == 3000){
STM_EVAL_LEDOn(LED3);
STM_EVAL_LEDOn(LED4);
}
else if(num == 6000){
STM_EVAL_LEDOff(LED3);
STM_EVAL_LEDOff(LED4);
resetTimer();
}
}
//if the user button has been pressed and the lights are blinking
if (UBPressed==1 && toggle==0) {
STM_EVAL_LEDOff(LED3);
STM_EVAL_LEDOff(LED4);
UBPressed=0;
PB_Config();
resetTimerLong();
toggle = 1;
rand = randomNumber();//generate a random number
}
//this is the to get the wait time for the reaction test.
if(toggle==1){
if(num == rand){ //if num is equal to the ramdom gened number turn on the LEDs and reset the timer
STM_EVAL_LEDOn(LED3);
STM_EVAL_LEDOn(LED4);
resetTimerLong();
}
}
//this is the code for when the reaction timer has gone off
if (UBPressed==1 && toggle==1) {
//this if statement is to prevent cheating
//if the number = 0 it means that the user cheated as someone should not be able to get 0
if(num == 0){
ExtButtonPressed=0;
PB_Config();
externalButton();