NNP STM Generic Remote Module git-main
Loading...
Searching...
No Matches
main.c
Go to the documentation of this file.
1/* USER CODE BEGIN Header */
18/* USER CODE END Header */
19/* Includes ------------------------------------------------------------------*/
20#include "main.h"
21
22/* Private includes ----------------------------------------------------------*/
23/* USER CODE BEGIN Includes */
24#include "eedata.h"
25#include "acceltemp.h"
26#include "app.h"
27
28/* USER CODE END Includes */
29
30/* Private typedef -----------------------------------------------------------*/
31/* USER CODE BEGIN PTD */
32
33/* USER CODE END PTD */
34
35/* Private define ------------------------------------------------------------*/
36/* USER CODE BEGIN PD */
37
38#define CO_ENABLE_LSS
39
40/* USER CODE END PD */
41
42/* Private macro -------------------------------------------------------------*/
43/* USER CODE BEGIN PM */
44
45/* USER CODE END PM */
46
47/* Private variables ---------------------------------------------------------*/
48ADC_HandleTypeDef hadc1;
49DMA_HandleTypeDef hdma_adc1;
50
51CAN_HandleTypeDef hcan1;
52
53I2C_HandleTypeDef hi2c2;
54
55TIM_HandleTypeDef htim2;
56
57/* USER CODE BEGIN PV */
58CAN_FilterTypeDef sFilterConfig;
59CAN_RxHeaderTypeDef RxHeader;
60CAN_TxHeaderTypeDef TxHeader;
61CAN_TxHeaderTypeDef TxHeaderSDO;
62CAN_TxHeaderTypeDef TxHeaderPDO;
63CAN_TxHeaderTypeDef TxHeaderScan;
64
65uint8_t RxData[8];
66uint8_t TxData[8];
67uint8_t TxDataSDO[8];
68uint8_t TxDataPDO[8];
69uint8_t TxDataScan[8];
70
71uint32_t TxMailbox;
72
73UNS16 blink = 0;
74UNS8 lastRequestedAddress = 0;
75
76/* USER CODE END PV */
77
78/* Private function prototypes -----------------------------------------------*/
79void SystemClock_Config(void);
80static void MX_GPIO_Init(void);
81static void MX_DMA_Init(void);
82static void MX_CAN1_Init(void);
83static void MX_TIM2_Init(void);
84static void MX_I2C2_Init(void);
85static void MX_ADC1_Init(void);
86/* USER CODE BEGIN PFP */
87
88void initNodeIDSerialNumber( void );
89void ReadMemory( void );
91UNS8 ReadEEProm(void);
92UNS8 WriteEEProm ( void );
93
94/* USER CODE END PFP */
95
96/* Private user code ---------------------------------------------------------*/
97/* USER CODE BEGIN 0 */
98
103{
104 setState(&ObjDict_Data, Waiting);
105}
106
111{
112 UNS8 node = *(uint8_t*)(127 * FLASH_PAGE_SIZE); // Config data lives in the last page of flash
113 if(node > 0 && node <= 0x7F)
114 Status_NodeId = node;
115
116 setNodeId(&ObjDict_Data, Status_NodeId);
117
118 ObjDict_obj1018_Serial_Number = *(uint8_t*)(0x08004FFD) << 8 | *(uint8_t*)(0x08004FFE);
119 ObjDict_obj1018_Product_Code = *(uint8_t*)(0x08004FFF);
120
121 HAL_Delay(START_DELAY_MS * (Status_NodeId - 1));
122}
123
124/* USER CODE END 0 */
125
130int main(void)
131{
132
133 /* USER CODE BEGIN 1 */
134
135 /* USER CODE END 1 */
136
137 /* MCU Configuration--------------------------------------------------------*/
138
139 /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
140 HAL_Init();
141
142 /* USER CODE BEGIN Init */
143 if (CheckRestoreFlag())
144 {
145 //Load custom settings from EEPROM into the OD
147 }
148 else
149 {
150 //Use default settings from OD rather than what is stored in EEPROM
151 //Then, overwrite EEPROM with these default settings
152 SaveValues();
153 }
154 /* USER CODE END Init */
155
156 /* Configure the system clock */
158
159 /* USER CODE BEGIN SysInit */
161
162 /* USER CODE END SysInit */
163
164 /* Initialize all configured peripherals */
165 MX_GPIO_Init();
166 MX_DMA_Init();
167 MX_CAN1_Init();
168 MX_TIM2_Init();
169 MX_I2C2_Init();
170 MX_ADC1_Init();
171 /* USER CODE BEGIN 2 */
172
175 initDiagnostics();
176 initAppTask();
177
178 /* USER CODE END 2 */
179
180 /* Infinite loop */
181 /* USER CODE BEGIN WHILE */
182 while (1)
183 {
185// updateTemperature(); //TODO: Check w/physical temp module
188 Status_TestValue++;
189
190 if(blink++ > 125){
191 if(getState(&ObjDict_Data) == Waiting)
192 {
193 ReadMemory();
194 }
195 blink = 0;
196 //TODO: Turn off heartbeat LED
197 //HAL_GPIO_WritePin();
198 }
199 else if(blink > 100)
200 {
201 //TODO: Turn on heartbeat LED
202 //HAL_GPIO_WritePin();
203 }
204
205 HAL_PWR_EnterSLEEPMode(PWR_MAINREGULATOR_ON, PWR_SLEEPENTRY_WFI);
206 /* USER CODE END WHILE */
207
208 /* USER CODE BEGIN 3 */
209 }
210 /* USER CODE END 3 */
211}
212
218{
219 RCC_OscInitTypeDef RCC_OscInitStruct = {0};
220 RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
221
224 if (HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1) != HAL_OK)
225 {
227 }
228
232 RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI|RCC_OSCILLATORTYPE_MSI;
233 RCC_OscInitStruct.HSIState = RCC_HSI_ON;
234 RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
235 RCC_OscInitStruct.MSIState = RCC_MSI_ON;
236 RCC_OscInitStruct.MSICalibrationValue = 0;
237 RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_8;
238 RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
239 if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
240 {
242 }
243
246 RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
247 |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
248 RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI;
249 RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV4;
250 RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
251 RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
252
253 if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK)
254 {
256 }
257}
258
264static void MX_ADC1_Init(void)
265{
266
267 /* USER CODE BEGIN ADC1_Init 0 */
268
269 /* USER CODE END ADC1_Init 0 */
270
271 ADC_ChannelConfTypeDef sConfig = {0};
272
273 /* USER CODE BEGIN ADC1_Init 1 */
274 __HAL_RCC_ADC_CLK_ENABLE(); // Enable ADC clock
275
276 /* USER CODE END ADC1_Init 1 */
277
280 hadc1.Instance = ADC1;
281 hadc1.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV256;
282 hadc1.Init.Resolution = ADC_RESOLUTION_8B;
283 hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT;
284 hadc1.Init.ScanConvMode = ADC_SCAN_ENABLE;
285 hadc1.Init.EOCSelection = ADC_EOC_SEQ_CONV;
286 hadc1.Init.LowPowerAutoWait = DISABLE;
287 hadc1.Init.ContinuousConvMode = DISABLE;
288 hadc1.Init.NbrOfConversion = 4;
289 hadc1.Init.DiscontinuousConvMode = DISABLE;
290 hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START;
291 hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
292 hadc1.Init.DMAContinuousRequests = DISABLE;
293 hadc1.Init.Overrun = ADC_OVR_DATA_OVERWRITTEN;
294 hadc1.Init.OversamplingMode = ENABLE;
295 hadc1.Init.Oversampling.Ratio = ADC_OVERSAMPLING_RATIO_16;
296 hadc1.Init.Oversampling.RightBitShift = ADC_RIGHTBITSHIFT_NONE;
297 hadc1.Init.Oversampling.TriggeredMode = ADC_TRIGGEREDMODE_SINGLE_TRIGGER;
298 hadc1.Init.Oversampling.OversamplingStopReset = ADC_REGOVERSAMPLING_CONTINUED_MODE;
299 if (HAL_ADC_Init(&hadc1) != HAL_OK)
300 {
302 }
303
306 sConfig.Channel = ADC_CHANNEL_1;
307 sConfig.Rank = ADC_REGULAR_RANK_1;
308 sConfig.SamplingTime = ADC_SAMPLETIME_2CYCLES_5;
309 sConfig.SingleDiff = ADC_SINGLE_ENDED;
310 sConfig.OffsetNumber = ADC_OFFSET_NONE;
311 sConfig.Offset = 0;
312 if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
313 {
315 }
316
319 sConfig.Channel = ADC_CHANNEL_2;
320 sConfig.Rank = ADC_REGULAR_RANK_2;
321 if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
322 {
324 }
325
328 sConfig.Channel = ADC_CHANNEL_3;
329 sConfig.Rank = ADC_REGULAR_RANK_3;
330 if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
331 {
333 }
334
337 sConfig.Channel = ADC_CHANNEL_4;
338 sConfig.Rank = ADC_REGULAR_RANK_4;
339 if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
340 {
342 }
343 /* USER CODE BEGIN ADC1_Init 2 */
344 HAL_ADCEx_Calibration_Start(&hadc1, ADC_SINGLE_ENDED); // Calibrate ADC before use
345 /* USER CODE END ADC1_Init 2 */
346
347}
348
354static void MX_CAN1_Init(void)
355{
356
357 /* USER CODE BEGIN CAN1_Init 0 */
358
359 /* USER CODE END CAN1_Init 0 */
360
361 /* USER CODE BEGIN CAN1_Init 1 */
362
363 /* USER CODE END CAN1_Init 1 */
364 hcan1.Instance = CAN1;
365 hcan1.Init.Prescaler = 4;
366 hcan1.Init.Mode = CAN_MODE_NORMAL;
367 hcan1.Init.SyncJumpWidth = CAN_SJW_1TQ;
368 hcan1.Init.TimeSeg1 = CAN_BS1_6TQ;
369 hcan1.Init.TimeSeg2 = CAN_BS2_3TQ;
370 hcan1.Init.TimeTriggeredMode = DISABLE;
371 hcan1.Init.AutoBusOff = DISABLE;
372 hcan1.Init.AutoWakeUp = DISABLE;
373 hcan1.Init.AutoRetransmission = ENABLE;
374 hcan1.Init.ReceiveFifoLocked = DISABLE;
375 hcan1.Init.TransmitFifoPriority = DISABLE;
376 if (HAL_CAN_Init(&hcan1) != HAL_OK)
377 {
379 }
380 /* USER CODE BEGIN CAN1_Init 2 */
381 sFilterConfig.FilterBank = 0;
382 sFilterConfig.FilterMode = CAN_FILTERMODE_IDMASK;
383 sFilterConfig.FilterScale = CAN_FILTERSCALE_32BIT;
384 sFilterConfig.FilterIdHigh = 0x0000;
385 sFilterConfig.FilterIdLow = 0x0000;
386 sFilterConfig.FilterMaskIdHigh = 0x0000;
387 sFilterConfig.FilterMaskIdLow = 0x0000;
388 sFilterConfig.FilterFIFOAssignment = CAN_RX_FIFO0;
389 sFilterConfig.FilterActivation = ENABLE;
390 sFilterConfig.SlaveStartFilterBank = 14;
391 if (HAL_CAN_ConfigFilter(&hcan1, &sFilterConfig) != HAL_OK)
392 {
393 /* Filter configuration Error */
395 }
396
397 HAL_CAN_Start(&hcan1);
398
399 HAL_CAN_ActivateNotification(&hcan1, CAN_IT_RX_FIFO0_MSG_PENDING);
400 HAL_CAN_ActivateNotification(&hcan1, CAN_IT_RX_FIFO1_MSG_PENDING);
401 HAL_CAN_ActivateNotification(&hcan1, CAN_IT_LAST_ERROR_CODE);
402 HAL_CAN_ActivateNotification(&hcan1, CAN_IT_ERROR);
403 HAL_CAN_ActivateNotification(&hcan1, CAN_IT_BUSOFF);
404 HAL_CAN_ActivateNotification(&hcan1, CAN_IT_ERROR_WARNING);
405 HAL_CAN_ActivateNotification(&hcan1, CAN_IT_ERROR_PASSIVE);
406
407 ObjDict_Data.canHandle = &hcan1;
408 canInit();
409 /* USER CODE END CAN1_Init 2 */
410
411}
412
418static void MX_I2C2_Init(void)
419{
420
421 /* USER CODE BEGIN I2C2_Init 0 */
422
423 /* USER CODE END I2C2_Init 0 */
424
425 /* USER CODE BEGIN I2C2_Init 1 */
426
427 /* USER CODE END I2C2_Init 1 */
428 hi2c2.Instance = I2C2;
429 hi2c2.Init.Timing = 0x00000000;
430 hi2c2.Init.OwnAddress1 = 0;
431 hi2c2.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
432 hi2c2.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
433 hi2c2.Init.OwnAddress2 = 0;
434 hi2c2.Init.OwnAddress2Masks = I2C_OA2_NOMASK;
435 hi2c2.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
436 hi2c2.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
437 if (HAL_I2C_Init(&hi2c2) != HAL_OK)
438 {
440 }
441
444 if (HAL_I2CEx_ConfigAnalogFilter(&hi2c2, I2C_ANALOGFILTER_ENABLE) != HAL_OK)
445 {
447 }
448
451 if (HAL_I2CEx_ConfigDigitalFilter(&hi2c2, 0) != HAL_OK)
452 {
454 }
455
458 HAL_I2CEx_EnableFastModePlus(I2C_FASTMODEPLUS_I2C2);
459 /* USER CODE BEGIN I2C2_Init 2 */
460
461 /* USER CODE END I2C2_Init 2 */
462
463}
464
470static void MX_TIM2_Init(void)
471{
472
473 /* USER CODE BEGIN TIM2_Init 0 */
474
475 /* USER CODE END TIM2_Init 0 */
476
477 TIM_ClockConfigTypeDef sClockSourceConfig = {0};
478 TIM_MasterConfigTypeDef sMasterConfig = {0};
479
480 /* USER CODE BEGIN TIM2_Init 1 */
481
482 /* USER CODE END TIM2_Init 1 */
483 htim2.Instance = TIM2;
484 htim2.Init.Prescaler = 39;
485 htim2.Init.CounterMode = TIM_COUNTERMODE_UP;
486 htim2.Init.Period = 65535;
487 htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
488 htim2.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_ENABLE;
489 if (HAL_TIM_Base_Init(&htim2) != HAL_OK)
490 {
492 }
493 sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
494 if (HAL_TIM_ConfigClockSource(&htim2, &sClockSourceConfig) != HAL_OK)
495 {
497 }
498 sMasterConfig.MasterOutputTrigger = TIM_TRGO_OC4REF;
499 sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
500 if (HAL_TIMEx_MasterConfigSynchronization(&htim2, &sMasterConfig) != HAL_OK)
501 {
503 }
504 /* USER CODE BEGIN TIM2_Init 2 */
505 if(HAL_TIM_Base_Start_IT(&htim2) != HAL_OK) {Error_Handler();}
506
507 CLEAR_BIT(TIM2->CR1, TIM_CR1_CEN); //Disable the timer
508 TIM2->CNT = 1; // Set count to 1
509
510 SetAlarm(NULL, 0, start_callback, 0, 0); // Begin the timer
511
512 /* USER CODE END TIM2_Init 2 */
513
514}
515
519static void MX_DMA_Init(void)
520{
521
522 /* DMA controller clock enable */
523 __HAL_RCC_DMA1_CLK_ENABLE();
524
525 /* DMA interrupt init */
526 /* DMA1_Channel1_IRQn interrupt configuration */
527 HAL_NVIC_SetPriority(DMA1_Channel1_IRQn, 0, 0);
528 HAL_NVIC_EnableIRQ(DMA1_Channel1_IRQn);
529
530}
531
537static void MX_GPIO_Init(void)
538{
539 GPIO_InitTypeDef GPIO_InitStruct = {0};
540 /* USER CODE BEGIN MX_GPIO_Init_1 */
541 /* USER CODE END MX_GPIO_Init_1 */
542
543 /* GPIO Ports Clock Enable */
544 __HAL_RCC_GPIOC_CLK_ENABLE();
545 __HAL_RCC_GPIOB_CLK_ENABLE();
546 __HAL_RCC_GPIOA_CLK_ENABLE();
547
548 /*Configure GPIO pin : I2C2_INT_Pin */
549 GPIO_InitStruct.Pin = I2C2_INT_Pin;
550 GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
551 GPIO_InitStruct.Pull = GPIO_NOPULL;
552 HAL_GPIO_Init(I2C2_INT_GPIO_Port, &GPIO_InitStruct);
553
554 /* USER CODE BEGIN MX_GPIO_Init_2 */
555 /* USER CODE END MX_GPIO_Init_2 */
556}
557
558/* USER CODE BEGIN 4 */
559
560
561
566void ReadMemory(void)
567{
568 // clear status
569 if (memorySelect > 0 )
570 statusByteMemory = 0;
571
572 if (memorySelect == 1)
573 statusByteMemory = ReadLocalFlashMemory();
574 else if (memorySelect == 4)
575 statusByteMemory = ReadEEProm();
576 else if (memorySelect == 8)
577 statusByteMemory = WriteEEProm();
578 else if (memorySelect != 0)
579 statusByteMemory = 4;
580
581 memorySelect = 0;
582}
588{
589 UNS8 RMDataSize = sizeof(ReadMemoryData);
590 UNS16 recordSize = FLASH_RECORD_SIZE;
591
592 if (AddressRequest > (FLASH_SIZE - recordSize))
593 return 2;
594
595 if (lastRequestedAddress != AddressRequest || (triggerReadMemory == 1))
596 {
597 // set pattern to clear if read
598 memset( ReadMemoryData, 0xA5, sizeof(ReadMemoryData));
599 ReadLocalFlashData( AddressRequest, ReadMemoryData, recordSize );
600 // now copy requested address into the top of the array
601 ReadMemoryData[RMDataSize - 4] = (UNS8) AddressRequest;
602 ReadMemoryData[RMDataSize - 3] = (UNS8)(AddressRequest >> 8);
603 ReadMemoryData[RMDataSize - 2] = (UNS8)(AddressRequest >> 16);
604 ReadMemoryData[RMDataSize - 1] = (UNS8)(AddressRequest >> 24);
605
606 lastRequestedAddress = AddressRequest;
607 triggerReadMemory = 0;
608 return 0;
609 }
610 return 1;
611}
618{
619 UNS8 RMDataSize = sizeof(ReadMemoryData);
620 UNS16 recordSize = EEPROM_RECORD_SIZE;
621
622 if (AddressRequest > (MAX_EEPROM_MEMORY - recordSize))
623 return 2;
624
625 if (lastRequestedAddress != AddressRequest || (triggerReadMemory == 1))
626 {
627 // set pattern to clear if read
628 memset( ReadMemoryData, 0xA5, sizeof(ReadMemoryData));
629 EEPROM_read( (UNS16)AddressRequest, ReadMemoryData, recordSize );
630 // now copy requested address into the top of the array
631 ReadMemoryData[RMDataSize - 4] = (UNS8) AddressRequest;
632 ReadMemoryData[RMDataSize - 3] = (UNS8)(AddressRequest >> 8);
633 ReadMemoryData[RMDataSize - 2] = (UNS8)(AddressRequest >> 16);
634 ReadMemoryData[RMDataSize - 1] = (UNS8)(AddressRequest >> 24);
635
636 lastRequestedAddress = AddressRequest;
637 triggerReadMemory = 0;
638 return 0;
639 }
640 return 1;
641}
642
649{
650 UNS8 status = 0;
651
652 if (AddressRequest > MAX_EEPROM_MEMORY) // nominal address space
653 {
654 return 2;
655 }
656 else
657 {
658 EEPROM_open();
659 EEPROM_write((UNS16)AddressRequest, &writeByteMemory, 1);
661 }
662
663 return status;
664
665}
666
667/* USER CODE END 4 */
668
674{
675 /* USER CODE BEGIN Error_Handler_Debug */
676 /* User can add his own implementation to report the HAL error return state */
677 __disable_irq();
678 while (1)
679 {
680 }
681 /* USER CODE END Error_Handler_Debug */
682}
683
684#ifdef USE_FULL_ASSERT
692void assert_failed(uint8_t *file, uint32_t line)
693{
694 /* USER CODE BEGIN 6 */
695 /* User can add his own implementation to report the file name and line number,
696 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
697 /* USER CODE END 6 */
698}
699#endif /* USE_FULL_ASSERT */
void updateDiagnostics(void)
If disgnostics is enabled, update their entries in the OD.
Definition acceltemp.c:501
void initAccelerometer(void)
Initializes Accelerometer.
Definition acceltemp.c:119
void updateAccelerometer(void)
update Accelerometer
Definition acceltemp.c:127
void initTemperature(void)
initializes thermometer to default configuration
Definition acceltemp.c:441
Header file for app.c.
#define UNS8
Unsigned int8 representation in CANFest.
Definition applicfg.h:25
#define UNS16
Unsigned int16 representation in CANFest.
Definition applicfg.h:26
#define UNS32
Unsigned int32 representation in CANFest.
Definition applicfg.h:27
#define MAX_EEPROM_MEMORY
(6KB)
Definition eedata.h:13
UNS8 CheckRestoreFlag(void)
checks whether or not RestoreValues() should be run.
Definition eedata.c:27
void EEPROM_write(UNS16 address, UNS8 *data, UNS16 length)
Writes bytes to a specified location in EEPROM.
Definition eedata.c:327
void RestoreValues(void)
Restores the values of custom OD entries (specified in RestoreList OD index 0x2900) to the OD from EE...
Definition eedata.c:117
void EEPROM_read(UNS16 address, UNS8 *data, UNS16 length)
Reads bytes from a specified location in EEPROM.
Definition eedata.c:343
UNS8 EEPROM_commit()
Commits edits to EEPROM from ram to flash.
Definition eedata.c:266
void SaveValues(void)
Saves the values of custom OD entries (specified in RestoreList OD index 0x2900) to EEPROM from the O...
Definition eedata.c:51
UNS8 ReadLocalFlashData(UNS32 nvAddress, UNS8 *data, UNS8 numData)
reads CPU based flash data
Definition eedata.c:205
UNS8 EEPROM_open()
Copies the EEPROM into ram for modification by EEPROM_write()
Definition eedata.c:252
void initAppTask(void)
Function called at the initialization of program.
Definition app.c:33
void updateAppTask()
Main application loop called from main.c.
Definition app.c:45
UNS8 setState(CO_Data *d, e_nodeState newState)
Change the state of the node.
Definition states.c:161
e_nodeState getState(CO_Data *d)
Returns the state of the node.
Definition states.c:32
void setNodeId(CO_Data *d, UNS8 nodeId)
Define the node ID. Initialize the object dictionary.
Definition states.c:261
TIMER_HANDLE SetAlarm(CO_Data *d, UNS32 id, TimerCallback_t callback, TIMEVAL value, TIMEVAL period)
Set an alarm to execute a callback function when expired.
Definition timer.c:37
UNS8 ReadLocalFlashMemory(void)
Read flash memory in CPU.
Definition main.c:587
void Error_Handler(void)
This function is executed in case of error occurrence.
Definition main.c:673
void initNodeIDSerialNumber(void)
Initializes node ID and serial number data in the object dictionary.
Definition main.c:110
void ReadMemory(void)
Command processor to let CE read various memory locations.
Definition main.c:566
void start_callback(CO_Data *d, UNS32 id)
Callback that runs at the beginning of timer execution.
Definition main.c:102
UNS8 WriteEEProm(void)
used with handshake through the OD at 0x2020 to allow remote writing of a single value in the emulate...
Definition main.c:648
void SystemClock_Config(void)
System Clock Configuration.
Definition main.c:217
int main(void)
The application entry point.
Definition main.c:130
UNS8 ReadEEProm(void)
used with handshake through the OD at 0x2020 to allow remote reading of values in the emulated eeprom...
Definition main.c:617
: Header for main.c file. This file contains the common defines of the application.
This structure contains all necessary informations to define a CANOpen node.
Definition data.h:44