Atmel AVR Free Running ADC

Lectura continua de ADC.

 La lectura de ADC se dispara automaticamente cada vez que finaliza la lectura anterior.

En modo 8 bits se puede conseguir una lectura cada 13 uS (con reloj 16 MHz) lo que nos da una frecuencia de muestreo de 76923 sps sin usar tiempo de procesador.

Basta con configurar ADC de la siguiente forma para leer el canal 0:

    ADMUX  = b'01100000'    ' Channel 0, Left justified, Vref = Avcc
    ADCSRA = b'11100100'    ' Enabled, Auto-Trigger, presc = 16
    ADCSRB = 0

Interrupciones Puerto Paralelo en C

Ejemplo de uso, espera por una interrupciĆ³n, lee e imprime por pantalla el valor presente en el puerto de datos.

```c
//gcc -opport pport.c


#include <linux/ppdev.h>
#include <linux/parport.h>
#include <stropts.h>
#include <stdio.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/select.h>
 
#define PP_DEV_NAME "/dev/parport0"
 
int main()
{
    //Get a file descriptor for the parallel port
    int ppfd;
 
    ppfd = open(PP_DEV_NAME, O_RDWR);
    if(ppfd == -1)
    {
        printf("Unable to open parallel port!\n");
        return 1;
    }
 
    //Have to claim the device
    if(ioctl(ppfd, PPCLAIM))
    {
        printf("Couldn't claim parallel port!\n");
        close(ppfd);
        return 1;
    }
 
    while(1)
    {
        //Set up the control lines for when an interrupt happens
        int int_count;
        int busy = PARPORT_STATUS_ACK | PARPORT_STATUS_ERROR;
        int acking = PARPORT_STATUS_ERROR;
        int ready = PARPORT_STATUS_ACK | PARPORT_STATUS_ERROR;
        unsigned char value;
 
        int dir = 1;
        ioctl(ppfd, PPDATADIR, &dir);  // data port as inputs
        
        //Let ppdev know we're ready for interrupts
        ioctl(ppfd, PPWCONTROL, &ready);
 
        //Wait for an interrupt....................................................
        fd_set rfds;
        FD_ZERO(&rfds);
        FD_SET(ppfd, &rfds);

        if(select(ppfd + 1, &rfds, NULL, NULL, NULL))
        {
            printf("Received interrupt\n");
        }
        else
        {
            printf("No interrupt\n");
            continue; //Caught a signal
        }//.........................................................................
 
            //Read Data port
        ioctl(ppfd, PPRDATA, &value[i]);
        
        unsigned int int_value = value;
        printf("data =  %i\n", int_value);
        
        
        //Clear the interrupt
        ioctl(ppfd, PPCLRIRQ, &int_count);
        if(int_count > 1)
            printf("Uh oh, missed %i interrupts!\n", int_count - 1);
 
        //Acknowledge the interrupt
        //ioctl(ppfd, PPWCONTROL, &acking);
        //usleep(2);
        //ioctl(ppfd, PPWCONTROL, &busy);
    }
 
    return 0;
}
```

Fast linked list without list

If you need a very fast way to iterate over a list of objects and call the same method on all of them, then here is a posible solution. Der...