Kiibohd Controller
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

lcd_scan.c 16KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644
  1. /* Copyright (C) 2015 by Jacob Alexander
  2. *
  3. * This file is free software: you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation, either version 3 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This file is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this file. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. // ----- Includes -----
  17. // Compiler Includes
  18. #include <Lib/ScanLib.h>
  19. // Project Includes
  20. #include <cli.h>
  21. #include <kll_defs.h>
  22. #include <led.h>
  23. #include <print.h>
  24. // Interconnect module if compiled in
  25. #if defined(ConnectEnabled_define)
  26. #include <connect_scan.h>
  27. #endif
  28. // Local Includes
  29. #include "lcd_scan.h"
  30. // ----- Defines -----
  31. #define LCD_TOTAL_VISIBLE_PAGES 4
  32. #define LCD_TOTAL_PAGES 9
  33. #define LCD_PAGE_LEN 128
  34. // ----- Macros -----
  35. // Number of entries in the SPI0 TxFIFO
  36. #define SPI0_TxFIFO_CNT ( ( SPI0_SR & SPI_SR_TXCTR ) >> 12 )
  37. // ----- Structs -----
  38. // ----- Function Declarations -----
  39. // CLI Functions
  40. void cliFunc_lcdCmd ( char* args );
  41. void cliFunc_lcdColor( char* args );
  42. void cliFunc_lcdDisp ( char* args );
  43. void cliFunc_lcdInit ( char* args );
  44. void cliFunc_lcdTest ( char* args );
  45. // ----- Variables -----
  46. // Default Image - Displays on startup
  47. const uint8_t STLcdDefaultImage[] = { STLcdDefaultImage_define };
  48. // Full Toggle State
  49. uint8_t cliFullToggleState = 0;
  50. // Normal/Reverse Toggle State
  51. uint8_t cliNormalReverseToggleState = 0;
  52. // Scan Module command dictionary
  53. CLIDict_Entry( lcdCmd, "Send byte via SPI, second argument enables a0. Defaults to control." );
  54. CLIDict_Entry( lcdColor, "Set backlight color. 3 16-bit numbers: R G B. i.e. 0xFFF 0x1444 0x32" );
  55. CLIDict_Entry( lcdDisp, "Write byte(s) to given page starting at given address. i.e. 0x1 0x5 0xFF 0x00" );
  56. CLIDict_Entry( lcdInit, "Re-initialize the LCD display." );
  57. CLIDict_Entry( lcdTest, "Test out the LCD display." );
  58. CLIDict_Def( lcdCLIDict, "ST LCD Module Commands" ) = {
  59. CLIDict_Item( lcdCmd ),
  60. CLIDict_Item( lcdColor ),
  61. CLIDict_Item( lcdDisp ),
  62. CLIDict_Item( lcdInit ),
  63. CLIDict_Item( lcdTest ),
  64. { 0, 0, 0 } // Null entry for dictionary end
  65. };
  66. // ----- Interrupt Functions -----
  67. // ----- Functions -----
  68. inline void SPI_setup()
  69. {
  70. // Enable SPI internal clock
  71. SIM_SCGC6 |= SIM_SCGC6_SPI0;
  72. // Setup MOSI (SOUT) and SCLK (SCK)
  73. PORTC_PCR6 = PORT_PCR_DSE | PORT_PCR_MUX(2);
  74. PORTC_PCR5 = PORT_PCR_DSE | PORT_PCR_MUX(2);
  75. // Setup SS (PCS)
  76. PORTC_PCR4 = PORT_PCR_DSE | PORT_PCR_MUX(2);
  77. // Master Mode, CS0
  78. SPI0_MCR = SPI_MCR_MSTR | SPI_MCR_PCSIS(1);
  79. // DSPI Clock and Transfer Attributes
  80. // Frame Size: 8 bits
  81. // MSB First
  82. // CLK Low by default
  83. SPI0_CTAR0 = SPI_CTAR_FMSZ(7)
  84. | SPI_CTAR_ASC(7)
  85. | SPI_CTAR_DT(7)
  86. | SPI_CTAR_CSSCK(7)
  87. | SPI_CTAR_PBR(0) | SPI_CTAR_BR(7);
  88. }
  89. // Write buffer to SPI FIFO
  90. void SPI_write( uint8_t *buffer, uint8_t len )
  91. {
  92. for ( uint8_t byte = 0; byte < len; byte++ )
  93. {
  94. // Wait for SPI TxFIFO to have 4 or fewer entries
  95. while ( !( SPI0_SR & SPI_SR_TFFF ) )
  96. delayMicroseconds(10);
  97. // Write byte to TxFIFO
  98. // CS0, CTAR0
  99. SPI0_PUSHR = ( buffer[ byte ] & 0xff ) | SPI_PUSHR_PCS(1);
  100. // Indicate transfer has completed
  101. while ( !( SPI0_SR & SPI_SR_TCF ) );
  102. SPI0_SR |= SPI_SR_TCF;
  103. }
  104. }
  105. // Write to a control register
  106. void LCD_writeControlReg( uint8_t byte )
  107. {
  108. // Wait for TxFIFO to be empt
  109. while ( SPI0_TxFIFO_CNT != 0 );
  110. // Set A0 low to enter control register mode
  111. GPIOC_PCOR |= (1<<7);
  112. // Write byte to SPI FIFO
  113. SPI_write( &byte, 1 );
  114. // Wait for TxFIFO to be empty
  115. while ( SPI0_TxFIFO_CNT != 0 );
  116. // Make sure data has transferred
  117. delayMicroseconds(10); // XXX Adjust if SPI speed changes
  118. // Set A0 high to go back to display register mode
  119. GPIOC_PSOR |= (1<<7);
  120. }
  121. // Write to display register
  122. // Pages 0-7 normal display
  123. // Page 8 icon buffer
  124. void LCD_writeDisplayReg( uint8_t page, uint8_t *buffer, uint8_t len )
  125. {
  126. // Set the register page
  127. LCD_writeControlReg( 0xB0 | ( 0x0F & page ) );
  128. // Set display start line
  129. LCD_writeControlReg( 0x40 );
  130. // Reset Column Address
  131. LCD_writeControlReg( 0x10 );
  132. LCD_writeControlReg( 0x00 );
  133. // Write buffer to SPI
  134. SPI_write( buffer, len );
  135. }
  136. inline void LCD_clearPage( uint8_t page )
  137. {
  138. // Set the register page
  139. LCD_writeControlReg( 0xB0 | ( 0x0F & page ) );
  140. // Set display start line
  141. LCD_writeControlReg( 0x40 );
  142. // Reset Column Address
  143. LCD_writeControlReg( 0x10 );
  144. LCD_writeControlReg( 0x00 );
  145. for ( uint8_t page_reg = 0; page_reg < LCD_PAGE_LEN; page_reg++ )
  146. {
  147. uint8_t byte = 0;
  148. // Write buffer to SPI
  149. SPI_write( &byte, 1 );
  150. }
  151. // Wait for TxFIFO to be empty
  152. while ( SPI0_TxFIFO_CNT != 0 );
  153. }
  154. // Clear Display
  155. void LCD_clear()
  156. {
  157. // Setup each page
  158. for ( uint8_t page = 0; page < LCD_TOTAL_PAGES; page++ )
  159. {
  160. LCD_clearPage( page );
  161. }
  162. // Reset Page, Start Line, and Column Address
  163. // Page
  164. LCD_writeControlReg( 0xB0 );
  165. // Start Line
  166. LCD_writeControlReg( 0x40 );
  167. // Reset Column Address
  168. LCD_writeControlReg( 0x10 );
  169. LCD_writeControlReg( 0x00 );
  170. }
  171. // Intialize display
  172. void LCD_initialize()
  173. {
  174. // ADC Select (Normal)
  175. LCD_writeControlReg( 0xA0 );
  176. // LCD Off
  177. LCD_writeControlReg( 0xAE );
  178. // COM Scan Output Direction
  179. LCD_writeControlReg( 0xC0 );
  180. // LCD Bias (1/6 bias)
  181. LCD_writeControlReg( 0xA2 );
  182. // Power Supply Operating Mode (Internal Only)
  183. LCD_writeControlReg( 0x2F );
  184. // Internal Rb/Ra Ratio
  185. LCD_writeControlReg( 0x26 );
  186. // Reset
  187. LCD_writeControlReg( 0xE2 );
  188. // Electric volume mode set, and value
  189. LCD_writeControlReg( 0x81 );
  190. LCD_writeControlReg( 0x00 );
  191. // LCD On
  192. LCD_writeControlReg( 0xAF );
  193. // Clear Display RAM
  194. LCD_clear();
  195. }
  196. // Setup
  197. inline void LCD_setup()
  198. {
  199. // Register Scan CLI dictionary
  200. CLI_registerDictionary( lcdCLIDict, lcdCLIDictName );
  201. // Initialize SPI
  202. SPI_setup();
  203. // Setup Register Control Signal (A0)
  204. // Start in display register mode (1)
  205. GPIOC_PDDR |= (1<<7);
  206. PORTC_PCR7 = PORT_PCR_SRE | PORT_PCR_DSE | PORT_PCR_MUX(1);
  207. GPIOC_PSOR |= (1<<7);
  208. // Setup LCD Reset pin (RST)
  209. // 0 - Reset, 1 - Normal Operation
  210. // Start in normal mode (1)
  211. GPIOC_PDDR |= (1<<8);
  212. PORTC_PCR8 = PORT_PCR_SRE | PORT_PCR_DSE | PORT_PCR_MUX(1);
  213. GPIOC_PSOR |= (1<<8);
  214. // Run LCD intialization sequence
  215. LCD_initialize();
  216. // Write default image to LCD
  217. for ( uint8_t page = 0; page < LCD_TOTAL_VISIBLE_PAGES; page++ )
  218. LCD_writeDisplayReg( page, (uint8_t*)&STLcdDefaultImage[page * LCD_PAGE_LEN], LCD_PAGE_LEN );
  219. // Setup Backlight
  220. SIM_SCGC6 |= SIM_SCGC6_FTM0;
  221. FTM0_CNT = 0; // Reset counter
  222. // PWM Period
  223. // 16-bit maximum
  224. FTM0_MOD = 0xFFFF;
  225. // Set FTM to PWM output - Edge Aligned, Low-true pulses
  226. FTM0_C0SC = 0x24; // MSnB:MSnA = 10, ELSnB:ELSnA = 01
  227. FTM0_C1SC = 0x24;
  228. FTM0_C2SC = 0x24;
  229. // Base FTM clock selection (72 MHz system clock)
  230. // @ 0xFFFF period, 72 MHz / (0xFFFF * 2) = Actual period
  231. // Higher pre-scalar will use the most power (also look the best)
  232. // Pre-scalar calculations
  233. // 0 - 72 MHz -> 549 Hz
  234. // 1 - 36 MHz -> 275 Hz
  235. // 2 - 18 MHz -> 137 Hz
  236. // 3 - 9 MHz -> 69 Hz (Slightly visible flicker)
  237. // 4 - 4 500 kHz -> 34 Hz (Visible flickering)
  238. // 5 - 2 250 kHz -> 17 Hz
  239. // 6 - 1 125 kHz -> 9 Hz
  240. // 7 - 562 500 Hz -> 4 Hz
  241. // Using a higher pre-scalar without flicker is possible but FTM0_MOD will need to be reduced
  242. // Which will reduce the brightness range
  243. // System clock, /w prescalar setting
  244. FTM0_SC = FTM_SC_CLKS(1) | FTM_SC_PS( STLcdBacklightPrescalar_define );
  245. // Red
  246. FTM0_C0V = STLcdBacklightRed_define;
  247. PORTC_PCR1 = PORT_PCR_SRE | PORT_PCR_DSE | PORT_PCR_MUX(4);
  248. // Green
  249. FTM0_C1V = STLcdBacklightGreen_define;
  250. PORTC_PCR2 = PORT_PCR_SRE | PORT_PCR_DSE | PORT_PCR_MUX(4);
  251. // Blue
  252. FTM0_C2V = STLcdBacklightBlue_define;
  253. PORTC_PCR3 = PORT_PCR_SRE | PORT_PCR_DSE | PORT_PCR_MUX(4);
  254. }
  255. // LCD State processing loop
  256. inline uint8_t LCD_scan()
  257. {
  258. return 0;
  259. }
  260. // ----- Capabilities -----
  261. // Takes 1 8 bit length and 4 16 bit arguments, each corresponding to a layer index
  262. // Ordered from top to bottom
  263. // The first argument indicates how many numbers to display (max 4), set to 0 to load default image
  264. uint16_t LCD_layerStackExact[4];
  265. uint8_t LCD_layerStackExact_size = 0;
  266. typedef struct LCD_layerStackExact_args {
  267. uint8_t numArgs;
  268. uint16_t layers[4];
  269. } LCD_layerStackExact_args;
  270. void LCD_layerStackExact_capability( uint8_t state, uint8_t stateType, uint8_t *args )
  271. {
  272. // Display capability name
  273. if ( stateType == 0xFF && state == 0xFF )
  274. {
  275. print("LCD_layerStackExact_capability(num,layer1,layer2,layer3,layer4)");
  276. return;
  277. }
  278. // Read arguments
  279. LCD_layerStackExact_args *stack_args = (LCD_layerStackExact_args*)args;
  280. // Number data for LCD
  281. const uint8_t numbers[10][128] = {
  282. { STLcdNumber0_define },
  283. { STLcdNumber1_define },
  284. { STLcdNumber2_define },
  285. { STLcdNumber3_define },
  286. { STLcdNumber4_define },
  287. { STLcdNumber5_define },
  288. { STLcdNumber6_define },
  289. { STLcdNumber7_define },
  290. { STLcdNumber8_define },
  291. { STLcdNumber9_define },
  292. };
  293. // Color data for numbers
  294. const uint16_t colors[10][3] = {
  295. { STLcdNumber0Color_define },
  296. { STLcdNumber1Color_define },
  297. { STLcdNumber2Color_define },
  298. { STLcdNumber3Color_define },
  299. { STLcdNumber4Color_define },
  300. { STLcdNumber5Color_define },
  301. { STLcdNumber6Color_define },
  302. { STLcdNumber7Color_define },
  303. { STLcdNumber8Color_define },
  304. { STLcdNumber9Color_define },
  305. };
  306. // Only display if there are layers active
  307. if ( stack_args->numArgs > 0 )
  308. {
  309. // Set the color according to the "top-of-stack" layer
  310. uint16_t layerIndex = stack_args->layers[0];
  311. FTM0_C0V = colors[ layerIndex ][0];
  312. FTM0_C1V = colors[ layerIndex ][1];
  313. FTM0_C2V = colors[ layerIndex ][2];
  314. // Iterate through each of the pages
  315. // XXX Many of the values here are hard-coded
  316. // Eventually a proper font rendering engine should take care of things like this... -HaaTa
  317. for ( uint8_t page = 0; page < LCD_TOTAL_VISIBLE_PAGES; page++ )
  318. {
  319. // Set the register page
  320. LCD_writeControlReg( 0xB0 | ( 0x0F & page ) );
  321. // Set starting address
  322. LCD_writeControlReg( 0x10 );
  323. LCD_writeControlReg( 0x00 );
  324. // Write data
  325. for ( uint16_t layer = 0; layer < stack_args->numArgs; layer++ )
  326. {
  327. layerIndex = stack_args->layers[ layer ];
  328. // Default to 0, if over 9
  329. if ( layerIndex > 9 )
  330. {
  331. layerIndex = 0;
  332. }
  333. // Write page of number to display
  334. SPI_write( (uint8_t*)&numbers[ layerIndex ][ page * 32 ], 32 );
  335. }
  336. // Blank out rest of display
  337. uint8_t data = 0;
  338. for ( uint8_t c = 0; c < 4 - stack_args->numArgs; c++ )
  339. {
  340. for ( uint8_t byte = 0; byte < 32; byte++ )
  341. {
  342. SPI_write( &data, 1 );
  343. }
  344. }
  345. }
  346. }
  347. else
  348. {
  349. // Set default backlight
  350. FTM0_C0V = STLcdBacklightRed_define;
  351. FTM0_C1V = STLcdBacklightGreen_define;
  352. FTM0_C2V = STLcdBacklightBlue_define;
  353. // Write default image
  354. for ( uint8_t page = 0; page < LCD_TOTAL_VISIBLE_PAGES; page++ )
  355. LCD_writeDisplayReg( page, (uint8_t *)&STLcdDefaultImage[page * LCD_PAGE_LEN], LCD_PAGE_LEN );
  356. }
  357. }
  358. // Determines the current layer stack, and sets the LCD output accordingly
  359. // Will only work on a master node when using the interconnect (use LCD_layerStackExact_capability instead)
  360. uint16_t LCD_layerStack_prevSize = 0;
  361. uint16_t LCD_layerStack_prevTop = 0;
  362. void LCD_layerStack_capability( uint8_t state, uint8_t stateType, uint8_t *args )
  363. {
  364. // Display capability name
  365. if ( stateType == 0xFF && state == 0xFF )
  366. {
  367. print("LCD_layerStack_capability()");
  368. return;
  369. }
  370. // Parse the layer stack, top to bottom
  371. extern uint16_t macroLayerIndexStack[];
  372. extern uint16_t macroLayerIndexStackSize;
  373. // Ignore if the stack size hasn't changed and the top of the stack is the same
  374. if ( macroLayerIndexStackSize == LCD_layerStack_prevSize
  375. && macroLayerIndexStack[macroLayerIndexStackSize - 1] == LCD_layerStack_prevTop )
  376. {
  377. return;
  378. }
  379. LCD_layerStack_prevSize = macroLayerIndexStackSize;
  380. LCD_layerStack_prevTop = macroLayerIndexStack[macroLayerIndexStackSize - 1];
  381. LCD_layerStackExact_args stack_args;
  382. memset( stack_args.layers, 0, sizeof( stack_args.layers ) );
  383. // Use the LCD_layerStackExact_capability to set the LCD using the determined stack
  384. // Construct argument set for capability
  385. stack_args.numArgs = macroLayerIndexStackSize;
  386. for ( uint16_t layer = 1; layer <= macroLayerIndexStackSize; layer++ )
  387. {
  388. stack_args.layers[ layer - 1 ] = macroLayerIndexStack[ macroLayerIndexStackSize - layer ];
  389. }
  390. // Only deal with the interconnect if it has been compiled in
  391. #if defined(ConnectEnabled_define)
  392. if ( Connect_master )
  393. {
  394. // generatedKeymap.h
  395. extern const Capability CapabilitiesList[];
  396. // Broadcast layerStackExact remote capability (0xFF is the broadcast id)
  397. Connect_send_RemoteCapability(
  398. 0xFF,
  399. LCD_layerStackExact_capability_index,
  400. state,
  401. stateType,
  402. CapabilitiesList[ LCD_layerStackExact_capability_index ].argCount,
  403. (uint8_t*)&stack_args
  404. );
  405. }
  406. #endif
  407. // Call LCD_layerStackExact directly
  408. LCD_layerStackExact_capability( state, stateType, (uint8_t*)&stack_args );
  409. }
  410. // ----- CLI Command Functions -----
  411. void cliFunc_lcdInit( char* args )
  412. {
  413. LCD_initialize();
  414. }
  415. void cliFunc_lcdTest( char* args )
  416. {
  417. // Write default image
  418. for ( uint8_t page = 0; page < LCD_TOTAL_VISIBLE_PAGES; page++ )
  419. LCD_writeDisplayReg( page, (uint8_t *)&STLcdDefaultImage[page * LCD_PAGE_LEN], LCD_PAGE_LEN );
  420. }
  421. void cliFunc_lcdCmd( char* args )
  422. {
  423. char* curArgs;
  424. char* arg1Ptr;
  425. char* arg2Ptr = args;
  426. print( NL ); // No \r\n by default after the command is entered
  427. curArgs = arg2Ptr; // Use the previous 2nd arg pointer to separate the next arg from the list
  428. CLI_argumentIsolation( curArgs, &arg1Ptr, &arg2Ptr );
  429. // No args
  430. if ( *arg1Ptr == '\0' )
  431. return;
  432. // SPI Command
  433. uint8_t cmd = (uint8_t)numToInt( arg1Ptr );
  434. curArgs = arg2Ptr; // Use the previous 2nd arg pointer to separate the next arg from the list
  435. CLI_argumentIsolation( curArgs, &arg1Ptr, &arg2Ptr );
  436. // Single Arg
  437. if ( *arg1Ptr == '\0' )
  438. goto cmd;
  439. // TODO Deal with a0
  440. cmd:
  441. info_msg("Sending - ");
  442. printHex( cmd );
  443. print( NL );
  444. LCD_writeControlReg( cmd );
  445. }
  446. void cliFunc_lcdColor( char* args )
  447. {
  448. char* curArgs;
  449. char* arg1Ptr;
  450. char* arg2Ptr = args;
  451. // Colors
  452. uint16_t rgb[3]; // Red, Green, Blue
  453. // Parse integers from 3 arguments
  454. for ( uint8_t color = 0; color < 3; color++ )
  455. {
  456. curArgs = arg2Ptr;
  457. CLI_argumentIsolation( curArgs, &arg1Ptr, &arg2Ptr );
  458. // Give up if not enough args given
  459. if ( *arg1Ptr == '\0' )
  460. return;
  461. // Convert argument to integer
  462. rgb[ color ] = numToInt( arg1Ptr );
  463. }
  464. // Set PWM channels
  465. FTM0_C0V = rgb[0];
  466. FTM0_C1V = rgb[1];
  467. FTM0_C2V = rgb[2];
  468. }
  469. void cliFunc_lcdDisp( char* args )
  470. {
  471. char* curArgs;
  472. char* arg1Ptr;
  473. char* arg2Ptr = args;
  474. // First process page and starting address
  475. curArgs = arg2Ptr;
  476. CLI_argumentIsolation( curArgs, &arg1Ptr, &arg2Ptr );
  477. // Stop processing args if no more are found
  478. if ( *arg1Ptr == '\0' )
  479. return;
  480. uint8_t page = numToInt( arg1Ptr );
  481. curArgs = arg2Ptr;
  482. CLI_argumentIsolation( curArgs, &arg1Ptr, &arg2Ptr );
  483. // Stop processing args if no more are found
  484. if ( *arg1Ptr == '\0' )
  485. return;
  486. uint8_t address = numToInt( arg1Ptr );
  487. // Set the register page
  488. LCD_writeControlReg( 0xB0 | ( 0x0F & page ) );
  489. // Set starting address
  490. LCD_writeControlReg( 0x10 | ( ( 0xF0 & address ) >> 4 ) );
  491. LCD_writeControlReg( 0x00 | ( 0x0F & address ));
  492. // Process all args
  493. for ( ;; )
  494. {
  495. curArgs = arg2Ptr;
  496. CLI_argumentIsolation( curArgs, &arg1Ptr, &arg2Ptr );
  497. // Stop processing args if no more are found
  498. if ( *arg1Ptr == '\0' )
  499. break;
  500. uint8_t value = numToInt( arg1Ptr );
  501. // Write buffer to SPI
  502. SPI_write( &value, 1 );
  503. }
  504. }