Subversion Repositories EngineBay2

Rev

Rev 7 | Rev 9 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7 Rev 8
Line 49... Line 49...
49
UART_HandleTypeDef huart1;
49
UART_HandleTypeDef huart1;
50
UART_HandleTypeDef huart2;
50
UART_HandleTypeDef huart2;
51
 
51
 
52
/* USER CODE BEGIN PV */
52
/* USER CODE BEGIN PV */
53
/* Private variables ---------------------------------------------------------*/
53
/* Private variables ---------------------------------------------------------*/
-
 
54
char TimerFlag = 0;
-
 
55
 
-
 
56
char NoSerialInCTR = 0; // Missing characters coming in on USART1
-
 
57
char NoSerialIn = 0;
-
 
58
 
-
 
59
// storage for ADC
-
 
60
long ADC_samples[6];
54
 
61
 
55
/* USER CODE END PV */
62
/* USER CODE END PV */
56
 
63
 
57
/* Private function prototypes -----------------------------------------------*/
64
/* Private function prototypes -----------------------------------------------*/
58
void SystemClock_Config(void);
65
void SystemClock_Config(void);
Line 70... Line 77...
70
               
77
               
71
 
78
 
72
/* USER CODE BEGIN PFP */
79
/* USER CODE BEGIN PFP */
73
/* Private function prototypes -----------------------------------------------*/
80
/* Private function prototypes -----------------------------------------------*/
74
 
81
 
75
long ADC_samples[6];
-
 
76
 
-
 
77
 
82
 
78
void ConfigureDMA(void)
83
void ConfigureDMA(void)
79
{
84
{
80
 hdma_adc.Instance                 = DMA1_Channel1;
85
 hdma_adc.Instance                 = DMA1_Channel1;
81
 hdma_adc.Init.Direction           = DMA_PERIPH_TO_MEMORY;
86
 hdma_adc.Init.Direction           = DMA_PERIPH_TO_MEMORY;
Line 128... Line 133...
128
        __HAL_RCC_USART2_CLK_ENABLE() ;  // Debug comms port
133
        __HAL_RCC_USART2_CLK_ENABLE() ;  // Debug comms port
129
 
134
 
130
    __HAL_RCC_ADC1_CLK_ENABLE(); // enable the ADC
135
    __HAL_RCC_ADC1_CLK_ENABLE(); // enable the ADC
131
 
136
 
132
 
137
 
-
 
138
    __HAL_RCC_TIM6_CLK_ENABLE();
-
 
139
 
133
    ConfigureDMA();
140
    ConfigureDMA();
134
  //   HAL_ADC_Start_DMA(&g_AdcHandle, g_ADCBuffer, ADC_BUFFER_LENGTH);
141
  //   HAL_ADC_Start_DMA(&g_AdcHandle, g_ADCBuffer, ADC_BUFFER_LENGTH);
135
 
142
 
136
        /* setup the USART control blocks */
143
        /* setup the USART control blocks */
137
        init_usart_ctl(&uc1, huart1.Instance);
144
        init_usart_ctl(&uc1, huart1.Instance);
138
        init_usart_ctl(&uc2, huart2.Instance);
145
        init_usart_ctl(&uc2, huart2.Instance);
139
 
146
 
140
        EnableSerialRxInterrupt(&uc1);
147
        EnableSerialRxInterrupt(&uc1);
141
        EnableSerialRxInterrupt(&uc2);
148
        EnableSerialRxInterrupt(&uc2);
142
 
149
 
-
 
150
         HAL_TIM_Base_Start_IT(&htim6);
-
 
151
 
143
  PutCharSerial(&uc2,'A');
152
  PutCharSerial(&uc2,'A');
144
 
153
 
145
  /* USER CODE END 2 */
154
  /* USER CODE END 2 */
146
 
155
 
147
  /* Infinite loop */
156
  /* Infinite loop */
148
  /* USER CODE BEGIN WHILE */
157
  /* USER CODE BEGIN WHILE */
149
  while (1)
158
  while (1)
150
  {
159
  {
151
  /* USER CODE END WHILE */
160
  /* USER CODE END WHILE */
152
      char c =  GetCharSerial(&uc2);
-
 
153
      PutCharSerial(&uc2,c);
-
 
154
 
-
 
155
 
-
 
156
 
161
 
157
  /* USER CODE BEGIN 3 */
162
  /* USER CODE BEGIN 3 */
158
 
163
 
159
  }
164
  }
160
  /* USER CODE END 3 */
165
  /* USER CODE END 3 */