1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
27
28
29
30
31
32
33
34
37
38
41
42
45
46
49
52
53
56
59
70
71
74
77
78
81
85
86
89
90
93
94
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
117
118
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
183
184
187
188
192
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
295
300
301
302
303
304
305
306
307
308
309
310
311
312
313
330
331
332
333
334
335
336
337
338
339
340
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
398
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
498
499
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
526
530
531
532
533
534
535
539
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
567
571
575
579
583
587
591
592
593
594
597
598
601
602
603
606
607
608
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
679
680
681
682
683
684
685
686
687
688
689
690
691
692
697
698
699
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
792
793
794
795
802
806
807
811
812
813
814
815
816
817
818
819
820
823
824
827
828
829
830
833
837
838
841
853
854
860
864
865
871
875
876
877
878
879
880
881
882
883
884
888
889
896
900
901
905
909
910
911
912
913
914
917
921
922
925
928
929
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
962
966
967
973
977
978
979
980
981
982
983
984
985
986
990
991
995
999
1000
1003
1006
1007
1010
1013
1014
1015
1016
1017
1018
1021
1025
1026
1029
1033
1034
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1076
1080
1081
1082
1083
1086
1090
1091
1097
1098
1099
1100
1101
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1120
1121
1122
1123
1124
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1144
1148
1149
1150
1151
1154
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1184
1185
1186
1187
1188
1189
1190
1191
1192
1196
1197
1198
1199
1203
1207
1208
1209
1210
1211
1212
1213
1214
1215
1219
1220
1221
1222
1223
1224
1225
1226
1227
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1258
1259
1263
1267
1268
1269
1273
1277
1278
1281
1282
1285
1286
1289
1290
/* ... */
/* ... */
#include "stm32469i_eval.h"
#if defined(USE_IOEXPANDER)
#include "stm32469i_eval_io.h"
#endif
/* ... */
/* ... */
/* ... */
/* ... */
/* ... */
/* ... */
/* ... */
#define __STM32469I_EVAL_BSP_VERSION_MAIN (0x02)
#define __STM32469I_EVAL_BSP_VERSION_SUB1 (0x01)
#define __STM32469I_EVAL_BSP_VERSION_SUB2 (0x02)
#define __STM32469I_EVAL_BSP_VERSION_RC (0x00)
#define __STM32469I_EVAL_BSP_VERSION ((__STM32469I_EVAL_BSP_VERSION_MAIN << 24)\
|(__STM32469I_EVAL_BSP_VERSION_SUB1 << 16)\
|(__STM32469I_EVAL_BSP_VERSION_SUB2 << 8 )\
|(__STM32469I_EVAL_BSP_VERSION_RC))...
5 defines
/* ... */
/* ... */
/* ... */
/* ... */
const uint32_t GPIO_PIN[LEDn] = {LED1_PIN,
LED2_PIN,
LED3_PIN,
LED4_PIN...};
GPIO_TypeDef* BUTTON_PORT[BUTTONn] = {WAKEUP_BUTTON_GPIO_PORT,
TAMPER_BUTTON_GPIO_PORT,
KEY_BUTTON_GPIO_PORT...};
const uint16_t BUTTON_PIN[BUTTONn] = {WAKEUP_BUTTON_PIN,
TAMPER_BUTTON_PIN,
KEY_BUTTON_PIN...};
const uint16_t BUTTON_IRQn[BUTTONn] = {WAKEUP_BUTTON_EXTI_IRQn,
TAMPER_BUTTON_EXTI_IRQn,
KEY_BUTTON_EXTI_IRQn...};
USART_TypeDef* COM_USART[COMn] = {EVAL_COM1};
GPIO_TypeDef* COM_TX_PORT[COMn] = {EVAL_COM1_TX_GPIO_PORT};
GPIO_TypeDef* COM_RX_PORT[COMn] = {EVAL_COM1_RX_GPIO_PORT};
const uint16_t COM_TX_PIN[COMn] = {EVAL_COM1_TX_PIN};
const uint16_t COM_RX_PIN[COMn] = {EVAL_COM1_RX_PIN};
const uint16_t COM_TX_AF[COMn] = {EVAL_COM1_TX_AF};
const uint16_t COM_RX_AF[COMn] = {EVAL_COM1_RX_AF};
static I2C_HandleTypeDef heval_I2c;
/* ... */
/* ... */
static void I2Cx_MspInit(void);
static void I2Cx_Init(void);
static void I2Cx_Write(uint8_t Addr, uint8_t Reg, uint8_t Value);
static uint8_t I2Cx_Read(uint8_t Addr, uint8_t Reg);
static HAL_StatusTypeDef I2Cx_ReadMultiple(uint8_t Addr, uint16_t Reg, uint16_t MemAddSize, uint8_t *Buffer, uint16_t Length);
static HAL_StatusTypeDef I2Cx_WriteMultiple(uint8_t Addr, uint16_t Reg, uint16_t MemAddSize, uint8_t *Buffer, uint16_t Length);
static HAL_StatusTypeDef I2Cx_IsDeviceReady(uint16_t DevAddress, uint32_t Trials);
static void I2Cx_Error(uint8_t Addr);
void IOE_Init(void);
void IOE_ITConfig(void);
void IOE_Delay(uint32_t Delay);
void IOE_Write(uint8_t Addr, uint8_t Reg, uint8_t Value);
uint8_t IOE_Read(uint8_t Addr, uint8_t Reg);
uint16_t IOE_ReadMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length);
void IOE_WriteMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length);
#if defined(USE_IOEXPANDER)
void MFX_IO_Init(void);
void MFX_IO_DeInit(void);
void MFX_IO_ITConfig(void);
void MFX_IO_Delay(uint32_t Delay);
void MFX_IO_Write(uint16_t Addr, uint8_t Reg, uint8_t Value);
uint8_t MFX_IO_Read(uint16_t Addr, uint8_t Reg);
uint16_t MFX_IO_ReadMultiple(uint16_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length);
void MFX_IO_Wakeup(void);
void MFX_IO_EnableWakeupPin(void);/* ... */
#endif
void AUDIO_IO_Init(void);
void AUDIO_IO_DeInit(void);
void AUDIO_IO_Write(uint8_t Addr, uint16_t Reg, uint16_t Value);
uint16_t AUDIO_IO_Read(uint8_t Addr, uint16_t Reg);
void AUDIO_IO_Delay(uint32_t Delay);
void CAMERA_IO_Init(void);
void CAMERA_Delay(uint32_t Delay);
void CAMERA_IO_Write(uint8_t Addr, uint16_t Reg, uint16_t Value);
uint16_t CAMERA_IO_Read(uint8_t Addr, uint16_t Reg);
void EEPROM_IO_Init(void);
HAL_StatusTypeDef EEPROM_IO_WriteData(uint16_t DevAddress, uint16_t MemAddress, uint8_t* pBuffer, uint32_t BufferSize);
HAL_StatusTypeDef EEPROM_IO_ReadData(uint16_t DevAddress, uint16_t MemAddress, uint8_t* pBuffer, uint32_t BufferSize);
HAL_StatusTypeDef EEPROM_IO_IsDeviceReady(uint16_t DevAddress, uint32_t Trials);
void TS_IO_Init(void);
void TS_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value);
uint8_t TS_IO_Read(uint8_t Addr, uint8_t Reg);
uint16_t TS_IO_ReadMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length);
void TS_IO_WriteMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length);
void TS_IO_Delay(uint32_t Delay);
void OTM8009A_IO_Delay(uint32_t Delay);
/* ... */
/* ... */
/* ... */
uint32_t BSP_GetVersion(void)
{
return __STM32469I_EVAL_BSP_VERSION;
}{ ... }
/* ... */
void BSP_LED_Init(Led_TypeDef Led)
{
#if !defined(USE_STM32469I_EVAL_REVA)
GPIO_InitTypeDef gpio_init_structure;
if (Led <= LED4)
{
LEDx_GPIO_CLK_ENABLE();
gpio_init_structure.Pin = GPIO_PIN[Led];
gpio_init_structure.Mode = GPIO_MODE_OUTPUT_PP;
gpio_init_structure.Pull = GPIO_PULLUP;
gpio_init_structure.Speed = GPIO_SPEED_HIGH;
HAL_GPIO_Init(LEDx_GPIO_PORT, &gpio_init_structure);
HAL_GPIO_WritePin(LEDx_GPIO_PORT, GPIO_PIN[Led], GPIO_PIN_SET);
}if (Led <= LED4) { ... }
/* ... */#else
#if defined(USE_IOEXPANDER)
BSP_IO_Init();
BSP_IO_ConfigPin(GPIO_PIN[Led], IO_MODE_OUTPUT_PP_PU);
BSP_IO_WritePin(GPIO_PIN[Led], BSP_IO_PIN_SET);/* ... */
#endif /* ... */
#endif
}{ ... }
/* ... */
void BSP_LED_DeInit(Led_TypeDef Led)
{
#if !defined(USE_STM32469I_EVAL_REVA)
GPIO_InitTypeDef gpio_init_structure;
if (Led <= LED4)
{
HAL_GPIO_WritePin(LEDx_GPIO_PORT, GPIO_PIN[Led], GPIO_PIN_RESET);
gpio_init_structure.Pin = GPIO_PIN[Led];
HAL_GPIO_DeInit(LEDx_GPIO_PORT, gpio_init_structure.Pin);
}if (Led <= LED4) { ... }
/* ... */#else
#if defined(USE_IOEXPANDER)
BSP_IO_ConfigPin(GPIO_PIN[Led], IO_MODE_OFF);/* ... */
#endif /* ... */
#endif
}{ ... }
/* ... */
void BSP_LED_On(Led_TypeDef Led)
{
#if !defined(USE_STM32469I_EVAL_REVA)
if (Led <= LED4)
{
HAL_GPIO_WritePin(LEDx_GPIO_PORT, GPIO_PIN[Led], GPIO_PIN_RESET);
}if (Led <= LED4) { ... }
/* ... */#else
#if defined(USE_IOEXPANDER)
BSP_IO_WritePin(GPIO_PIN[Led], BSP_IO_PIN_RESET);/* ... */
#endif /* ... */
#endif
}{ ... }
/* ... */
void BSP_LED_Off(Led_TypeDef Led)
{
#if !defined(USE_STM32469I_EVAL_REVA)
if (Led <= LED4)
{
HAL_GPIO_WritePin(LEDx_GPIO_PORT, GPIO_PIN[Led], GPIO_PIN_SET);
}if (Led <= LED4) { ... }
/* ... */#else
#if defined(USE_IOEXPANDER)
BSP_IO_WritePin(GPIO_PIN[Led], BSP_IO_PIN_SET);/* ... */
#endif /* ... */
#endif
}{ ... }
/* ... */
void BSP_LED_Toggle(Led_TypeDef Led)
{
#if !defined(USE_STM32469I_EVAL_REVA)
if (Led <= LED4)
{
HAL_GPIO_TogglePin(LEDx_GPIO_PORT, GPIO_PIN[Led]);
}if (Led <= LED4) { ... }
/* ... */#else
#if defined(USE_IOEXPANDER)
BSP_IO_TogglePin(GPIO_PIN[Led]);/* ... */
#endif /* ... */
#endif
}{ ... }
/* ... */
void BSP_PB_Init(Button_TypeDef Button, ButtonMode_TypeDef Button_Mode)
{
GPIO_InitTypeDef gpio_init_structure;
BUTTONx_GPIO_CLK_ENABLE(Button);
if(Button_Mode == BUTTON_MODE_GPIO)
{
gpio_init_structure.Pin = BUTTON_PIN[Button];
gpio_init_structure.Mode = GPIO_MODE_INPUT;
gpio_init_structure.Pull = GPIO_NOPULL;
gpio_init_structure.Speed = GPIO_SPEED_FAST;
HAL_GPIO_Init(BUTTON_PORT[Button], &gpio_init_structure);
}if (Button_Mode == BUTTON_MODE_GPIO) { ... }
if(Button_Mode == BUTTON_MODE_EXTI)
{
gpio_init_structure.Pin = BUTTON_PIN[Button];
gpio_init_structure.Pull = GPIO_NOPULL;
gpio_init_structure.Speed = GPIO_SPEED_FAST;
if(Button != BUTTON_WAKEUP)
{
gpio_init_structure.Mode = GPIO_MODE_IT_FALLING;
}if (Button != BUTTON_WAKEUP) { ... }
else
{
gpio_init_structure.Mode = GPIO_MODE_IT_RISING;
}else { ... }
HAL_GPIO_Init(BUTTON_PORT[Button], &gpio_init_structure);
HAL_NVIC_SetPriority((IRQn_Type)(BUTTON_IRQn[Button]), 0x0F, 0x00);
HAL_NVIC_EnableIRQ((IRQn_Type)(BUTTON_IRQn[Button]));
}if (Button_Mode == BUTTON_MODE_EXTI) { ... }
}{ ... }
/* ... */
void BSP_PB_DeInit(Button_TypeDef Button)
{
GPIO_InitTypeDef gpio_init_structure;
gpio_init_structure.Pin = BUTTON_PIN[Button];
HAL_NVIC_DisableIRQ((IRQn_Type)(BUTTON_IRQn[Button]));
HAL_GPIO_DeInit(BUTTON_PORT[Button], gpio_init_structure.Pin);
}{ ... }
/* ... */
uint32_t BSP_PB_GetState(Button_TypeDef Button)
{
return HAL_GPIO_ReadPin(BUTTON_PORT[Button], BUTTON_PIN[Button]);
}{ ... }
/* ... */
void BSP_COM_Init(COM_TypeDef COM, UART_HandleTypeDef *huart)
{
GPIO_InitTypeDef gpio_init_structure;
EVAL_COMx_TX_RX_GPIO_CLK_ENABLE(COM);
EVAL_COMx_CLK_ENABLE(COM);
gpio_init_structure.Pin = COM_TX_PIN[COM];
gpio_init_structure.Mode = GPIO_MODE_AF_PP;
gpio_init_structure.Pull = GPIO_PULLUP;
gpio_init_structure.Speed = GPIO_SPEED_HIGH;
gpio_init_structure.Alternate = COM_TX_AF[COM];
HAL_GPIO_Init(COM_TX_PORT[COM], &gpio_init_structure);
gpio_init_structure.Pin = COM_RX_PIN[COM];
HAL_GPIO_Init(COM_RX_PORT[COM], &gpio_init_structure);
huart->Instance = COM_USART[COM];
HAL_UART_Init(huart);
}{ ... }
/* ... */
void BSP_COM_DeInit(COM_TypeDef COM, UART_HandleTypeDef *huart)
{
huart->Instance = COM_USART[COM];
HAL_UART_DeInit(huart);
EVAL_COMx_CLK_DISABLE(COM);
/* ... */
/* ... */
}{ ... }
#if defined(USE_IOEXPANDER)
/* ... */
uint8_t BSP_JOY_Init(JOYMode_TypeDef Joy_Mode)
{
uint8_t ret = 0;
ret = BSP_IO_Init();
if(Joy_Mode == JOY_MODE_EXTI)
{
BSP_IO_ConfigPin(JOY_ALL_PINS, IO_MODE_IT_LOW_LEVEL_PU);
}if (Joy_Mode == JOY_MODE_EXTI) { ... }
else
{
BSP_IO_ConfigPin(JOY_ALL_PINS, IO_MODE_INPUT_PU);
}else { ... }
return ret;
}{ ... }
/* ... */
void BSP_JOY_DeInit()
{
BSP_IO_ConfigPin(JOY_ALL_PINS, IO_MODE_OFF);
}{ ... }
/* ... */
JOYState_TypeDef BSP_JOY_GetState(void)
{
uint16_t pin_status = 0;
pin_status = BSP_IO_ReadPin(JOY_ALL_PINS);
if((pin_status & JOY_NONE_PIN) == JOY_NONE)
{
return(JOYState_TypeDef) JOY_NONE;
}if ((pin_status & JOY_NONE_PIN) == JOY_NONE) { ... }
else if(!(pin_status & JOY_SEL_PIN))
{
return(JOYState_TypeDef) JOY_SEL;
}else if (!(pin_status & JOY_SEL_PIN)) { ... }
else if(!(pin_status & JOY_DOWN_PIN))
{
return(JOYState_TypeDef) JOY_DOWN;
}else if (!(pin_status & JOY_DOWN_PIN)) { ... }
else if(!(pin_status & JOY_LEFT_PIN))
{
return(JOYState_TypeDef) JOY_LEFT;
}else if (!(pin_status & JOY_LEFT_PIN)) { ... }
else if(!(pin_status & JOY_RIGHT_PIN))
{
return(JOYState_TypeDef) JOY_RIGHT;
}else if (!(pin_status & JOY_RIGHT_PIN)) { ... }
else if(!(pin_status & JOY_UP_PIN))
{
return(JOYState_TypeDef) JOY_UP;
}else if (!(pin_status & JOY_UP_PIN)) { ... }
else
{
return(JOYState_TypeDef) JOY_NONE;
}else { ... }
}{ ... }
#endif/* ... */
/* ... */
/* ... */
/* ... */
/* ... */
static void I2Cx_MspInit(void)
{
GPIO_InitTypeDef gpio_init_structure;
EVAL_I2Cx_SCL_SDA_GPIO_CLK_ENABLE();
gpio_init_structure.Pin = EVAL_I2Cx_SCL_PIN;
gpio_init_structure.Mode = GPIO_MODE_AF_OD;
gpio_init_structure.Pull = GPIO_NOPULL;
gpio_init_structure.Speed = GPIO_SPEED_FAST;
gpio_init_structure.Alternate = EVAL_I2Cx_SCL_SDA_AF;
HAL_GPIO_Init(EVAL_I2Cx_SCL_SDA_GPIO_PORT, &gpio_init_structure);
gpio_init_structure.Pin = EVAL_I2Cx_SDA_PIN;
HAL_GPIO_Init(EVAL_I2Cx_SCL_SDA_GPIO_PORT, &gpio_init_structure);
EVAL_I2Cx_CLK_ENABLE();
EVAL_I2Cx_FORCE_RESET();
EVAL_I2Cx_RELEASE_RESET();
HAL_NVIC_SetPriority(EVAL_I2Cx_EV_IRQn, 0x05, 0);
HAL_NVIC_EnableIRQ(EVAL_I2Cx_EV_IRQn);
HAL_NVIC_SetPriority(EVAL_I2Cx_ER_IRQn, 0x05, 0);
HAL_NVIC_EnableIRQ(EVAL_I2Cx_ER_IRQn);
}{ ... }
/* ... */
static void I2Cx_Init(void)
{
if(HAL_I2C_GetState(&heval_I2c) == HAL_I2C_STATE_RESET)
{
heval_I2c.Instance = I2C1;
heval_I2c.Init.ClockSpeed = I2C_SCL_FREQ_KHZ;
heval_I2c.Init.DutyCycle = I2C_DUTYCYCLE_2;
heval_I2c.Init.OwnAddress1 = 0;
heval_I2c.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
heval_I2c.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
heval_I2c.Init.OwnAddress2 = 0;
heval_I2c.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
heval_I2c.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
I2Cx_MspInit();
HAL_I2C_Init(&heval_I2c);
}if (HAL_I2C_GetState(&heval_I2c) == HAL_I2C_STATE_RESET) { ... }
}{ ... }
/* ... */
static void I2Cx_Write(uint8_t Addr, uint8_t Reg, uint8_t Value)
{
HAL_StatusTypeDef status = HAL_OK;
status = HAL_I2C_Mem_Write(&heval_I2c,
Addr,
(uint16_t)Reg,
I2C_MEMADD_SIZE_8BIT,
&Value,
1,
100);
if(status != HAL_OK)
{
I2Cx_Error(Addr);
}if (status != HAL_OK) { ... }
}{ ... }
/* ... */
static uint8_t I2Cx_Read(uint8_t Addr, uint8_t Reg)
{
HAL_StatusTypeDef status = HAL_OK;
uint8_t Value = 0;
status = HAL_I2C_Mem_Read(&heval_I2c,
Addr,
Reg,
I2C_MEMADD_SIZE_8BIT,
&Value,
1,
1000);
if(status != HAL_OK)
{
I2Cx_Error(Addr);
}if (status != HAL_OK) { ... }
return Value;
}{ ... }
/* ... */
static HAL_StatusTypeDef I2Cx_ReadMultiple(uint8_t Addr,
uint16_t Reg,
uint16_t MemAddress,
uint8_t *Buffer,
uint16_t Length)
{
HAL_StatusTypeDef status = HAL_OK;
status = HAL_I2C_Mem_Read(&heval_I2c,
Addr,
(uint16_t)Reg,
MemAddress,
Buffer,
Length,
1000);
if(status != HAL_OK)
{
I2Cx_Error(Addr);
}if (status != HAL_OK) { ... }
return status;
}{ ... }
/* ... */
static HAL_StatusTypeDef I2Cx_WriteMultiple(uint8_t Addr,
uint16_t Reg,
uint16_t MemAddress,
uint8_t *Buffer,
uint16_t Length)
{
HAL_StatusTypeDef status = HAL_OK;
status = HAL_I2C_Mem_Write(&heval_I2c,
Addr,
(uint16_t)Reg,
MemAddress,
Buffer,
Length,
1000);
if(status != HAL_OK)
{
I2Cx_Error(Addr);
}if (status != HAL_OK) { ... }
return status;
}{ ... }
/* ... */
static HAL_StatusTypeDef I2Cx_IsDeviceReady(uint16_t DevAddress, uint32_t Trials)
{
return (HAL_I2C_IsDeviceReady(&heval_I2c, DevAddress, Trials, 1000));
}{ ... }
/* ... */
static void I2Cx_Error(uint8_t Addr)
{
HAL_I2C_DeInit(&heval_I2c);
I2Cx_Init();
}{ ... }
/* ... */
/* ... */
I2C Routines
/* ... */
void IOE_Init(void)
{
I2Cx_Init();
}{ ... }
/* ... */
void IOE_ITConfig(void)
{
static uint8_t IOE_IT_Enabled = 0;
if(IOE_IT_Enabled == 0)
{
IOE_IT_Enabled = 1;
}if (IOE_IT_Enabled == 0) { ... }
}{ ... }
/* ... */
void IOE_Write(uint8_t Addr, uint8_t Reg, uint8_t Value)
{
I2Cx_Write(Addr, Reg, Value);
}{ ... }
/* ... */
uint8_t IOE_Read(uint8_t Addr, uint8_t Reg)
{
return I2Cx_Read(Addr, Reg);
}{ ... }
/* ... */
uint16_t IOE_ReadMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length)
{
return I2Cx_ReadMultiple(Addr, (uint16_t)Reg, I2C_MEMADD_SIZE_8BIT, Buffer, Length);
}{ ... }
/* ... */
void IOE_WriteMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length)
{
I2Cx_WriteMultiple(Addr, (uint16_t)Reg, I2C_MEMADD_SIZE_8BIT, Buffer, Length);
}{ ... }
/* ... */
void IOE_Delay(uint32_t Delay)
{
HAL_Delay(Delay);
}{ ... }
#if defined(USE_IOEXPANDER)
/* ... */
void MFX_IO_Init(void)
{
I2Cx_Init();
}{ ... }
/* ... */
void MFX_IO_DeInit(void)
{
}{ ... }
/* ... */
void MFX_IO_ITConfig(void)
{
static uint8_t MFX_IO_IT_Enabled = 0;
GPIO_InitTypeDef gpio_init_structure;
if(MFX_IO_IT_Enabled == 0)
{
MFX_IO_IT_Enabled = 1;
__HAL_RCC_GPIOI_CLK_ENABLE();
__HAL_RCC_SYSCFG_CLK_ENABLE();
gpio_init_structure.Pin = GPIO_PIN_8;
gpio_init_structure.Pull = GPIO_NOPULL;
gpio_init_structure.Speed = GPIO_SPEED_LOW;
gpio_init_structure.Mode = GPIO_MODE_IT_RISING;
HAL_GPIO_Init(GPIOI, &gpio_init_structure);
HAL_NVIC_SetPriority((IRQn_Type)(EXTI9_5_IRQn), 0x0F, 0x0F);
HAL_NVIC_EnableIRQ((IRQn_Type)(EXTI9_5_IRQn));
}if (MFX_IO_IT_Enabled == 0) { ... }
}{ ... }
/* ... */
void MFX_IO_Write(uint16_t Addr, uint8_t Reg, uint8_t Value)
{
I2Cx_Write((uint8_t) Addr, Reg, Value);
}{ ... }
/* ... */
uint8_t MFX_IO_Read(uint16_t Addr, uint8_t Reg)
{
return I2Cx_Read((uint8_t) Addr, Reg);
}{ ... }
/* ... */
uint16_t MFX_IO_ReadMultiple(uint16_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length)
{
return I2Cx_ReadMultiple((uint8_t)Addr, (uint16_t)Reg, I2C_MEMADD_SIZE_8BIT, Buffer, Length);
}{ ... }
/* ... */
void MFX_IO_Delay(uint32_t Delay)
{
HAL_Delay(Delay);
}{ ... }
/* ... */
void MFX_IO_Wakeup(void)
{
}{ ... }
/* ... */
void MFX_IO_EnableWakeupPin(void)
{
}{ ... }
/* ... */#endif
/* ... */
void AUDIO_IO_Init(void)
{
I2Cx_Init();
}{ ... }
/* ... */
void AUDIO_IO_DeInit(void)
{
}{ ... }
/* ... */
void AUDIO_IO_Write(uint8_t Addr, uint16_t Reg, uint16_t Value)
{
uint16_t tmp = Value;
Value = ((uint16_t)(tmp >> 8) & 0x00FF);
Value |= ((uint16_t)(tmp << 8)& 0xFF00);
I2Cx_WriteMultiple(Addr, Reg, I2C_MEMADD_SIZE_16BIT,(uint8_t*)&Value, 2);
}{ ... }
/* ... */
uint16_t AUDIO_IO_Read(uint8_t Addr, uint16_t Reg)
{
uint16_t read_value = 0, tmp = 0;
I2Cx_ReadMultiple(Addr, Reg, I2C_MEMADD_SIZE_16BIT, (uint8_t*)&read_value, 2);
tmp = ((uint16_t)(read_value >> 8) & 0x00FF);
tmp |= ((uint16_t)(read_value << 8)& 0xFF00);
read_value = tmp;
return read_value;
}{ ... }
/* ... */
void AUDIO_IO_Delay(uint32_t Delay)
{
HAL_Delay(Delay);
}{ ... }
LINK AUDIO
/* ... */
void CAMERA_IO_Init(void)
{
I2Cx_Init();
}{ ... }
/* ... */
void CAMERA_IO_Write(uint8_t Addr, uint16_t Reg, uint16_t Value)
{
uint16_t tmp = Value;
if(Addr == CAMERA_I2C_ADDRESS_2)
{
I2Cx_WriteMultiple(Addr, Reg, I2C_MEMADD_SIZE_16BIT,(uint8_t*)&Value, 1);
}if (Addr == CAMERA_I2C_ADDRESS_2) { ... }
else
{
Value = ((uint16_t)(tmp >> 8) & 0x00FF);
Value |= ((uint16_t)(tmp << 8)& 0xFF00);
I2Cx_WriteMultiple(Addr, Reg, I2C_MEMADD_SIZE_16BIT,(uint8_t*)&Value, 2);
}else { ... }
}{ ... }
/* ... */
uint16_t CAMERA_IO_Read(uint8_t Addr, uint16_t Reg)
{
uint16_t read_value = 0, tmp = 0;
if(Addr == CAMERA_I2C_ADDRESS_2)
{
I2Cx_ReadMultiple(Addr , Reg, I2C_MEMADD_SIZE_16BIT, (uint8_t*)&read_value, 1);
}if (Addr == CAMERA_I2C_ADDRESS_2) { ... }
else
{
I2Cx_ReadMultiple(Addr, Reg, I2C_MEMADD_SIZE_16BIT, (uint8_t*)&read_value, 2);
tmp = ((uint16_t)(read_value >> 8) & 0x00FF);
tmp |= ((uint16_t)(read_value << 8)& 0xFF00);
read_value = tmp;
}else { ... }
return read_value;
}{ ... }
/* ... */
void CAMERA_Delay(uint32_t Delay)
{
HAL_Delay(Delay);
}{ ... }
LINK CAMERA
/* ... */
void EEPROM_IO_Init(void)
{
I2Cx_Init();
}{ ... }
/* ... */
HAL_StatusTypeDef EEPROM_IO_WriteData(uint16_t DevAddress, uint16_t MemAddress, uint8_t* pBuffer, uint32_t BufferSize)
{
return (I2Cx_WriteMultiple(DevAddress, MemAddress, I2C_MEMADD_SIZE_16BIT, pBuffer, BufferSize));
}{ ... }
/* ... */
HAL_StatusTypeDef EEPROM_IO_ReadData(uint16_t DevAddress, uint16_t MemAddress, uint8_t* pBuffer, uint32_t BufferSize)
{
return (I2Cx_ReadMultiple(DevAddress, MemAddress, I2C_MEMADD_SIZE_16BIT, pBuffer, BufferSize));
}{ ... }
/* ... */
HAL_StatusTypeDef EEPROM_IO_IsDeviceReady(uint16_t DevAddress, uint32_t Trials)
{
return (I2Cx_IsDeviceReady(DevAddress, Trials));
}{ ... }
LINK I2C EEPROM
/* ... */
void TS_IO_Init(void)
{
I2Cx_Init();
}{ ... }
/* ... */
void TS_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value)
{
I2Cx_Write(Addr, Reg, Value);
}{ ... }
/* ... */
uint8_t TS_IO_Read(uint8_t Addr, uint8_t Reg)
{
return I2Cx_Read(Addr, Reg);
}{ ... }
/* ... */
uint16_t TS_IO_ReadMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length)
{
return I2Cx_ReadMultiple(Addr, (uint16_t)Reg, I2C_MEMADD_SIZE_8BIT, Buffer, Length);
}{ ... }
/* ... */
void TS_IO_WriteMultiple(uint8_t Addr, uint8_t Reg, uint8_t *Buffer, uint16_t Length)
{
I2Cx_WriteMultiple(Addr, (uint16_t)Reg, I2C_MEMADD_SIZE_8BIT, Buffer, Length);
}{ ... }
/* ... */
void TS_IO_Delay(uint32_t Delay)
{
HAL_Delay(Delay);
}{ ... }
LINK TS (TouchScreen)
/* ... */
void OTM8009A_IO_Delay(uint32_t Delay)
{
HAL_Delay(Delay);
}{ ... }
/* ... */
/* ... */
/* ... */
/* ... */