Embedded: C Encoding for Ctrl-C interrupt in u-boot terminal

I am new to embedded programming. I am working on a craneboard (ARM Cortex A8). Source code is available on github .

I created C code to connect an external LED connected via GPIO to blink. It can be executed in the u-boot console as a command. Currently,

I can not stop the blinking of the LED using Ctrl-C.
Where is Ctrl-C interrupt coding located?

ret=set_mmc_mux(); if(ret<0) printf("\n\nLED failed to glow!\n\n"); else{ if(!omap_request_gpio(lpin)) { omap_set_gpio_direction(lpin,0); for(i=1;i<21;i++) { ctr=0; if((i%2)==0) { num=num-1; omap_set_gpio_dataout(lpin,num); } else { num=num+1; omap_set_gpio_dataout(lpin,num); } udelay(3000000); } } } 

I ask you to notify me.

+6
source share
2 answers

Try the uboot ctrlc function:

 if(ctrlc()) return 1; // or whatever else you want to do 
+3
source

You work at a low level, so the methods you need are also low level:

  • Check the UART flag "accessible data access" in your cycle - it is very hardware dependent, but usually includes reading the register, masking some bits and viewing if the correct bit is set.
  • If data is available, check if it is a CTRL-C character ( 0x03 ), exit, if so, discard if not

Now, after seeing the answer of nneonneo, I assume that the ctrlc() function does ...

+1
source

All Articles