本文整理汇总了C++中TM_DELAY_Init函数的典型用法代码示例。如果您正苦于以下问题:C++ TM_DELAY_Init函数的具体用法?C++ TM_DELAY_Init怎么用?C++ TM_DELAY_Init使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TM_DELAY_Init函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(void) {
/* RCC clocks typedef */
RCC_ClocksTypeDef RCC_Clocks;
/* RCC PLL structure */
TM_RCC_PLL_t PLL;
/* Initialize system */
SystemInit();
/* Initialize delay, systick has interrupts every 1ms by default */
TM_DELAY_Init();
/* Init USART2, TX: PA2, RX: PA3, 921600 baud */
TM_USART_Init(USART2, TM_USART_PinsPack_1, 921600);
/* Get current system clock */
RCC_GetClocksFreq(&RCC_Clocks);
/* Print current system clock */
printf("System core clock: %d\n", RCC_Clocks.SYSCLK_Frequency);
/* Read PLL settings */
TM_RCC_GetPLL(&PLL);
/* Set PLL N to some random value */
PLL.PLLN = 200;
/* Change PLL settings */
TM_RCC_SetPLL(&PLL);
/* Send something over USART */
printf("This will not be seen correct on USART\n");
/* Reinit everything with new clock */
/* You have to reinit everything what depends on system CLOCK */
/* Like timer prescalers, usarts, i2c, etc */
/* Set new systick preload value */
TM_DELAY_Init();
/* Set new prescalers for USART settings */
TM_USART_Init(USART2, TM_USART_PinsPack_1, 921600);
/* Get current system clock */
RCC_GetClocksFreq(&RCC_Clocks);
/* Print current system clock */
/* This will be seen on console with new settings */
printf("System core clock after PLL change: %d\n", RCC_Clocks.SYSCLK_Frequency);
while (1) {
}
}
示例2: Global_Init
void Global_Init(void)
{
// Initialize system
SystemInit();
// Initialize button and LEDs
init_GPIO();
// Initialize delay
TM_DELAY_Init();
// Init sounds
InitSounds();
// Initialize accelerometer
AccInit();
// Initialize USB, IO, SysTick, and all those other things you do in the morning
init();
//timerINit
Timer_Init();
}
示例3: TM_HCSR04_Init
uint8_t TM_HCSR04_Init(TM_HCSR04_t* HCSR04, GPIO_TypeDef* ECHO_GPIOx, uint16_t ECHO_GPIO_Pin, GPIO_TypeDef* TRIGGER_GPIOx, uint16_t TRIGGER_GPIO_Pin) {
/* Init Delay functions */
TM_DELAY_Init();
/* Save everything */
HCSR04->ECHO_GPIOx = ECHO_GPIOx;
HCSR04->ECHO_GPIO_Pin = ECHO_GPIO_Pin;
HCSR04->TRIGGER_GPIOx = TRIGGER_GPIOx;
HCSR04->TRIGGER_GPIO_Pin = TRIGGER_GPIO_Pin;
/* Initialize pins */
/* Trigger pin */
TM_GPIO_Init(HCSR04->TRIGGER_GPIOx, HCSR04->TRIGGER_GPIO_Pin, TM_GPIO_Mode_OUT, TM_GPIO_OType_PP, TM_GPIO_PuPd_DOWN, TM_GPIO_Speed_Medium);
/* Echo pin */
TM_GPIO_Init(HCSR04->ECHO_GPIOx, HCSR04->ECHO_GPIO_Pin, TM_GPIO_Mode_IN, TM_GPIO_OType_PP, TM_GPIO_PuPd_DOWN, TM_GPIO_Speed_Medium);
/* Trigger set to low */
TM_GPIO_SetPinLow(HCSR04->TRIGGER_GPIOx, HCSR04->TRIGGER_GPIO_Pin);
/* Start measurement, check if sensor is working */
if (TM_HCSR04_Read(HCSR04) >= 0) {
/* Sensor OK */
return 1;
}
/* Sensor error */
return 0;
}
示例4: main
int main(void) {
/* Initialize system */
SystemInit();
/* Initialize delay */
TM_DELAY_Init();
/* Initialize leds on board */
TM_DISCO_LedInit();
/* Initialize button */
TM_DISCO_ButtonInit();
/* Disable watchdog when we are in debug mode */
DBGMCU->APB1FZ |= DBGMCU_IWDG_STOP;
/* Initialize watchdog timer */
/* Set timeout to 1s */
/* If we are in debug mode, watchdog won't start even if we enable it */
if (TM_WATCHDOG_Init(TM_WATCHDOG_Timeout_1s)) {
/* System was reset by watchdog */
TM_DISCO_LedOn(LED_RED);
} else {
/* System was not reset by watchdog */
TM_DISCO_LedOn(LED_GREEN);
}
while (1) {
/* If button is pressed, do nothing and system will be reset after 1 second */
while (TM_DISCO_ButtonPressed());
/* Reset watchdog */
TM_WATCHDOG_Reset();
}
}
示例5: main
int main(void) {
/* Initialize system */
SystemInit();
/* Initialize delay */
TM_DELAY_Init();
/* Initialize onboard leds */
TM_DISCO_LedInit();
/* Reset counter to 0 */
TM_DELAY_SetTime(0);
while (1) {
/* If time is more than 500ms */
if (TM_DELAY_Time() >= 500) {
/* Reset time */
TM_DELAY_SetTime(0);
/* Toggle leds here */
TM_DISCO_LedToggle(LED_RED | LED_GREEN);
}
/* Place your code here */
/* Code here will be checked without any delay */
/* Constantly */
}
}
示例6: main
int main(void) {
/* Init system */
TM_RCC_InitSystem();
/* Init HAL layer */
HAL_Init();
/* Init leds */
TM_DISCO_LedInit();
/* Init delay */
TM_DELAY_Init();
/* Init USB peripheral */
TM_USB_Init();
/* Init VCP on HS port */
TM_USBD_CDC_Init(TM_USB_HS);
/* Start USB device mode on HS port */
TM_USBD_Start(TM_USB_HS);
while (1) {
/* Process USB CDC device, send remaining data if needed */
/* It is better if you call this in periodic timer, like each ms in SYSTICK handler */
TM_USBD_CDC_Process(TM_USB_HS);
/* Check if device is ready, if drivers are installed if needed on HS port */
if (TM_USBD_IsDeviceReady(TM_USB_HS) == TM_USBD_Result_Ok) {
/* Turn on green LED */
TM_DISCO_LedOn(LED_GREEN);
/* Check if user has changed parameters for COM port */
TM_USBD_CDC_GetSettings(TM_USB_HS, &USB_Settings);
/* Check if settings updated from user terminal */
if (USB_Settings.Updated) {
/* Reinit USART, only baudrate works in this example */
TM_USART_Init(USART6, TM_USART_PinsPack_1, USB_Settings.Baudrate);
}
/* Check if anything received on HS port from user */
while (TM_USBD_CDC_Getc(TM_USB_HS, &ch)) {
/* One character received */
/* Send character to USART */
TM_USART_Putc(USART6, ch);
}
/* CHeck if any character received from USART */
while (!TM_USART_BufferEmpty(USART6)) {
/* Send data over USB CDC */
TM_USBD_CDC_Putc(TM_USB_HS, TM_USART_Getc(USART6));
}
} else {
/* Turn off green LED */
TM_DISCO_LedOff(LED_GREEN);
}
}
}
示例7: main
int main(void) {
/* Initialize system */
SystemInit();
/* Initialize delay */
TM_DELAY_Init();
/* Initialize ILI9341 with LTDC */
/* By default layer 1 is used */
TM_ILI9341_Init();
/* Rotate LCD for 90 degrees */
TM_ILI9341_Rotate(TM_ILI9341_Orientation_Landscape_2);
TM_ILI9341_SetLayer1();
/* Fill data on layer 1 */
TM_ILI9341_Fill(ILI9341_COLOR_WHITE);
/* Show text */
TM_ILI9341_Puts(65, 30, "Layer 1", &TM_Font_11x18, ILI9341_COLOR_BLACK, ILI9341_COLOR_BLUE2);
TM_ILI9341_Puts(20, 130, "STM32F429 Discovery ONLY!", &TM_Font_11x18, ILI9341_COLOR_BLACK, ILI9341_COLOR_BLUE2);
TM_ILI9341_Puts(60, 150, "ILI9341 LCD Module", &TM_Font_11x18, ILI9341_COLOR_BLACK, ILI9341_COLOR_BLUE2);
TM_ILI9341_Puts(70, 170, "with LTDC support", &TM_Font_11x18, ILI9341_COLOR_BLACK, ILI9341_COLOR_BLUE2);
TM_ILI9341_Puts(170, 230, "stm32f4-discovery.com", &TM_Font_7x10, ILI9341_COLOR_BLACK, ILI9341_COLOR_ORANGE);
/* Go to layer 2 */
TM_ILI9341_SetLayer2();
/* Fill data on layer 2 */
TM_ILI9341_Fill(ILI9341_COLOR_GREEN2);
/* Show text */
TM_ILI9341_Puts(65, 30, "Layer 2", &TM_Font_11x18, ILI9341_COLOR_BLACK, ILI9341_COLOR_BLUE);
TM_ILI9341_Puts(20, 130, "STM32F429 Discovery ONLY!", &TM_Font_11x18, ILI9341_COLOR_BLACK, ILI9341_COLOR_RED);
TM_ILI9341_Puts(60, 150, "ILI9341 LCD Module", &TM_Font_11x18, ILI9341_COLOR_BLACK, ILI9341_COLOR_BLUE2);
TM_ILI9341_Puts(70, 170, "with LTDC support", &TM_Font_11x18, ILI9341_COLOR_BLACK, ILI9341_COLOR_BLUE2);
TM_ILI9341_Puts(170, 230, "stm32f4-discovery.com", &TM_Font_7x10, ILI9341_COLOR_BLACK, ILI9341_COLOR_ORANGE);
/* Draw circle on layer 2 */
TM_ILI9341_DrawCircle(150, 150, 140, ILI9341_COLOR_BLACK);
while (1) {
/* This will set opacity of one layer to 0, other to max (255) each time */
/* This is like toggle function */
TM_ILI9341_ChangeLayers();
Delayms(500);
/*
//Bottom code works the same as one before inside while loop
//Turn on Layer1 and turn off Layer2
TM_ILI9341_SetLayer1Opacity(255);
TM_ILI9341_SetLayer2Opacity(0);
Delayms(500);
//Turn on Layer2 and turn off Layer1
TM_ILI9341_SetLayer1Opacity(0);
TM_ILI9341_SetLayer2Opacity(255);
Delayms(500);
*/
}
}
示例8: main
int main(void) {
/* Initialize system */
SystemInit();
/* Initialize delay */
TM_DELAY_Init();
/* Initialize leds on board */
TM_DISCO_LedInit();
/* Initialize button */
TM_DISCO_ButtonInit();
/* Initialize watchdog timer */
/* Set timeout to 1s */
if (TM_WATCHDOG_Init(TM_WATCHDOG_Timeout_1s)) {
/* System was reset by watchdog */
TM_DISCO_LedOn(LED_RED);
} else {
/* System was not reset by watchdog */
TM_DISCO_LedOn(LED_GREEN);
}
while (1) {
/* If button is pressed, do nothing and system will be reset after 1 second */
while (TM_DISCO_ButtonPressed());
/* Reset watchdog */
TM_WATCHDOG_Reset();
}
}
示例9: main
int main(void) {
/* Init system */
TM_RCC_InitSystem();
/* Init HAL layer */
HAL_Init();
/* Init leds */
TM_DISCO_LedInit();
/* Init delay */
TM_DELAY_Init();
/* Init USB peripheral */
TM_USB_Init();
/* Init MSC device */
TM_USBD_MSC_Init(TM_USB_HS);
/* Start MSC device */
TM_USBD_Start(TM_USB_HS);
while (1) {
}
}
示例10: main
int main(void) {
//Initialize system
SystemInit();
//Initialize delay
TM_DELAY_Init();
//Initialize leds on board
TM_DISCO_LedInit();
//Initialize button
TM_DISCO_ButtonInit();
//Initialize watchdog timer
//Set timeout to 1s
if (TM_WATCHDOG_Init(TM_WATCHDOG_Timeout_1s)) {
//System was reset by watchdog
TM_DISCO_LedOn(LED_RED);
} else {
//System was not reset by watchdog
TM_DISCO_LedOn(LED_GREEN);
}
while (1) {
//if button is pressed, do nothing and system will be reset after 1 second
while (TM_DISCO_ButtonPressed());
//Reset watchdog
TM_WATCHDOG_Reset();
}
}
示例11: main
int main(void) {
char str[15];
//Initialize system
SystemInit();
//Initialize Delay library
TM_DELAY_Init();
//Initialize USART1-> TX: PA9, RX: PA10
TM_USART_Init(USART1, TM_USART_PinsPack_1, 9600);
TM_USART_Puts(USART1, "ADC example");
//Initialize ADC1 on channel 0, this is pin PA0
TM_ADC_Init(ADC1, ADC_Channel_0);
//Initialize ADC1 on channel 3, this is pin PA3
TM_ADC_Init(ADC1, ADC_Channel_3);
while (1) {
// Read ADC1 Channel0 Read ADC1 Channel3
sprintf(str, "%d: %d\n\r", TM_ADC_Read(ADC1, ADC_Channel_0), TM_ADC_Read(ADC1, ADC_Channel_3));
TM_USART_Puts(USART1, str);
Delayms(100);
}
}
示例12: main
int main(void) {
/* Set coordinates for poly line */
TM_DMA2DRAPHIC_Poly_t Coordinates[] = {
{10, 10},
{15, 65},
{200, 200},
{150, 30},
{10, 10}
};
/* Initialize system */
SystemInit();
/* Initialize delay functions */
TM_DELAY_Init();
/* Initialize ILI9341 with LTDC */
/* By default layer 1 is used */
TM_ILI9341_Init();
/* Initialize DMA2D GRAPHIC library */
TM_DMA2DGRAPHIC_Init();
/* Set ILI9341 Orientation */
TM_ILI9341_Rotate(TM_ILI9341_Orientation_Portrait_2);
/* Set DMA2D GRAPHIC library Orientation */
TM_DMA2DGRAPHIC_SetOrientation((uint8_t)TM_ILI9341_Orientation_Portrait_2);
/* Layer 1 */
/* Draw red rectangle at X = 10, Y = 10 position, width = 100 and height = 50px */
TM_DMA2DGRAPHIC_DrawRectangle(10, 10, 100, 50, GRAPHIC_COLOR_RED);
/* Draw filled blue rectangle at X = 100, Y = 100 position, width = 100 and height = 50px */
TM_DMA2DGRAPHIC_DrawFilledRectangle(100, 100, 100, 50, GRAPHIC_COLOR_BLUE);
/* Draw rounded rectangle */
TM_DMA2DGRAPHIC_DrawRoundedRectangle(110, 110, 80, 30, 10, GRAPHIC_COLOR_GREEN);
/* Go to layer 2, set address offset in memory for LCD */
TM_DMA2DGRAPHIC_SetLayer(2);
/* Fill layer 2 */
TM_DMA2DGRAPHIC_Fill(GRAPHIC_COLOR_YELLOW);
/* Draw poly line */
TM_DMA2DGRAPHIC_DrawPolyLine(Coordinates, 5, GRAPHIC_COLOR_BLACK);
/* Draw filled circle */
TM_DMA2DGRAPHIC_DrawFilledCircle(100, 170, 40, GRAPHIC_COLOR_CYAN);
while (1) {
/* Change display layer on LCD using LTDC transfer */
TM_ILI9341_ChangeLayers();
/* Delay */
Delayms(1000);
}
}
示例13: main
int main(void)
{
SystemInit(); // initialize MCU clocks and registers
TM_DELAY_Init(); // initialize Delay library
TM_DELAY_SetTime(0); // Reset couter for systime
Laser_GPIO_Conf(); // configure GPIO for laser control (to be able to enable/disable lasers via software
TM_BKPSRAM_Init(); // initialize BKP RAM access library
Laser_Update(); // load laser statuses saved in BKP RAM
TM_USART_Init(OUTPUT_USART, OUTPUT_USART_PINS, OUTPUT_USART_SPEED); // initialize UART used for collected Data output
TM_USART_Init(MENU_USART, MENU_USART_PINS, MENU_USART_SPEED); // initialize UART used for configuration
TM_RTC_Init(TM_RTC_ClockSource_External); // initialize RTC library
TM_GPIO_Init(GPIOD, GPIO_Pin_8, TM_GPIO_Mode_OUT, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_Low); // configure GPIO for GSM status indication (RED LED)
TM_GPIO_Init(GPIOD, GPIO_Pin_9, TM_GPIO_Mode_OUT, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_Low); // configure GPIO for GSM status indication (GREEN LED)
Laser_ADC_Init(); // initialize ADC peripherals
Menu_Init(); // initialize CLI library
sfpInit(); // configure GPIO for SFP modules
gsm_Init(); // initialize GSM module
/* configure and initialize Ethernet hardware and LwIP stack */
ETH_BSP_Config(); // configure ETH GPIOs
printf("Ethernet MAC and PHY configured successfully!\n");
LwIP_Init(); // start LwIP stack
printf("LwIP stack initialized successfully!\n");
UDP_Server_Init(); // start UDP Server
printf("UDP Server initialized successfully!\n");
//start periodic tasks
/* GSM Status update "task" */
GSM_Status_Update_Timer = TM_DELAY_TimerCreate(GSM_CHECK_INTERVAL, 1, 1, GSM_Status_Update_Timer_Task, NULL);
printf("GSM status check task created!\n");
/* Print results from remote devices "task" */
Print_Results_Timer = TM_DELAY_TimerCreate(DATA_OUT_INTERVAL, 1, 1, Print_Results_Timer_Task, NULL);
printf("Print collected data task created!\n");
/* LaserLock status update "task" */
LaserLock_Timer = TM_DELAY_TimerCreate(1000, 1, 1, LaserLock_Timer_Task, NULL);
printf("Laser lock check task created!\n");
while (1) {
/* CLI menu update */
Menu_Update();
/* check if any packet received */
if (ETH_CheckFrameReceived())
{
/* process received ethernet packet */
LwIP_Pkt_Handle();
}
/* handle periodic timers for LwIP */
LwIP_Periodic_Handle(LocalTime);
/* update laser statuses */
Laser_Update();
/* remove SMS messages which were read by system */
delete_read_gsm_messages();
}
}
示例14: main
int main(void) {
uint8_t i;
/* Init system clock for maximum system speed */
TM_RCC_InitSystem();
/* Init HAL layer */
HAL_Init();
/* Init leds */
TM_DISCO_LedInit();
/* Init delay functions */
TM_DELAY_Init();
/* Init LCD */
TM_LCD_Init();
/* Fill LCD with color */
TM_LCD_Fill(0xFFFF);
/* Set custom orientation for LCD */
TM_LCD_SetOrientation(1);
/* Get orientation from LCD and save to Touch Screen structure */
TS.Orientation = TM_LCD_GetOrientation();
/* Init touch, use default drivers, depends on defines in library */
/* Check library description for more information */
TM_TOUCH_Init(NULL, &TS);
while (1) {
/* Read touch */
TM_TOUCH_Read(&TS);
/* Check if pressed */
if (TS.NumPresses) {
/* Go through all presses on LCD */
for (i = 0; i < TS.NumPresses; i++) {
/* Draw circle */
TM_LCD_DrawFilledCircle(TS.X[i], TS.Y[i], 5, TOUCH_Colors[i]);
/* Format string */
sprintf(str, "X: %3d Y: %3d", TS.X[i], TS.Y[i]);
/* Print on LCD */
TM_LCD_SetXY(10, 10 + i * 20);
TM_LCD_Puts(str);
}
}
Delayms(5);
}
}
示例15: main
int main(void) {
uint8_t i;
/* Initialize system */
SystemInit();
/* Initialize delay */
TM_DELAY_Init();
/* Initialize LEDS */
TM_DISCO_LedInit();
/* Initialize RTC with internal clock */
TM_RTC_Init(TM_RTC_ClockSource_Internal);
/* Set RTC to generate wakeup interrupt every 10 seconds */
TM_RTC_Interrupts(TM_RTC_Int_10s);
/* Set time to 0 */
TM_DELAY_SetTime(0);
while (1) {
/* Toggle LEDs every 200ms */
if (TM_DELAY_Time() >= 200000) {
/* Reset time */
TM_DELAY_SetTime(0);
/* Toggle leds */
TM_DISCO_LedToggle(LED_GREEN);
/* Increase counter */
i++;
/* After 20 toggles, put STM32F4 into sleep mode */
if (i == 20) {
/* Reset counter */
i = 0;
/* Sleep until interrupt occur */
/* Also disable systick with "1" as parameter */
/* Because systick makes interrupts and it will wakeup */
/* device back after some ticks. This is useless */
/* If you set parameter to "0", then this function will not */
/* affect to Systick timer */
TM_LOWPOWER_SleepUntilInterrupt(1);
/* Toggle RED LED to indicate wakeup from sleep mode */
TM_DISCO_LedToggle(LED_RED);
}
}
}
}