Skip to content

Commit f244dfd

Browse files
committed
check if LED manager is initialized before calling functions
1 parent ffa3f1b commit f244dfd

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

components/LED/LED.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ ErrCode_t DebugLEDManager::disable( void )
5353
ErrCode_t errCode = ErrCode_Internal;
5454
int ret;
5555

56+
if( !isInitalized ) { errCode = ErrCode_NotReady; goto exit; }
57+
5658
ret = gpio_pin_set_dt(&led, DISABLE_LED);
5759
if ( ret ) { goto exit; }
5860

@@ -72,6 +74,8 @@ ErrCode_t DebugLEDManager::enable( void )
7274
ErrCode_t errCode = ErrCode_Internal;
7375
int ret;
7476

77+
if( !isInitalized ) { errCode = ErrCode_NotReady; goto exit; }
78+
7579
ret = gpio_pin_set_dt( &led, ENABLE_LED );
7680
if ( ret ) { goto exit; }
7781

@@ -91,6 +95,8 @@ ErrCode_t DebugLEDManager::toggle( void )
9195
ErrCode_t errCode = ErrCode_Internal;
9296
int ret;
9397

98+
if( !isInitalized ) { errCode = ErrCode_NotReady; goto exit; }
99+
94100
ret = gpio_pin_toggle_dt( &led );
95101
if ( ret ) { goto exit; }
96102

0 commit comments

Comments
 (0)