6

I'm a beginner in embedded programming. I'm working on craneboard (ARM Cortex A8). The source code is available at github.

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

I can't stop the blinking of LED by Ctrl-C.
Where does the coding for Ctrl-C interrupt reside?

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);
             }

        }
}

Kindly guide me.

Gomu
  • 1,004
  • 5
  • 16
  • 36

2 Answers2

3

Try the uboot ctrlc function:

if(ctrlc())
    return 1; // or whatever else you want to do
nneonneo
  • 171,345
  • 36
  • 312
  • 383
  • Thanks. But, my code will continuously send data(1 or 0) to the GPIO pin. How do I get an input amidst that? – Gomu Feb 27 '13 at 09:14
  • @Gomu: Sorry. I think U-Boot may handle Ctrl+C through the `ctrlc` function. Please see updated answer. – nneonneo Feb 27 '13 at 10:48
1

You are working at a low level, so the methods you need to use are also low-level:

  • Check the UART "data-available" flag within your loop - this is very hardware dependent, but usually involves reading a register, masking some bits off and seeing if the right bit is set.
  • if data is available, check to see if it is a CTRL-C (0x03) character, exit if so, discard if not

Having now seen nneonneo's answer, I assume that's what the ctrlc() function does...

Martin Thompson
  • 16,395
  • 1
  • 38
  • 56