@@ -108,6 +108,102 @@ static int cmd_version(const struct shell *shell, size_t argc, char **argv)
108
108
return 0 ;
109
109
}
110
110
111
+ int led_on = 0 ;
112
+
113
+ static int cmd_led_toggle (const struct shell * shell , size_t argc , char * * argv )
114
+ {
115
+ * ((volatile uint32_t * )0xe0006808 ) = 0x7 ;
116
+
117
+ * ((volatile uint32_t * )0xe0006804 ) = 0x8 ; // address: LEDDCR0
118
+ * ((volatile uint32_t * )0xe0006800 ) = 0xc8 ;
119
+ * ((volatile uint32_t * )0xe0006804 ) = 0x9 ; // address: LEDDBR
120
+ * ((volatile uint32_t * )0xe0006800 ) = 0xba ;
121
+
122
+ * ((volatile uint32_t * )0xe0006808 ) = 0x6 ;
123
+ * ((volatile uint32_t * )0xe0006808 ) = 0x7 ;
124
+
125
+ // control breathe on/off
126
+ * ((volatile uint32_t * )0xe0006804 ) = 0x5 ; // address: LEDDBCRR
127
+ * ((volatile uint32_t * )0xe0006800 ) = 0x0 ;
128
+ * ((volatile uint32_t * )0xe0006804 ) = 0x6 ; // address: LEDDBCFR
129
+ * ((volatile uint32_t * )0xe0006800 ) = 0x0 ;
130
+
131
+ // set brightness
132
+ * ((volatile uint32_t * )0xe0006804 ) = 0x2 ; // address: LEDDPWRG
133
+ * ((volatile uint32_t * )0xe0006800 ) = 0x0 ;
134
+ * ((volatile uint32_t * )0xe0006804 ) = 0x3 ; // address: LEDDPWRB - this one seems to be red
135
+ * ((volatile uint32_t * )0xe0006800 ) = 0x0 ;
136
+ * ((volatile uint32_t * )0xe0006804 ) = 0x1 ; // address: LEDDPWRR - it seems to be blue
137
+ * ((volatile uint32_t * )0xe0006800 ) = 0xff ;
138
+
139
+ if (led_on )
140
+ {
141
+ // led driver on/off time register
142
+ * ((volatile uint32_t * )0xe0006804 ) = 0xa ; // address: LEDDONR
143
+ * ((volatile uint32_t * )0xe0006800 ) = 0x0 ;
144
+ * ((volatile uint32_t * )0xe0006804 ) = 0xb ; // address: LEDDOFR
145
+ * ((volatile uint32_t * )0xe0006800 ) = 0xff ;
146
+
147
+ led_on = 0 ;
148
+ shell_print (shell , "LED turned off" );
149
+ }
150
+ else
151
+ {
152
+ // led driver on/off time register
153
+ * ((volatile uint32_t * )0xe0006804 ) = 0xa ; // address: LEDDONR
154
+ * ((volatile uint32_t * )0xe0006800 ) = 0xff ;
155
+ * ((volatile uint32_t * )0xe0006804 ) = 0xb ; // address: LEDDOFR
156
+ * ((volatile uint32_t * )0xe0006800 ) = 0x0 ;
157
+
158
+ led_on = 1 ;
159
+ shell_print (shell , "LED turned on" );
160
+ }
161
+
162
+ return 0 ;
163
+ }
164
+
165
+ static int cmd_led_breathe (const struct shell * shell , size_t argc , char * * argv )
166
+ {
167
+ * ((volatile uint32_t * )0xe0006808 ) = 0x7 ;
168
+
169
+ * ((volatile uint32_t * )0xe0006804 ) = 0x8 ; // address: LEDDCR0
170
+ * ((volatile uint32_t * )0xe0006800 ) = 0xc8 ;
171
+ * ((volatile uint32_t * )0xe0006804 ) = 0x9 ; // address: LEDDBR
172
+ * ((volatile uint32_t * )0xe0006800 ) = 0xba ;
173
+
174
+ * ((volatile uint32_t * )0xe0006808 ) = 0x6 ;
175
+ * ((volatile uint32_t * )0xe0006808 ) = 0x7 ;
176
+
177
+
178
+ // led driver on/off time register
179
+ * ((volatile uint32_t * )0xe0006804 ) = 0xa ; // address: LEDDONR
180
+ * ((volatile uint32_t * )0xe0006800 ) = 0x3 ;
181
+ * ((volatile uint32_t * )0xe0006804 ) = 0xb ; // address: LEDDOFR
182
+ * ((volatile uint32_t * )0xe0006800 ) = 0x3 ;
183
+
184
+
185
+ // control breathe on/off
186
+ * ((volatile uint32_t * )0xe0006804 ) = 0x5 ; // address: LEDDBCRR
187
+ * ((volatile uint32_t * )0xe0006800 ) = 0xe2 ;
188
+ * ((volatile uint32_t * )0xe0006804 ) = 0x6 ; // address: LEDDBCFR
189
+ * ((volatile uint32_t * )0xe0006800 ) = 0xa3 ;
190
+
191
+
192
+ // set brightness
193
+ * ((volatile uint32_t * )0xe0006804 ) = 0x2 ; // address: LEDDPWRG
194
+ * ((volatile uint32_t * )0xe0006800 ) = 0x3c ;
195
+ * ((volatile uint32_t * )0xe0006804 ) = 0x3 ; // address: LEDDPWRB
196
+ * ((volatile uint32_t * )0xe0006800 ) = 0x2 ;
197
+ * ((volatile uint32_t * )0xe0006804 ) = 0x1 ; // address: LEDDPWRR
198
+ * ((volatile uint32_t * )0xe0006800 ) = 0x0 ;
199
+
200
+ led_on = 1 ;
201
+
202
+ shell_print (shell , "LED breathing turned on" );
203
+
204
+ return 0 ;
205
+ }
206
+
111
207
SHELL_STATIC_SUBCMD_SET_CREATE (sub_demo ,
112
208
SHELL_CMD (params , NULL , "Print params command." , cmd_demo_params ),
113
209
SHELL_CMD (ping , NULL , "Ping command." , cmd_demo_ping ),
@@ -117,6 +213,9 @@ SHELL_CMD_REGISTER(demo, &sub_demo, "Demo commands", NULL);
117
213
118
214
SHELL_CMD_ARG_REGISTER (version , NULL , "Show kernel version" , cmd_version , 1 , 0 );
119
215
216
+ SHELL_CMD_ARG_REGISTER (led_toggle , NULL , "Toggles LED" , cmd_led_toggle , 1 , 0 );
217
+ SHELL_CMD_ARG_REGISTER (led_breathe , NULL , "Switched LED into blink with breathe mode" , cmd_led_breathe , 1 , 0 );
218
+
120
219
void main (void )
121
220
{
122
221
0 commit comments