int main(void) { char str[100]; TM_DS1307_Time_t time; uint8_t last; /* Initialize system */ SystemInit(); /* Initialize LEDS */ TM_DISCO_LedInit(); /* Initialize ILI9341 LCD on board */ TM_ILI9341_Init(); TM_ILI9341_Fill(ILI9341_COLOR_ORANGE); TM_ILI9341_Rotate(TM_ILI9341_Orientation_Portrait_2); TM_ILI9341_Puts(90, 310, "stm32f4-discovery.com", &TM_Font_7x10, ILI9341_COLOR_BLACK, ILI9341_COLOR_ORANGE); /* Initialize DS1307 */ if (TM_DS1307_Init() != TM_DS1307_Result_Ok) { /* Red LED on */ TM_DISCO_LedOn(LED_RED); /* Show on LCD */ TM_ILI9341_Puts(10, 10, "DS1307 Error", &TM_Font_11x18, ILI9341_COLOR_BLACK, ILI9341_COLOR_ORANGE); while (1); } /* Set date and time */ /* Day 7, 26th May 2014, 02:05:00 */ time.hours = 21; time.minutes = 18; time.seconds = 0; time.date = 26; time.day = 1; time.month = 5; time.year = 14; TM_DS1307_SetDateTime(&time); /* Disable output first */ TM_DS1307_DisableOutputPin(); /* Set output pin to 4096 Hz */ TM_DS1307_EnableOutputPin(TM_DS1307_OutputFrequency_4096Hz); while (1) { /* Get date and time */ TM_DS1307_GetDateTime(&time); /* Display on LCD */ sprintf(str, "Day: %d\nDate: %02d\nMonth: %02d\nYear: %04d\nHours: %02d\nMinutes: %02d\nSeconds: %02d", time.day, time.date, time.month, time.year + 2000, time.hours, time.minutes, time.seconds); TM_ILI9341_Puts(10, 15, str, &TM_Font_11x18, ILI9341_COLOR_ORANGE, 0x0000); /* Toggle GREEN led if needed */ if (last != time.seconds) { last = time.seconds; /* Toggle GREEN LED */ TM_DISCO_LedToggle(LED_GREEN); } } }
int main(void) { uint8_t c; /* System Init */ SystemInit(); /* Initialize LED's. Make sure to check settings for your board in tm_stm32f4_disco.h file */ TM_DISCO_LedInit(); /* Initialize USB VCP */ TM_USB_VCP_Init(); while (1) { /* USB configured OK, drivers OK */ if (TM_USB_VCP_GetStatus() == TM_USB_VCP_CONNECTED) { /* Turn on GREEN led */ TM_DISCO_LedOn(LED_GREEN); /* If something arrived at VCP */ if (TM_USB_VCP_Getc(&c) == TM_USB_VCP_DATA_OK) { /* Return data back */ TM_USB_VCP_Putc(c); } } else { /* USB not OK */ TM_DISCO_LedOff(LED_GREEN); } } }
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); } } }
int main(void) { /* Init system clock for maximum system speed */ TM_RCC_InitSystem(); /* Init HAL layer */ HAL_Init(); /* Init leds */ TM_DISCO_LedInit(); /* Init button */ TM_DISCO_ButtonInit(); /* Init ONEWIRE port on PB4 pin */ TM_OneWire_Init(&OW, GPIOB, GPIO_PIN_4); /* Check if any device is connected */ if (TM_OneWire_First(&OW)) { /* Set LED GREEN */ TM_DISCO_LedOn(LED_GREEN); /* Search for next devices */ do { /* Read ROM from device */ //TM_OneWire_GetFullROM(&OW, &array_8_bytes[0]); } while (TM_OneWire_Next(&OW)); } else { /* Set LED RED */ TM_DISCO_LedOn(LED_RED); } while (1) { } }
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(); } }
int main(void) { /* Init system clock for maximum system speed */ TM_RCC_InitSystem(); /* Init HAL layer */ HAL_Init(); /* Init leds */ TM_DISCO_LedInit(); /* Init button */ TM_DISCO_ButtonInit(); /* Init USART, Pins not initialized yet, 921600 bauds */ TM_USART_Init(USART6, TM_USART_PinsPack_Custom, 921600); /* Put test string */ TM_USART_Puts(USART6, "Hello world\n"); while (1) { /* Check if anything received */ while (!TM_USART_BufferEmpty(USART6)) { /* Send data back from buffer */ TM_USART_Putc(USART6, TM_USART_Getc(USART6)); } } }
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(); } }
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(); } }
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) { } }
int test_exi(void) { /* Initialize system */ SystemInit(); /* Initialize LEDS */ TM_DISCO_LedInit(); //Initialize LCD TM_ILI9341_Init(); //Fill with orange color TM_ILI9341_Fill(ILI9341_COLOR_ORANGE); //Rotate LCD TM_ILI9341_Rotate(TM_ILI9341_Orientation_Portrait_2); /* Attach interrupt on pin PA0 = External line 0 */ /* Button connected on discovery boards */ if (TM_EXTI_Attach(GPIOA, GPIO_Pin_0, TM_EXTI_Trigger_Rising) == TM_EXTI_Result_Ok) { TM_DISCO_LedOn(LED_RED); } /* Attach interrupt on pin PC13 = External line 13 */ /* Button connected on nucleo boards */ if (TM_EXTI_Attach(GPIOC, GPIO_Pin_13, TM_EXTI_Trigger_Falling) == TM_EXTI_Result_Ok) { TM_DISCO_LedOn(LED_GREEN); } while (1) { } }
int main(void) { /* Init system clock for maximum system speed */ TM_RCC_InitSystem(); /* Init HAL layer */ HAL_Init(); /* Init leds */ TM_DISCO_LedInit(); /* Init USART, TX: PC6, RX: PC7, 921600 bauds */ TM_USART_Init(USART2, TM_USART_PinsPack_1, 115200); /* Put test string */ TM_USART_Puts(USART2, "Hello world\n"); while (1) { /* Check if we have string "OK" in USART6 buffer */ if (TM_USART_FindString(USART2, "OK")) { /* Send data back from buffer */ while (!TM_USART_BufferEmpty(USART2)) { /* Send to computer */ TM_USART_Putc(USART2, TM_USART_Getc(USART6)); } } } }
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 */ } }
int main(void) { /* Init system clock for maximum system speed */ TM_RCC_InitSystem(); /* Init HAL layer */ HAL_Init(); /* Init leds */ TM_DISCO_LedInit(); /* Init button */ TM_DISCO_ButtonInit(); /* Initialize USART, TX: PB6, RX: PB7 */ TM_USART_Init(USART1, TM_USART_PinsPack_2, 115200); /* Initialize NRF24L01+ on channel 15 and 32bytes of payload */ /* By default 2Mbps data rate and 0dBm output power */ /* NRF24L01 goes to RX mode by default */ TM_NRF24L01_Init(15, 32); /* Set RF settings, Data rate to 2Mbps, Output power to -18dBm */ TM_NRF24L01_SetRF(TM_NRF24L01_DataRate_2M, TM_NRF24L01_OutputPower_M18dBm); /* Set my address, 5 bytes */ TM_NRF24L01_SetMyAddress(MyAddress); /* Set TX address, 5 bytes */ TM_NRF24L01_SetTxAddress(TxAddress); while (1) { /* If data is ready on NRF24L01+ */ if (TM_NRF24L01_DataReady()) { /* Get data from NRF24L01+ */ TM_NRF24L01_GetData(dataIn); /* Start send */ TM_DISCO_LedOn(LED_GREEN); /* Send it back, automatically goes to TX mode */ TM_NRF24L01_Transmit(dataIn); /* Wait for data to be sent */ do { /* Wait till sending */ transmissionStatus = TM_NRF24L01_GetTransmissionStatus(); } while (transmissionStatus == TM_NRF24L01_Transmit_Status_Sending); /* Send done */ TM_DISCO_LedOff(LED_GREEN); /* Go back to RX mode */ TM_NRF24L01_PowerUpRx(); } } }
int main(void) { uint16_t values[2] = {0, 0}; /* Init system clock for maximum system speed */ TM_RCC_InitSystem(); /* Init HAL layer */ HAL_Init(); /* Init leds */ TM_DISCO_LedInit(); /* Init button */ TM_DISCO_ButtonInit(); /* Init DAC channel 1 = PA4 */ TM_DAC_Init(TM_DAC_Channel_1); /* Init DAC channel 2 = PA5 */ TM_DAC_Init(TM_DAC_Channel_2); while (1) { /* Toggle ALL leds */ if (TM_DELAY_Time() > 200) { /* Toggle leds */ TM_DISCO_LedToggle(LED_ALL); } /* Increase channel 1 value */ values[0]++; /* Decrease channel 2 value */ values[1]--; /* Check if channel 1 is overflowed 12 bit and set it to zero */ if (values[0] > 0x0FFF) { values[0] = 0; } /* Check if channel 2 is less than zero (overflow to 0xFFFF) and set to to max 12 bit value */ if (values[1] > 0x0FFF) { values[1] = 0x0FFF; } /* Set DAC channel 1 = PA4 */ TM_DAC_SetValue(TM_DAC_Channel_1, values[0]); /* Set DAC channel 2 = PA5 */ TM_DAC_SetValue(TM_DAC_Channel_2, values[1]); /* Delay 1ms */ Delayms(1); } }
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); } }
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); } } } }
int main(void) { char buff[100]; /* Init system clock for maximum system speed */ TM_RCC_InitSystem(); /* Init HAL layer */ HAL_Init(); /* Init leds */ TM_DISCO_LedInit(); /* Init LCD */ TM_LCD_Init(); /* Display fixes */ #if defined(STM32F7_DISCOVERY) TM_LCD_SetFont(&TM_Font_7x10); #elif defined(STM32F429_DISCOVERY) TM_LCD_SetFont(&TM_Font_7x10); TM_LCD_SetOrientation(3); #endif /* Format unique ID */ sprintf(buff, "Unique ID: 0x%08X 0x%08X 0x%08X", TM_ID_GetUnique32(0), TM_ID_GetUnique32(1), TM_ID_GetUnique32(2)); TM_LCD_SetXY(10, 10); TM_LCD_Puts(buff); /* Format device signature */ sprintf(buff, "Device signature: 0x%04X", TM_ID_GetSignature()); TM_LCD_SetXY(10, 30); TM_LCD_Puts(buff); /* Format revision */ sprintf(buff, "Revision: 0x%04X", TM_ID_GetRevision()); TM_LCD_SetXY(10, 50); TM_LCD_Puts(buff); /* Format package */ sprintf(buff, "Package: 0x%04X", TM_ID_GetPackage()); TM_LCD_SetXY(10, 70); TM_LCD_Puts(buff); /* Format flash size */ sprintf(buff, "Flash size: %04d kBytes", TM_ID_GetFlashSize()); TM_LCD_SetXY(10, 90); TM_LCD_Puts(buff); while (1) { } }
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() >= 200) { /* Reset time */ TM_DELAY_SetTime(0); /* Toggle leds */ TM_DISCO_LedToggle(LED_GREEN); /* Increase counter */ i++; /* After 20 toggles, put STM32F4 into STOP mode */ if (i == 20) { /* Reset counter */ i = 0; /* Stop STM32F4 */ /* If you stop device, then you can wake him up with interrupt/event on EXTI line */ /* Put it into STOP mode, allowing EXTI interrupts to wake him up */ /* RTC will wake him up after 10 seconds */ TM_LOWPOWER_StopUntilInterrupt(); /* Toggle RED LED to indicate wakeup from stop mode */ TM_DISCO_LedToggle(LED_RED); } } } }
int main(void) { /* Initialize system */ SystemInit(); /* Initialize delay */ TM_DELAY_Init(); /* Initiaize button */ TM_DISCO_ButtonInit(); /* Initialize Leds */ TM_DISCO_LedInit(); /* Initialize USART, TX: PB10, RX: PB11 */ TM_USART_Init(USART3, TM_USART_PinsPack_1, 115200); /* Initialize RTC with internal 32768Hz clock */ /* It's not very accurate */ if (!TM_RTC_Init(TM_RTC_ClockSource_Internal)) { /* RTC was first time initialized */ /* Do your stuff here */ /* eg. set default time */ } /* Set wakeup interrupt every 125 ms */ TM_RTC_Interrupts(TM_RTC_Int_125ms); while (1) { /* If button pressed */ if (TM_DISCO_ButtonPressed()) { /* Subseconds are ignored when writing new time */ datatime.hours = 0; datatime.minutes = 59; datatime.seconds = 55; datatime.year = 14; datatime.month = 6; datatime.date = 30; datatime.day = 6; /* Set new time */ TM_RTC_SetDateTime(&datatime, TM_RTC_Format_BIN); } } }
int main(void) { /* Init system clock for maximum system speed */ TM_RCC_InitSystem(); /* Init HAL layer */ HAL_Init(); /* Init leds */ TM_DISCO_LedInit(); /* Try to mount card */ if (f_mount(&FS, "SD:", 1) == FR_OK) { /* Try to open file */ if ((fres = f_open(&fil, "SD:first_file.txt", FA_OPEN_ALWAYS | FA_READ | FA_WRITE)) == FR_OK) { /* Read SDCARD size */ TM_FATFS_GetDriveSize("SD:", &CardSize); /* Format string */ sprintf(buffer, "Total card size: %u kBytes\n", CardSize.Total); /* Write total card size to file */ f_puts(buffer, &fil); /* Format string for free card size */ sprintf(buffer, "Free card size: %u kBytes\n", CardSize.Free); /* Write free card size to file */ f_puts(buffer, &fil); /* Close file */ f_close(&fil); /* Turn led ON */ TM_DISCO_LedOn(LED_ALL); } /* Unmount SDCARD */ f_mount(NULL, "SD:", 1); } /* Do nothing */ while (1) { } }
int main(void) { __IO uint32_t i; /* CPU load structure */ TM_CPULOAD_t CPU_LOAD; /* Init CPU load monitor */ TM_CPULOAD_Init(&CPU_LOAD); /* Initialize system */ SystemInit(); /* Initialize delay */ TM_DELAY_Init(); /* Initialize leds on board */ TM_DISCO_LedInit(); /* Init button */ TM_DISCO_ButtonInit(); /* Init USART2, TX: PA2, RX: PA3, 921600 bauds */ TM_USART_Init(USART2, TM_USART_PinsPack_1, 921600); while (1) { /* Check if CPU LOAD variable is updated */ if (CPU_LOAD.Updated) { /* Print to user */ printf("W: %u; S: %u; Load: %5.2f\n", CPU_LOAD.WCNT, CPU_LOAD.SCNT, CPU_LOAD.Load); } /* Toggle leds */ TM_DISCO_LedToggle(LED_ALL); /* If button pressed, do some useless counting */ if (TM_DISCO_ButtonPressed()) { /* Count something to waste some time before entering to sleep mode */ i = 0; while (i++ < 0x1FFF); } /* Go low power mode, sleep mode until interrupt, measure CPU load */ TM_CPULOAD_GoToSleepMode(&CPU_LOAD, TM_LOWPOWERMODE_SleepUntilInterrupt); } }
int main(void) { /* Initialize system */ SystemInit(); /* Initialize delay */ TM_DELAY_Init(); /* Initiaize button */ TM_DISCO_ButtonInit(); /* Initialize Leds */ TM_DISCO_LedInit(); /* Initialize RTC with internal 32768Hz clock */ /* It's not very accurate */ if (!TM_RTC_Init(TM_RTC_ClockSource_Internal)) { /* RTC was first time initialized */ /* Do your stuff here */ /* eg. set default time */ /* Write data to backup register 4 */ TM_RTC_WriteBackupRegister(4, 0x1244); /* Turn on RED led = Write operation */ TM_DISCO_LedOn(LED_RED); } else { /* Try to read data back and check if it is OK */ if (TM_RTC_ReadBackupRegister(4) == 0x1244) { /* Read OK after reset, turn on GREEN led */ TM_DISCO_LedOn(LED_GREEN); } } /* If not leds ON, try to remove power from device first so RTC will need to initialize again */ /* If still no leds after that, then you have problems with your RTC clock */ while (1) { /* If button pressed */ if (TM_DISCO_ButtonPressed()) { /* After button press, system will reset */ NVIC_SystemReset(); } } }
int main(void) { /* Init system clock for maximum system speed */ TM_RCC_InitSystem(); /* Init HAL layer */ HAL_Init(); /* Initialize delay */ TM_DELAY_Init(); /* Initialize leds on board */ TM_DISCO_LedInit(); /* Init button */ TM_DISCO_ButtonInit(); /* Init USART6, TX: PC6, 921600 baud */ TM_USART_Init(USART6, TM_USART_PinsPack_1, 921600); /* Get system reset source and clear flags after read */ printf("System reset source: %d\n", (uint8_t)TM_GENERAL_GetResetSource(1)); /* Get system reset source and clear flags after read */ /* You should see number which corresponds to "None", because we cleared flags in statement above */ printf("System reset source: %d\n", (uint8_t)TM_GENERAL_GetResetSource(1)); /* Get system core and PCLK1 (Peripheral Clock 1, APB1) clocks */ printf("System core clock: %u Hz; PCLK1 clock: %u Hz\n", TM_GENERAL_GetClockSpeed(TM_GENERAL_Clock_SYSCLK), TM_GENERAL_GetClockSpeed(TM_GENERAL_Clock_PCLK1) ); while (1) { /* If button pressed */ if (TM_DISCO_ButtonOnPressed()) { /* Send to USER */ printf("Software reset will happen in a moment\n"); /* Wait a little */ Delayms(500); /* Perform system software reset */ TM_GENERAL_SystemReset(); } } }
int main(void) { //Initialize system */ SystemInit(); /* Initialize delay */ TM_DELAY_Init(); /* Initialize onboard leds */ TM_DISCO_LedInit(); while (1) { /* Toggle leds */ TM_DISCO_LedToggle(LED_GREEN); /* Delay 500ms */ Delayms(500); /* Delay 500 us */ //Delay(500); } }
int main(void) { /* Initialize System */ SystemInit(); /* Initialize leds on board */ TM_DISCO_LedInit(); /* Initialize button on board */ TM_DISCO_ButtonInit(); while(1) { /* If button pressed */ if (TM_DISCO_ButtonPressed()) { /* Turn on leds */ TM_DISCO_LedOn(LED_RED | LED_GREEN); } else { /* Turn off leds */ TM_DISCO_LedOff(LED_RED | LED_GREEN); } } }
int main(void) { uint8_t i = 0; /* Init system clock for maximum system speed */ TM_RCC_InitSystem(); /* Init HAL layer */ HAL_Init(); /* Init leds */ TM_DISCO_LedInit(); /* Init SDRAM */ TM_SDRAM_Init(); /* Fill write data */ for (i = 0; i < 32; i++) { Write[i] = 1 << i; /* Write to SDRAM */ TM_SDRAM_Write32(4 * i, Write[i]); } /* Read data from SDRAM */ for (i = 0; i < 32; i++) { Read[i] = TM_SDRAM_Read32(4 * i); } /* Memory compare */ if (memcmp((uint8_t *)Read, (uint8_t *)Write, sizeof(Read)) == 0) { /* SDRAM is OK */ TM_DISCO_LedOn(LED_GREEN); } else { /* SDRAM failed */ TM_DISCO_LedOn(LED_RED); } while (1) { } }
int main(void) { /* Init system clock for maximum system speed */ TM_RCC_InitSystem(); /* Init HAL layer */ HAL_Init(); /* Init leds */ TM_DISCO_LedInit(); /* Init delay */ TM_DELAY_Init(); /* Init I2C, use custom pins, callback function will be caleed */ /* For STM32F4xx and STM32F7xx lines */ TM_I2C_Init(I2C1, TM_I2C_PinsPack_Custom, 100000); while (1) { } }
int main(void) { /* Init system clock for maximum system speed */ TM_RCC_InitSystem(); /* Init HAL layer */ HAL_Init(); /* Init leds */ TM_DISCO_LedInit(); /* Init button */ TM_DISCO_ButtonInit(); while (1) { /* Toggle leds */ TM_DISCO_LedToggle(LED_ALL); /* Delay 500ms */ Delayms(500); } }
int main(void) { uint16_t write, read; uint8_t i; /* Initialize system */ SystemInit(); /* Initialize delay */ TM_DELAY_Init(); /* Initialize leds */ TM_DISCO_LedInit(); /* Initialize SDRAM */ if (TM_SDRAM_Init()) { TM_DISCO_LedOn(LED_GREEN); } else { TM_DISCO_LedOn(LED_RED); } /* Some delay */ Delayms(2000); write = 1234; /* Write 16bit value to SDRAM at location 0x3214 */ TM_SDRAM_Write16(0x3214, write); /* Read from location 0x3214 */ read = TM_SDRAM_Read16(0x3214); if (write == read) { TM_DISCO_LedOff(LED_GREEN | LED_RED); /* Blink leds to indicate that reading and writing was correct */ for (i = 0; i < 10; i++) { TM_DISCO_LedToggle(LED_GREEN | LED_RED); Delayms(100); } } while (1) { } }
int main(void) { TM_RCC_InitSystem(); /* Init system */ HAL_Init(); /* Init HAL layer */ TM_DISCO_LedInit(); /* Init leds */ TM_DISCO_ButtonInit(); /* Init button */ TM_DELAY_Init(); /* Init delay */ TM_USART_Init(DEBUG_USART, DEBUG_USART_PP, 921600); /* Init USART for debug purpose */ /* Print first screen message */ printf("ESP8266 commands parser; Compiled: %s %s\r\n", __DATE__, __TIME__); /* Initialize threads */ ESP_Update_ThreadId = osThreadCreate(osThread(ESP_Update), NULL); ESP_Main_ThreadId = osThreadCreate(osThread(ESP_Main), NULL); /* Start kernel */ osKernelStart(); while (1) { } }