@@ -189,15 +189,18 @@ static const hciLedData ledData[HCI_LED_TOTAL_NOS] =
189189 *****************************************************************************/
190190ReturnStatus hci_led_turnon_green (const HciLedCfg * driver )
191191{
192- ReturnStatus status = RETURN_OK ;
192+ ReturnStatus status = RETURN_NOTOK ;
193193
194+ if (!driver ) {
195+ return status ;
196+ }
194197 /* Turn On Left side Green LEDs */
195198 status = ioexp_led_set_data (& driver -> sx1509_dev [HCI_LED_DRIVER_LEFT ],
196- SX1509_REG_AB , 0x55 , 0x55 );
199+ SX1509_REG_AB , LED_GREEN , LED_GREEN );
197200 if (status == RETURN_OK ) {
198201 /* Turn On Right side Green LEDs */
199202 status = ioexp_led_set_data (& driver -> sx1509_dev [HCI_LED_DRIVER_RIGHT ],
200- SX1509_REG_AB , 0x55 , 0x55 );
203+ SX1509_REG_AB , LED_GREEN , 0x55 );
201204 }
202205 return status ;
203206}
@@ -214,15 +217,18 @@ ReturnStatus hci_led_turnon_green(const HciLedCfg *driver)
214217 *****************************************************************************/
215218ReturnStatus hci_led_turnon_red (const HciLedCfg * driver )
216219{
217- ReturnStatus status = RETURN_OK ;
220+ ReturnStatus status = RETURN_NOTOK ;
218221
222+ if (!driver ) {
223+ return status ;
224+ }
219225 /* Turn On Left side Red LEDs */
220226 status = ioexp_led_set_data (& driver -> sx1509_dev [HCI_LED_DRIVER_LEFT ],
221- SX1509_REG_AB , 0xAA , 0xAA );
227+ SX1509_REG_AB , LED_RED , LED_RED );
222228 if (status == RETURN_OK ) {
223229 /* Turn On Right side Red LEDs */
224230 status = ioexp_led_set_data (& driver -> sx1509_dev [HCI_LED_DRIVER_RIGHT ],
225- SX1509_REG_AB , 0xAA , 0xAA );
231+ SX1509_REG_AB , LED_RED , LED_RED );
226232 }
227233 return status ;
228234}
@@ -239,8 +245,11 @@ ReturnStatus hci_led_turnon_red(const HciLedCfg *driver)
239245 *****************************************************************************/
240246ReturnStatus hci_led_turnoff_all (const HciLedCfg * driver )
241247{
242- ReturnStatus status = RETURN_OK ;
248+ ReturnStatus status = RETURN_NOTOK ;
243249
250+ if (!driver ) {
251+ return status ;
252+ }
244253 /* Turn Off Left side LEDs */
245254 status = ioexp_led_set_data (& driver -> sx1509_dev [HCI_LED_DRIVER_LEFT ],
246255 SX1509_REG_AB , LED_OFF , LED_OFF );
@@ -264,9 +273,12 @@ ReturnStatus hci_led_turnoff_all(const HciLedCfg *driver)
264273 *****************************************************************************/
265274static ReturnStatus hci_led_configure_sx1509_onofftime (const I2C_Dev * ioexpDev )
266275{
267- ReturnStatus status = RETURN_OK ;
268276 uint8_t index ;
277+ ReturnStatus status = RETURN_NOTOK ;
269278
279+ if (!ioexpDev ) {
280+ return status ;
281+ }
270282 for (index = 0 ; index < 14 ; index ++ ) {
271283 /* Configure RegTOn time of LEDs */
272284 status = ioexp_led_set_on_time (ioexpDev , index , REG_T_ON_VALUE );
@@ -282,7 +294,54 @@ static ReturnStatus hci_led_configure_sx1509_onofftime(const I2C_Dev *ioexpDev)
282294 }
283295 return status ;
284296}
297+ /*****************************************************************************
298+ ** FUNCTION NAME : hci_led_configure_onofftime_left
299+ **
300+ ** DESCRIPTION : Configure On and Off time of left LEDs on the LED
301+ *board.
302+ **
303+ ** ARGUMENTS : None
304+ **
305+ ** RETURN TYPE : Success or Failure
306+ **
307+ *****************************************************************************/
308+ static ReturnStatus hci_led_configure_onofftime_left (const HciLedCfg * driver )
309+ {
310+ ReturnStatus status = RETURN_NOTOK ;
311+
312+ if (!driver ) {
313+ return status ;
314+ }
315+ /* Configure LED driver parameters(RegTOn, RegOff) for Left side LEDs */
316+ status = hci_led_configure_sx1509_onofftime (
317+ & driver -> sx1509_dev [HCI_LED_DRIVER_LEFT ]);
318+
319+ return status ;
320+ }
321+ /*****************************************************************************
322+ ** FUNCTION NAME : hci_led_configure_onofftime_right
323+ **
324+ ** DESCRIPTION : Configure On and Off time of right LEDs on the LED
325+ *board.
326+ **
327+ ** ARGUMENTS : None
328+ **
329+ ** RETURN TYPE : Success or Failure
330+ **
331+ *****************************************************************************/
332+ static ReturnStatus hci_led_configure_onofftime_right (const HciLedCfg * driver )
333+ {
334+ ReturnStatus status = RETURN_NOTOK ;
335+
336+ if (!driver ) {
337+ return status ;
338+ }
339+ /* Configure LED driver parameters(RegTOn, RegOff) for Left side LEDs */
340+ status = hci_led_configure_sx1509_onofftime (
341+ & driver -> sx1509_dev [HCI_LED_DRIVER_RIGHT ]);
285342
343+ return status ;
344+ }
286345/*****************************************************************************
287346 ** FUNCTION NAME : hci_led_configure_onofftime
288347 **
@@ -295,16 +354,17 @@ static ReturnStatus hci_led_configure_sx1509_onofftime(const I2C_Dev *ioexpDev)
295354 *****************************************************************************/
296355static ReturnStatus hci_led_configure_onofftime (const HciLedCfg * driver )
297356{
298- ReturnStatus status = RETURN_OK ;
357+ ReturnStatus status = RETURN_NOTOK ;
299358
359+ if (!driver ) {
360+ return status ;
361+ }
300362 /* Configure LED driver parameters(RegTOn, RegOff) for Left side LEDs */
301- status = hci_led_configure_sx1509_onofftime (
302- & driver -> sx1509_dev [HCI_LED_DRIVER_LEFT ]);
363+ status = hci_led_configure_onofftime_left (driver );
303364 if (status == RETURN_OK ) {
304365 /* Configure LED driver parameters(RegTOn, RegOff) for Right side LEDs
305366 */
306- hci_led_configure_sx1509_onofftime (
307- & driver -> sx1509_dev [HCI_LED_DRIVER_RIGHT ]);
367+ status = hci_led_configure_onofftime_right (driver );
308368 }
309369 return status ;
310370}
@@ -322,10 +382,13 @@ static ReturnStatus hci_led_configure_onofftime(const HciLedCfg *driver)
322382 *****************************************************************************/
323383ReturnStatus hci_led_system_boot (const HciLedCfg * driver )
324384{
325- ReturnStatus status = RETURN_OK ;
326385 uint8_t index = 0 ;
327386 uint8_t regValue = 0 ;
387+ ReturnStatus status = RETURN_NOTOK ;
328388
389+ if (!driver ) {
390+ return status ;
391+ }
329392 /* Turn off all LEDs */
330393 status = hci_led_turnoff_all (driver );
331394 if (status != RETURN_OK ) {
@@ -364,8 +427,11 @@ ReturnStatus hci_led_system_boot(const HciLedCfg *driver)
364427 *****************************************************************************/
365428ReturnStatus hci_led_system_running (const HciLedCfg * driver )
366429{
367- ReturnStatus status = RETURN_OK ;
430+ ReturnStatus status = RETURN_NOTOK ;
368431
432+ if (!driver ) {
433+ return status ;
434+ }
369435 /* Turn off all LEDs */
370436 status = hci_led_turnoff_all (driver );
371437 if (status != RETURN_OK ) {
@@ -397,8 +463,11 @@ ReturnStatus hci_led_system_running(const HciLedCfg *driver)
397463 *****************************************************************************/
398464ReturnStatus hci_led_system_failure (const HciLedCfg * driver )
399465{
400- ReturnStatus status = RETURN_OK ;
466+ ReturnStatus status = RETURN_NOTOK ;
401467
468+ if (!driver ) {
469+ return status ;
470+ }
402471 /* Turn off all LEDs */
403472 status = hci_led_turnoff_all (driver );
404473 if (status != RETURN_OK ) {
@@ -430,14 +499,21 @@ ReturnStatus hci_led_system_failure(const HciLedCfg *driver)
430499 *****************************************************************************/
431500ReturnStatus hci_led_radio_failure (const HciLedCfg * driver )
432501{
433- ReturnStatus status = RETURN_OK ;
502+ ReturnStatus status = RETURN_NOTOK ;
434503
504+ if (!driver ) {
505+ return status ;
506+ }
435507 /* Turn off all LEDs */
436508 status = hci_led_turnoff_all (driver );
509+ /* Enable blink for the left LEDs */
510+ if (status == RETURN_OK ) {
511+ status = hci_led_configure_onofftime_left (driver );
512+ }
437513 if (status == RETURN_OK ) {
438514 /* Turn On Left side Red LEDs */
439- status =
440- ioexp_led_set_data ( HCI_LED_DRIVER_LEFT , SX1509_REG_AB , 0xAA , 0xAA );
515+ status = ioexp_led_set_data ( & driver -> sx1509_dev [ HCI_LED_DRIVER_LEFT ],
516+ SX1509_REG_AB , LED_RED , LED_RED );
441517 }
442518
443519 return status ;
@@ -456,14 +532,21 @@ ReturnStatus hci_led_radio_failure(const HciLedCfg *driver)
456532 *****************************************************************************/
457533ReturnStatus hci_led_backhaul_failure (const HciLedCfg * driver )
458534{
459- ReturnStatus status = RETURN_OK ;
535+ ReturnStatus status = RETURN_NOTOK ;
460536
537+ if (!driver ) {
538+ return status ;
539+ }
461540 /* Turn off all LEDs */
462541 status = hci_led_turnoff_all (driver );
542+ /* Enable blink for all Right LEDs */
543+ if (status == RETURN_OK ) {
544+ status = hci_led_configure_onofftime_right (driver );
545+ }
463546 if (status == RETURN_OK ) {
464547 /* Turn On Right side Red LEDs */
465548 status = ioexp_led_set_data (& driver -> sx1509_dev [HCI_LED_DRIVER_RIGHT ],
466- SX1509_REG_AB , 0xAA , 0xAA );
549+ SX1509_REG_AB , LED_RED , LED_RED );
467550 }
468551 return status ;
469552}
@@ -481,15 +564,18 @@ ReturnStatus hci_led_backhaul_failure(const HciLedCfg *driver)
481564 *****************************************************************************/
482565ReturnStatus led_init (const HciLedCfg * driver )
483566{
484- ReturnStatus status = RETURN_OK ;
485567 uint8_t index ;
568+ ReturnStatus status = RETURN_NOTOK ;
486569
570+ if (!driver ) {
571+ return status ;
572+ }
487573 /* Steps required to use the LED driver
488574 - Disable input buffer (RegInputDisable)
489575 - Disable pull-up (RegPullUp)
490576 - Enable open drain (RegOpenDrain)
491- - Set direction to output (RegDir) by default RegData is set high => LED
492- OFF
577+ - Set direction to output (RegDir) \96 by default RegData is set high =>
578+ LED OFF
493579 - Enable oscillator (RegClock)
494580 - Configure LED driver clock and mode if relevant (RegMisc)
495581 - Enable LED driver operation (RegLEDDriverEnable)
@@ -569,6 +655,9 @@ ReturnStatus led_init(const HciLedCfg *driver)
569655void led_configure (HciLedCfg * driver )
570656{
571657 /* Initialize IO pins */
658+ if (!driver ) {
659+ return ;
660+ }
572661 OcGpio_configure (& driver -> pin_ec_gpio ,
573662 OCGPIO_CFG_OUTPUT | OCGPIO_CFG_OUT_HIGH );
574663}
@@ -585,9 +674,12 @@ void led_configure(HciLedCfg *driver)
585674 *****************************************************************************/
586675ePostCode led_probe (const HciLedCfg * driver , POSTData * postData )
587676{
588- ReturnStatus status = RETURN_NOTOK ;
677+ ReturnStatus status = POST_DEV_MISSING ;
589678 uint8_t regValue = 0x00 ;
590679
680+ if (!(driver && postData )) {
681+ return status ;
682+ }
591683 /* Read Test Register 1 of LED driver SX1509 of Left LED Module(RegTest1) */
592684 status = ioexp_led_read_testregister_1 (
593685 & driver -> sx1509_dev [HCI_LED_DRIVER_LEFT ], & regValue );
0 commit comments