Subversion Repositories dashGPS

Rev

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

Rev 2 Rev 5
Line 21... Line 21...
21
#include "main.h"
21
#include "main.h"
22
 
22
 
23
/* Private includes ----------------------------------------------------------*/
23
/* Private includes ----------------------------------------------------------*/
24
/* USER CODE BEGIN Includes */
24
/* USER CODE BEGIN Includes */
25
#include "libSerial/serial.h"
25
#include "libSerial/serial.h"
-
 
26
#include "libSSD1306/SSD1306.h"
26
#include "nmea.h"
27
#include "nmea.h"
27
/* USER CODE END Includes */
28
/* USER CODE END Includes */
28
 
29
 
29
/* Private typedef -----------------------------------------------------------*/
30
/* Private typedef -----------------------------------------------------------*/
30
/* USER CODE BEGIN PTD */
31
/* USER CODE BEGIN PTD */
Line 106... Line 107...
106
  /* setup the USART control blocks */
107
  /* setup the USART control blocks */
107
  init_usart_ctl(&uc1, huart1.Instance);
108
  init_usart_ctl(&uc1, huart1.Instance);
108
 
109
 
109
  EnableSerialRxInterrupt (&uc1);
110
  EnableSerialRxInterrupt (&uc1);
110
 
111
 
-
 
112
 
-
 
113
  ssd1306_begin(0,0);
-
 
114
 
-
 
115
  clearDisplay();
-
 
116
 
-
 
117
  drawLine(0,0,127,64,1);
-
 
118
 
-
 
119
  display();
-
 
120
 
-
 
121
  HAL_Delay(1000);
-
 
122
  int cnt = 0;
111
  /* USER CODE END 2 */
123
  /* USER CODE END 2 */
112
 
124
 
113
  /* Infinite loop */
125
  /* Infinite loop */
114
  /* USER CODE BEGIN WHILE */
126
  /* USER CODE BEGIN WHILE */
115
  while (1)
127
  while (1)
116
    {
128
    {
-
 
129
         if(cnt==0)
-
 
130
           clearDisplay();
-
 
131
         drawLine(0,cnt,127,cnt,1);
-
 
132
         display();
117
 
133
         cnt++;
-
 
134
         cnt%=64;
118
         Location loc;
135
         Location loc;
119
         uint8_t stat = updateLocation(&loc);
136
         uint8_t stat = updateLocation(&loc);
120
 
137
 
-
 
138
          HAL_Delay(10);
-
 
139
 
-
 
140
 
121
 
141
 
122
    /* USER CODE END WHILE */
142
    /* USER CODE END WHILE */
123
 
143
 
124
    /* USER CODE BEGIN 3 */
144
    /* USER CODE BEGIN 3 */
125
    }
145
    }
Line 219... Line 239...
219
  /* SPI1 parameter configuration*/
239
  /* SPI1 parameter configuration*/
220
  hspi1.Instance = SPI1;
240
  hspi1.Instance = SPI1;
221
  hspi1.Init.Mode = SPI_MODE_MASTER;
241
  hspi1.Init.Mode = SPI_MODE_MASTER;
222
  hspi1.Init.Direction = SPI_DIRECTION_1LINE;
242
  hspi1.Init.Direction = SPI_DIRECTION_1LINE;
223
  hspi1.Init.DataSize = SPI_DATASIZE_8BIT;
243
  hspi1.Init.DataSize = SPI_DATASIZE_8BIT;
224
  hspi1.Init.CLKPolarity = SPI_POLARITY_LOW;
244
  hspi1.Init.CLKPolarity = SPI_POLARITY_HIGH;
225
  hspi1.Init.CLKPhase = SPI_PHASE_1EDGE;
245
  hspi1.Init.CLKPhase = SPI_PHASE_2EDGE;
226
  hspi1.Init.NSS = SPI_NSS_SOFT;
246
  hspi1.Init.NSS = SPI_NSS_SOFT;
227
  hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_8;
247
  hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_8;
228
  hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;
248
  hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;
229
  hspi1.Init.TIMode = SPI_TIMODE_DISABLE;
249
  hspi1.Init.TIMode = SPI_TIMODE_DISABLE;
230
  hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
250
  hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
Line 329... Line 349...
329
static void MX_GPIO_Init(void)
349
static void MX_GPIO_Init(void)
330
{
350
{
331
  GPIO_InitTypeDef GPIO_InitStruct = {0};
351
  GPIO_InitTypeDef GPIO_InitStruct = {0};
332
 
352
 
333
  /* GPIO Ports Clock Enable */
353
  /* GPIO Ports Clock Enable */
-
 
354
  __HAL_RCC_GPIOC_CLK_ENABLE();
334
  __HAL_RCC_GPIOD_CLK_ENABLE();
355
  __HAL_RCC_GPIOD_CLK_ENABLE();
335
  __HAL_RCC_GPIOA_CLK_ENABLE();
356
  __HAL_RCC_GPIOA_CLK_ENABLE();
336
  __HAL_RCC_GPIOC_CLK_ENABLE();
-
 
337
  __HAL_RCC_GPIOB_CLK_ENABLE();
357
  __HAL_RCC_GPIOB_CLK_ENABLE();
338
 
358
 
339
  /*Configure GPIO pin Output Level */
359
  /*Configure GPIO pin Output Level */
340
  HAL_GPIO_WritePin(GPIOA, SPI_NSS1_Pin|SPI_CD_Pin, GPIO_PIN_RESET);
360
  HAL_GPIO_WritePin(GPIOC, SPI_CD_Pin|SPI_RESET_Pin, GPIO_PIN_RESET);
341
 
361
 
342
  /*Configure GPIO pin Output Level */
362
  /*Configure GPIO pin Output Level */
343
  HAL_GPIO_WritePin(SPI_RESET_GPIO_Port, SPI_RESET_Pin, GPIO_PIN_RESET);
363
  HAL_GPIO_WritePin(SPI_NSS1_GPIO_Port, SPI_NSS1_Pin, GPIO_PIN_RESET);
344
 
364
 
345
  /*Configure GPIO pins : SPI_NSS1_Pin SPI_CD_Pin */
365
  /*Configure GPIO pins : SPI_CD_Pin SPI_RESET_Pin */
346
  GPIO_InitStruct.Pin = SPI_NSS1_Pin|SPI_CD_Pin;
366
  GPIO_InitStruct.Pin = SPI_CD_Pin|SPI_RESET_Pin;
347
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
367
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
348
  GPIO_InitStruct.Pull = GPIO_NOPULL;
368
  GPIO_InitStruct.Pull = GPIO_NOPULL;
349
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
369
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
350
  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
370
  HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
351
 
371
 
352
  /*Configure GPIO pin : SPI_RESET_Pin */
372
  /*Configure GPIO pin : SPI_NSS1_Pin */
353
  GPIO_InitStruct.Pin = SPI_RESET_Pin;
373
  GPIO_InitStruct.Pin = SPI_NSS1_Pin;
354
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
374
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
355
  GPIO_InitStruct.Pull = GPIO_NOPULL;
375
  GPIO_InitStruct.Pull = GPIO_NOPULL;
356
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
376
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
357
  HAL_GPIO_Init(SPI_RESET_GPIO_Port, &GPIO_InitStruct);
377
  HAL_GPIO_Init(SPI_NSS1_GPIO_Port, &GPIO_InitStruct);
358
 
378
 
359
}
379
}
360
 
380
 
361
/* USER CODE BEGIN 4 */
381
/* USER CODE BEGIN 4 */
362
 
382