Advertisement
Guest User

Untitled

a guest
Dec 21st, 2014
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1.  
  2. #include "tm_stm32f4_usb_vcp.h"
  3. #include "tm_stm32f4_disco.h"
  4. #include "tm_stm32f4_delay.h"
  5. #include "tm_stm32f4_usart.h"
  6. #include "tm_stm32f4_adc.h"
  7. #include "stm32f4xx.h"
  8. #include "defines.h"
  9. #include "stdlib.h"
  10. #include <stdio.h>
  11.  
  12. int main(void) {
  13.  
  14. uint8_t c;
  15. // char str[15];
  16.  
  17. short rng;
  18.  
  19. /* System Init */
  20.  
  21. SystemInit();
  22.  
  23. /* Initialize LED's. Make sure to check settings for your board in tm_stm32f4_disco.h file */
  24. TM_DISCO_LedInit();
  25.  
  26. /* Initialize USB VCP */
  27. TM_USB_VCP_Init();
  28. TM_DELAY_Init();
  29. //TM_USART_Init(USART1, TM_USART_PinsPack_2, 115200);
  30. TM_ADC_Init(ADC1, ADC_Channel_0);
  31. rng = 0;
  32. while (1) {
  33. /* USB configured OK, drivers OK */
  34. if (TM_USB_VCP_GetStatus() == TM_USB_VCP_CONNECTED) {
  35. /* Turn on GREEN led */
  36. // sprintf(str, "%4d: \n\r", TM_ADC_Read(ADC1, ADC_Channel_0));
  37. // TM_USB_VCP_Putc(TM_ADC_Read(ADC1, ADC_Channel_0));
  38. // Delayms(100);
  39. // TM_USB_VCP_Putc(TM_ADC_Read(ADC1, ADC_Channel_0));
  40. // while(--delay);
  41.  
  42. TM_DISCO_LedOn(LED_GREEN);
  43.  
  44. TM_USB_VCP_Putc((float)++rng);
  45. // delay = 10000000;
  46. // while(--delay);
  47. // rng = rand() % 4095;
  48. //Delayms(1000);
  49. TM_DISCO_LedOff(LED_GREEN);
  50. // TM_USB_VCP_Putc(rng);
  51. // TM_USB_VCP_Putc(rng>>8);
  52. // delay = 10000000;
  53. Delayms(1000);
  54. /* If something arrived at VCP */
  55. if (TM_USB_VCP_Getc(&c) == TM_USB_VCP_DATA_OK) {
  56. /* Return data back */
  57. TM_USB_VCP_Putc(c);
  58. }
  59. } else {
  60. /* USB not OK */
  61. TM_DISCO_LedOff(LED_GREEN);
  62. }
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement