Source Code for LED Driver on Raspberry Pi
description
Device Driver for the LED on the Raspberry Pi kit .
Transcript of Source Code for LED Driver on Raspberry Pi
#include #include #include #include #include #include #include MODULE_LICENSE("GPL");struct GpioRegisters{uint32_t GPFSEL[6];uint32_t Reserved1;uint32_t GPSET[2];uint32_t Reserved2;uint32_t GPCLR[2];};struct GpioRegisters *s_pGpioRegisters;static void SetGPIOFunction(int GPIO, int functionCode){int registerIndex = GPIO / 10;int bit = (GPIO % 10) * 3;unsigned oldValue = s_pGpioRegisters->GPFSEL[registerIndex];unsigned mask = 0b111 > bit) & 0b111, functionCode);s_pGpioRegisters->GPFSEL[registerIndex] = (oldValue & ~mask) | ((functionCode GPSET[GPIO / 32] = (1 GPCLR[GPIO / 32] = (1