Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "tm_stm32f4_usb_vcp.h"
- #include "tm_stm32f4_disco.h"
- #include "tm_stm32f4_delay.h"
- #include "tm_stm32f4_usart.h"
- #include "tm_stm32f4_adc.h"
- #include "stm32f4xx.h"
- #include "defines.h"
- #include "stdlib.h"
- #include <stdio.h>
- int main(void) {
- uint8_t c;
- // char str[15];
- short rng;
- /* 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();
- TM_DELAY_Init();
- //TM_USART_Init(USART1, TM_USART_PinsPack_2, 115200);
- TM_ADC_Init(ADC1, ADC_Channel_0);
- rng = 0;
- while (1) {
- /* USB configured OK, drivers OK */
- if (TM_USB_VCP_GetStatus() == TM_USB_VCP_CONNECTED) {
- /* Turn on GREEN led */
- // sprintf(str, "%4d: \n\r", TM_ADC_Read(ADC1, ADC_Channel_0));
- // TM_USB_VCP_Putc(TM_ADC_Read(ADC1, ADC_Channel_0));
- // Delayms(100);
- // TM_USB_VCP_Putc(TM_ADC_Read(ADC1, ADC_Channel_0));
- // while(--delay);
- TM_DISCO_LedOn(LED_GREEN);
- TM_USB_VCP_Putc((float)++rng);
- // delay = 10000000;
- // while(--delay);
- // rng = rand() % 4095;
- //Delayms(1000);
- TM_DISCO_LedOff(LED_GREEN);
- // TM_USB_VCP_Putc(rng);
- // TM_USB_VCP_Putc(rng>>8);
- // delay = 10000000;
- Delayms(1000);
- /* 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);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement