keycontrol_ll.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575
  1. #include "drivers/keycontrol/keycontrol_ll.h"
  2. #include "drivers/keycontrol/keycontrol_ll_encoding.h"
  3. #include "core/gpio.h"
  4. #include "core/csect.h"
  5. #include "core/config_pins.h"
  6. #include "core/main.h" // HAL_Wait_us
  7. #include <stdint.h>
  8. #include <stddef.h>
  9. #define SUPPORT_SERIAL_REGISTER_1 0
  10. #define SUPPORT_SERIAL_REGISTER_2 0
  11. // LowLevel KeyControl version ACM2543.1
  12. //
  13. // [3] [4] VDD VSS | Logic Port Desc
  14. // HEADER #1 (o) (o) (o) (o) | PCB HOLE
  15. // *p1 *p2 *p3 *p4 | Legend index
  16. // -----------------------------------------------------+
  17. // VSS VDD [1] [2] | Logic Port Desc
  18. // HEADER #2 (o) (o) (o) (o) | PCB HOLE
  19. // *p5 *p6 *p7 *p8 | Legend index
  20. // Legend:
  21. // p1 - ST_VCTRL1_ADRF3_1, #12, PA2, [Line3]
  22. // p2 - ST_VCTRL2_ADRF3_1, #11, PA1, [Line4]
  23. // p3 - VDD_ADRF3_1
  24. // p4 - VSS_ADRF4_1
  25. // p5 - VSS_ADRF3_1
  26. // p6 - VDD_ADRF4_1
  27. // p7 - ST_VCTRL1_ADRF4_1, #39, PB3, [Line1]
  28. // p8 - ST_VCTRL2_ADRF4_1, #40, PB4, [Line2]
  29. static bool KeySwitch_Init( eKeySwitchControlMode_t mode );
  30. static bool KeySwitch_SetKeyCode( tKeySwitchCode_t code );
  31. static bool AmpSwitch_SetAmpCode( tKeySwitchCode_t code );
  32. static bool FiltSwitch_SetFiltCode( tKeySwitchCode_t code );
  33. static bool KeySwitch_SetKeyCodeParallel( tKeySwitchCode_t code );
  34. static bool KeySwitch_SetKeyCodeSerial( tKeySwitchCode_t code );
  35. static bool BandSwitch_SetBandCodeParallel( tKeySwitchCode_t code );
  36. static bool GainSwitch_SetGainCodeParallel( tKeySwitchCode_t code );
  37. #if SUPPORT_SERIAL_REGISTER_1
  38. static bool KeySwitch_SetKeyCodeSerial_Register1( tKeySwitchCode_t code );
  39. #endif
  40. #if SUPPORT_SERIAL_REGISTER_2
  41. static bool KeySwitch_SetKeyCodeSerial_Register2( tKeySwitchCode_t code );
  42. #endif
  43. static bool KeySwitch_GetKeyCode( tKeySwitchCode_t * pcode );
  44. static bool AmpSwitch_GetAmpCode( tKeySwitchCode_t * pcode );
  45. static bool FiltSwitch_GetFiltCode( tKeySwitchCode_t * pcode );
  46. static void KeySwitch_DeInit();
  47. static tKeySwitchCode_t keyCode = 0;
  48. static bool bInitialized = false;
  49. static eKeySwitchControlMode_t xMode = eSwCtlMode_default;
  50. typedef enum
  51. {
  52. eLLKeySw_IOLine_1,
  53. eLLKeySw_IOLine_2,
  54. eLLKeySw_IOLine_3,
  55. eLLKeySw_IOLine_4,
  56. eLLKeySw_IOLine_5,
  57. eLLKeySw_IOLine_6,
  58. }
  59. e_LLKeySwitch_IOLines_t;
  60. #if SUPPORT_SERIAL_REGISTER_1
  61. #define Register1_IOLine_Shift (eLLKeySw_IOLine_3)
  62. #define Register1_IOLine_Store (eLLKeySw_IOLine_2)
  63. #define Register1_IOLine_Data (eLLKeySw_IOLine_1)
  64. #endif
  65. #if SUPPORT_SERIAL_REGISTER_2
  66. #define Register2_IOLine_Shift (eLLKeySw_IOLine_3)
  67. #define Register2_IOLine_Store (eLLKeySw_IOLine_2)
  68. #define Register2_IOLine_Data (eLLKeySw_IOLine_1)
  69. #endif
  70. static void LL_KeySwitch_SetIOLine( e_LLKeySwitch_IOLines_t port, bool state );
  71. const sKeySwitchControlLL_t KeyControlLLHandle =
  72. {
  73. .Init = KeySwitch_Init,
  74. .SetKeyCode = KeySwitch_SetKeyCode,
  75. .SetAmpCode = AmpSwitch_SetAmpCode,
  76. .SetFiltCode = FiltSwitch_SetFiltCode,
  77. .GetKeyCode = KeySwitch_GetKeyCode,
  78. .GetAmpCode = AmpSwitch_GetAmpCode,
  79. .GetFiltCode = FiltSwitch_GetFiltCode,
  80. .DeInit = KeySwitch_DeInit
  81. };
  82. static bool KeySwitch_Init( eKeySwitchControlMode_t mode )
  83. {
  84. DI();
  85. xMode = mode;
  86. // Configure GPIO pins for KeySwitch control
  87. #if CONFIG_PORT__SINGLEPORTINIT
  88. {
  89. GPIO_InitTypeDef GPIO_InitStruct = {0};
  90. switch(xMode)
  91. {
  92. case eSwCtlMode_6line:
  93. GPIO_InitStruct.Pin = CONFIG_PIN__SWKEYPP_L1|CONFIG_PIN__SWKEYPP_L2|CONFIG_PIN__SWKEYPP_L3|CONFIG_PIN__SWKEYPP_L4|CONFIG_PIN__SWKEYPP_L5|CONFIG_PIN__SWKEYPP_L6;
  94. break;
  95. case eSwCtlMode_4line:
  96. default:
  97. GPIO_InitStruct.Pin = CONFIG_PIN__SWKEYPP_L1|CONFIG_PIN__SWKEYPP_L2|CONFIG_PIN__SWKEYPP_L3|CONFIG_PIN__SWKEYPP_L4;
  98. break;
  99. }
  100. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  101. GPIO_InitStruct.Pull = GPIO_NOPULL;
  102. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  103. HAL_GPIO_Init(CONFIG_PORT__SWKEYPP_L1, &GPIO_InitStruct);
  104. }
  105. #else
  106. {
  107. GPIO_InitTypeDef GPIO_InitStruct = {0};
  108. GPIO_InitStruct.Pin = CONFIG_PIN__SWKEYPP_L1;
  109. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  110. GPIO_InitStruct.Pull = GPIO_NOPULL;
  111. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  112. HAL_GPIO_Init(CONFIG_PORT__SWKEYPP_L1, &GPIO_InitStruct);
  113. }
  114. {
  115. GPIO_InitTypeDef GPIO_InitStruct = {0};
  116. GPIO_InitStruct.Pin = CONFIG_PIN__SWKEYPP_L2;
  117. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  118. GPIO_InitStruct.Pull = GPIO_NOPULL;
  119. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  120. HAL_GPIO_Init(CONFIG_PORT__SWKEYPP_L2, &GPIO_InitStruct);
  121. }
  122. {
  123. GPIO_InitTypeDef GPIO_InitStruct = {0};
  124. GPIO_InitStruct.Pin = CONFIG_PIN__SWKEYPP_L3;
  125. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  126. GPIO_InitStruct.Pull = GPIO_NOPULL;
  127. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  128. HAL_GPIO_Init(CONFIG_PORT__SWKEYPP_L3, &GPIO_InitStruct);
  129. }
  130. {
  131. GPIO_InitTypeDef GPIO_InitStruct = {0};
  132. GPIO_InitStruct.Pin = CONFIG_PIN__SWKEYPP_L4;
  133. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  134. GPIO_InitStruct.Pull = GPIO_NOPULL;
  135. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  136. HAL_GPIO_Init(CONFIG_PORT__SWKEYPP_L4, &GPIO_InitStruct);
  137. }
  138. if( xMode == eSwCtlMode_5line )
  139. {
  140. {
  141. GPIO_InitTypeDef GPIO_InitStruct = {0};
  142. GPIO_InitStruct.Pin = CONFIG_PIN__SWKEYPP_L5;
  143. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  144. GPIO_InitStruct.Pull = GPIO_NOPULL;
  145. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  146. HAL_GPIO_Init(CONFIG_PORT__SWKEYPP_L5, &GPIO_InitStruct);
  147. }
  148. }
  149. if( xMode == eSwCtlMode_6line )
  150. {
  151. {
  152. GPIO_InitTypeDef GPIO_InitStruct = {0};
  153. GPIO_InitStruct.Pin = CONFIG_PIN__SWKEYPP_L5;
  154. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  155. GPIO_InitStruct.Pull = GPIO_NOPULL;
  156. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  157. HAL_GPIO_Init(CONFIG_PORT__SWKEYPP_L5, &GPIO_InitStruct);
  158. }
  159. {
  160. GPIO_InitTypeDef GPIO_InitStruct = {0};
  161. GPIO_InitStruct.Pin = CONFIG_PIN__SWKEYPP_L6;
  162. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  163. GPIO_InitStruct.Pull = GPIO_NOPULL;
  164. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  165. HAL_GPIO_Init(CONFIG_PORT__SWKEYPP_L6, &GPIO_InitStruct);
  166. }
  167. }
  168. #endif
  169. bInitialized = true;
  170. EI();
  171. return true;
  172. }
  173. static bool KeySwitch_SetKeyCode( tKeySwitchCode_t code )
  174. {
  175. // Check the control type:
  176. if( CHECK_CONTROL_TYPE_REGISTER( code ) )
  177. {
  178. // Serial control (registers)
  179. return KeySwitch_SetKeyCodeSerial( code );
  180. }
  181. // Parallel control
  182. return KeySwitch_SetKeyCodeParallel( code );
  183. }
  184. static bool AmpSwitch_SetAmpCode( tKeySwitchCode_t code )
  185. {
  186. // Check the control type:
  187. if( CHECK_CONTROL_TYPE_REGISTER( code ) )
  188. {
  189. // Serial control (registers)
  190. return KeySwitch_SetKeyCodeSerial( code );
  191. }
  192. // Parallel control
  193. return GainSwitch_SetGainCodeParallel( code );
  194. }
  195. static bool FiltSwitch_SetFiltCode( tKeySwitchCode_t code )
  196. {
  197. // Check the control type:
  198. if( CHECK_CONTROL_TYPE_REGISTER( code ) )
  199. {
  200. // Serial control (registers)
  201. return KeySwitch_SetKeyCodeSerial( code );
  202. }
  203. // Parallel control
  204. return BandSwitch_SetBandCodeParallel( code );
  205. }
  206. static bool KeySwitch_SetKeyCodeParallel( tKeySwitchCode_t code )
  207. {
  208. bool set = true;
  209. DI();
  210. if( bInitialized )
  211. {
  212. // IOLine#1 = code.bit[6]
  213. // IOLine#2 = code.bit[7]
  214. // IOLine#3 = code.bit[8]
  215. // IOLine#4 = code.bit[9]
  216. LL_KeySwitch_SetIOLine( eLLKeySw_IOLine_1, (code & (1ul<<6)) );
  217. LL_KeySwitch_SetIOLine( eLLKeySw_IOLine_2, (code & (1ul<<7)) );
  218. LL_KeySwitch_SetIOLine( eLLKeySw_IOLine_3, (code & (1ul<<8)) );
  219. LL_KeySwitch_SetIOLine( eLLKeySw_IOLine_4, (code & (1ul<<9)) );
  220. if(xMode == eSwCtlMode_5line)
  221. {
  222. LL_KeySwitch_SetIOLine( eLLKeySw_IOLine_5, (code & (1ul<<10)));
  223. }
  224. if(xMode == eSwCtlMode_6line )
  225. {
  226. LL_KeySwitch_SetIOLine( eLLKeySw_IOLine_5, (code & (1ul<<10)));
  227. LL_KeySwitch_SetIOLine( eLLKeySw_IOLine_6, (code & (1ul<<11)));
  228. }
  229. keyCode = code;
  230. }
  231. else
  232. {
  233. set = false;
  234. }
  235. EI();
  236. return set;
  237. }
  238. static bool BandSwitch_SetBandCodeParallel( tKeySwitchCode_t code )
  239. {
  240. bool set = true;
  241. DI();
  242. if( bInitialized )
  243. {
  244. LL_KeySwitch_SetIOLine( eLLKeySw_IOLine_1, (code & (1ul<<6)) ); // CTRL-ADRFV1_ON
  245. LL_KeySwitch_SetIOLine( eLLKeySw_IOLine_2, (code & (1ul<<7)) ); // CTRL-ADRFV2_ON
  246. keyCode = code;
  247. }
  248. else
  249. {
  250. set = false;
  251. }
  252. EI();
  253. return set;
  254. }
  255. static bool GainSwitch_SetGainCodeParallel( tKeySwitchCode_t code )
  256. {
  257. bool set = true;
  258. DI();
  259. if( bInitialized )
  260. {
  261. LL_KeySwitch_SetIOLine( eLLKeySw_IOLine_3, (code & (1ul<<8)) ); // CTRL-HMCV1_ON
  262. LL_KeySwitch_SetIOLine( eLLKeySw_IOLine_4, (code & (1ul<<9)) ); // CTRL-HMCV2_ON
  263. if(xMode == eSwCtlMode_5line)
  264. {
  265. LL_KeySwitch_SetIOLine( eLLKeySw_IOLine_5, (code & (1ul<<10))); // CTRL-HMCV3_ON
  266. }
  267. keyCode = code;
  268. }
  269. else
  270. {
  271. set = false;
  272. }
  273. EI();
  274. return set;
  275. }
  276. #if SUPPORT_SERIAL_REGISTER_1
  277. static bool KeySwitch_SetKeyCodeSerial_Register1( tKeySwitchCode_t code )
  278. {
  279. // Idle
  280. __DI__
  281. LL_KeySwitch_SetIOLine( Register1_IOLine_Shift, false );
  282. LL_KeySwitch_SetIOLine( Register1_IOLine_Store, false );
  283. LL_KeySwitch_SetIOLine( Register1_IOLine_Data, false );
  284. __EI__
  285. // DataOut
  286. uint8_t value = GET_CONTROL_REGISTER_1( code );
  287. for( int32_t i = 7; i>=0; i-- )
  288. {
  289. LL_KeySwitch_SetIOLine( Register1_IOLine_Shift, false );
  290. LL_KeySwitch_SetIOLine( Register1_IOLine_Data, (value & (1ul<<i)) );
  291. HAL_Wait_us( SystemCoreClock / 1000000 ); // 1MHz
  292. LL_KeySwitch_SetIOLine( Register1_IOLine_Shift, true );
  293. HAL_Wait_us( SystemCoreClock / 1000000 ); // 1MHz
  294. LL_KeySwitch_SetIOLine( Register1_IOLine_Shift, false );
  295. }
  296. // Store
  297. __DI__
  298. HAL_Wait_us( SystemCoreClock / 1000000 ); // 1MHz
  299. LL_KeySwitch_SetIOLine( Register1_IOLine_Store, true );
  300. HAL_Wait_us( SystemCoreClock / 1000000 ); // 1MHz
  301. LL_KeySwitch_SetIOLine( Register1_IOLine_Store, false );
  302. __EI__
  303. // Idle
  304. __DI__
  305. LL_KeySwitch_SetIOLine( Register1_IOLine_Shift, false );
  306. LL_KeySwitch_SetIOLine( Register1_IOLine_Store, false );
  307. LL_KeySwitch_SetIOLine( Register1_IOLine_Data, false );
  308. __EI__
  309. return true;
  310. }
  311. #endif
  312. #if SUPPORT_SERIAL_REGISTER_2
  313. static bool KeySwitch_SetKeyCodeSerial_Register2( tKeySwitchCode_t code )
  314. {
  315. // Idle
  316. __DI__
  317. LL_KeySwitch_SetIOLine( Register2_IOLine_Shift, false );
  318. LL_KeySwitch_SetIOLine( Register2_IOLine_Store, false );
  319. LL_KeySwitch_SetIOLine( Register2_IOLine_Data, false );
  320. __EI__
  321. // DataOut
  322. uint8_t value = GET_CONTROL_REGISTER_2( code );
  323. for( int32_t i = 7; i>=0; i-- )
  324. {
  325. LL_KeySwitch_SetIOLine( Register2_IOLine_Shift, false );
  326. LL_KeySwitch_SetIOLine( Register2_IOLine_Data, (value & (1ul<<i)) );
  327. HAL_Wait_us( SystemCoreClock / 1000000 ); // 1MHz
  328. LL_KeySwitch_SetIOLine( Register2_IOLine_Shift, true );
  329. HAL_Wait_us( SystemCoreClock / 1000000 ); // 1MHz
  330. LL_KeySwitch_SetIOLine( Register2_IOLine_Shift, false );
  331. }
  332. // Store
  333. __DI__
  334. HAL_Wait_us( SystemCoreClock / 1000000 ); // 1MHz
  335. LL_KeySwitch_SetIOLine( Register2_IOLine_Store, true );
  336. HAL_Wait_us( SystemCoreClock / 1000000 ); // 1MHz
  337. LL_KeySwitch_SetIOLine( Register2_IOLine_Store, false );
  338. __EI__
  339. // Idle
  340. __DI__
  341. LL_KeySwitch_SetIOLine( Register2_IOLine_Shift, false );
  342. LL_KeySwitch_SetIOLine( Register2_IOLine_Store, false );
  343. LL_KeySwitch_SetIOLine( Register2_IOLine_Data, false );
  344. __EI__
  345. return true;
  346. }
  347. #endif
  348. static bool KeySwitch_SetKeyCodeSerial( tKeySwitchCode_t code )
  349. {
  350. bool set = true;
  351. DI();
  352. if( bInitialized )
  353. {
  354. EI();
  355. #if SUPPORT_SERIAL_REGISTER_1
  356. if( CHECK_CONTROL_REGISTER_1(code) )
  357. set = set && KeySwitch_SetKeyCodeSerial_Register1(code);
  358. #endif
  359. #if SUPPORT_SERIAL_REGISTER_2
  360. if( CHECK_CONTROL_REGISTER_2(code) )
  361. set = set && KeySwitch_SetKeyCodeSerial_Register2(code);
  362. #endif
  363. if( set )
  364. keyCode = code;
  365. }
  366. else
  367. {
  368. EI();
  369. set = false;
  370. }
  371. return set;
  372. }
  373. static void LL_KeySwitch_SetIOLine( e_LLKeySwitch_IOLines_t port, bool state )
  374. {
  375. switch( port )
  376. {
  377. // LogicPort #1
  378. case eLLKeySw_IOLine_1: HAL_GPIO_WritePin( CONFIG_PORT__SWKEYPP_L1, CONFIG_PIN__SWKEYPP_L1, ((state)?GPIO_PIN_SET:GPIO_PIN_RESET) );
  379. break;
  380. // LogicPort #2
  381. case eLLKeySw_IOLine_2: HAL_GPIO_WritePin( CONFIG_PORT__SWKEYPP_L2, CONFIG_PIN__SWKEYPP_L2, ((state)?GPIO_PIN_SET:GPIO_PIN_RESET) );
  382. break;
  383. // LogicPort #3
  384. case eLLKeySw_IOLine_3: HAL_GPIO_WritePin( CONFIG_PORT__SWKEYPP_L3, CONFIG_PIN__SWKEYPP_L3, ((state)?GPIO_PIN_SET:GPIO_PIN_RESET) );
  385. break;
  386. // LogicPort #4
  387. case eLLKeySw_IOLine_4: HAL_GPIO_WritePin( CONFIG_PORT__SWKEYPP_L4, CONFIG_PIN__SWKEYPP_L4, ((state)?GPIO_PIN_SET:GPIO_PIN_RESET) );
  388. break;
  389. // LogicPort #5
  390. case eLLKeySw_IOLine_5: HAL_GPIO_WritePin( CONFIG_PORT__SWKEYPP_L5, CONFIG_PIN__SWKEYPP_L5, ((state)?GPIO_PIN_SET:GPIO_PIN_RESET) );
  391. break;
  392. // LogicPort #6
  393. case eLLKeySw_IOLine_6: HAL_GPIO_WritePin( CONFIG_PORT__SWKEYPP_L6, CONFIG_PIN__SWKEYPP_L6, ((state)?GPIO_PIN_SET:GPIO_PIN_RESET) );
  394. break;
  395. }
  396. }
  397. static bool KeySwitch_GetKeyCode( tKeySwitchCode_t * pcode )
  398. {
  399. if( pcode )
  400. {
  401. __DI__ *pcode = keyCode; __EI__
  402. return true;
  403. }
  404. return false;
  405. }
  406. static bool AmpSwitch_GetAmpCode( tKeySwitchCode_t * pcode )
  407. {
  408. if( pcode )
  409. {
  410. __DI__ *pcode = keyCode; __EI__
  411. return true;
  412. }
  413. return false;
  414. }
  415. static bool FiltSwitch_GetFiltCode( tKeySwitchCode_t * pcode )
  416. {
  417. if( pcode )
  418. {
  419. __DI__ *pcode = keyCode; __EI__
  420. return true;
  421. }
  422. return false;
  423. }
  424. static void KeySwitch_DeInit()
  425. {
  426. DI();
  427. bInitialized = false;
  428. #if CONFIG_PORT__SINGLEPORTINIT
  429. {
  430. GPIO_InitTypeDef GPIO_InitStruct = {0};
  431. // Configure GPIO pins for KeySwitch control
  432. switch(xMode)
  433. {
  434. case eSwCtlMode_6line:
  435. GPIO_InitStruct.Pin = CONFIG_PIN__SWKEYPP_L1|CONFIG_PIN__SWKEYPP_L2|CONFIG_PIN__SWKEYPP_L3|CONFIG_PIN__SWKEYPP_L4|CONFIG_PIN__SWKEYPP_L5|CONFIG_PIN__SWKEYPP_L6;
  436. break;
  437. case eSwCtlMode_4line:
  438. default:
  439. GPIO_InitStruct.Pin = CONFIG_PIN__SWKEYPP_L1|CONFIG_PIN__SWKEYPP_L2|CONFIG_PIN__SWKEYPP_L3|CONFIG_PIN__SWKEYPP_L4;
  440. break;
  441. }
  442. }
  443. GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  444. GPIO_InitStruct.Pull = GPIO_NOPULL;
  445. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  446. HAL_GPIO_Init(CONFIG_PORT__SWKEYPP_L1, &GPIO_InitStruct);
  447. }
  448. #else
  449. {
  450. GPIO_InitTypeDef GPIO_InitStruct = {0};
  451. // Configure GPIO pins for KeySwitch control
  452. GPIO_InitStruct.Pin = CONFIG_PIN__SWKEYPP_L1;
  453. GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  454. GPIO_InitStruct.Pull = GPIO_NOPULL;
  455. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  456. HAL_GPIO_Init(CONFIG_PORT__SWKEYPP_L1, &GPIO_InitStruct);
  457. }
  458. {
  459. GPIO_InitTypeDef GPIO_InitStruct = {0};
  460. // Configure GPIO pins for KeySwitch control
  461. GPIO_InitStruct.Pin = CONFIG_PIN__SWKEYPP_L2;
  462. GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  463. GPIO_InitStruct.Pull = GPIO_NOPULL;
  464. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  465. HAL_GPIO_Init(CONFIG_PORT__SWKEYPP_L2, &GPIO_InitStruct);
  466. }
  467. {
  468. GPIO_InitTypeDef GPIO_InitStruct = {0};
  469. // Configure GPIO pins for KeySwitch control
  470. GPIO_InitStruct.Pin = CONFIG_PIN__SWKEYPP_L3;
  471. GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  472. GPIO_InitStruct.Pull = GPIO_NOPULL;
  473. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  474. HAL_GPIO_Init(CONFIG_PORT__SWKEYPP_L3, &GPIO_InitStruct);
  475. }
  476. {
  477. GPIO_InitTypeDef GPIO_InitStruct = {0};
  478. // Configure GPIO pins for KeySwitch control
  479. GPIO_InitStruct.Pin = CONFIG_PIN__SWKEYPP_L4;
  480. GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  481. GPIO_InitStruct.Pull = GPIO_NOPULL;
  482. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  483. HAL_GPIO_Init(CONFIG_PORT__SWKEYPP_L4, &GPIO_InitStruct);
  484. }
  485. if( xMode == eSwCtlMode_6line )
  486. {
  487. {
  488. GPIO_InitTypeDef GPIO_InitStruct = {0};
  489. // Configure GPIO pins for KeySwitch control
  490. GPIO_InitStruct.Pin = CONFIG_PIN__SWKEYPP_L5;
  491. GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  492. GPIO_InitStruct.Pull = GPIO_NOPULL;
  493. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  494. HAL_GPIO_Init(CONFIG_PORT__SWKEYPP_L5, &GPIO_InitStruct);
  495. }
  496. {
  497. GPIO_InitTypeDef GPIO_InitStruct = {0};
  498. // Configure GPIO pins for KeySwitch control
  499. GPIO_InitStruct.Pin = CONFIG_PIN__SWKEYPP_L6;
  500. GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  501. GPIO_InitStruct.Pull = GPIO_NOPULL;
  502. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  503. HAL_GPIO_Init(CONFIG_PORT__SWKEYPP_L6, &GPIO_InitStruct);
  504. }
  505. }
  506. #endif
  507. xMode = eSwCtlMode_default;
  508. EI();
  509. }