Skip to content
Snippets Groups Projects
main.c 1.85 KiB
Newer Older
  • Learn to ignore specific revisions
  • Pascal Koch's avatar
    Pascal Koch committed
    #include <pico/stdlib.h>
    
    Pascal Koch's avatar
    Pascal Koch committed
    #include <hardware/i2c.h>
    /*
    
    Pascal Koch's avatar
    Pascal Koch committed
    unsigned* enablerregister = (void *) (SIO_BASE + SIO_GPIO_OE_SET_OFFSET);
    unsigned* volatile outregister = (void *) (SIO_BASE + SIO_GPIO_OUT_SET_OFFSET);
    unsigned* volatile outclearregister = (void *) (SIO_BASE + SIO_GPIO_OUT_CLR_OFFSET);
    
    Pascal Koch's avatar
    Pascal Koch committed
    unsigned* gpioregister = (void *) (IO_BANK0_BASE + IO_BANK0_GPIO25_CTRL_OFFSET );
    
    Pascal Koch's avatar
    Pascal Koch committed
    unsigned* resetspace = (void *) (RESETS_BASE);
    
    Pascal Koch's avatar
    Pascal Koch committed
    unsigned* resetdone = (void*) (RESETS_BASE + RESETS_RESET_DONE_IO_BANK0_BITS);
    //unsigned* resetdone = (void*) RESETS_RESET_DONE_IO_BANK0_BITS;
    */
    unsigned* SDApinctrl = (void*)(IO_BANK0_BASE + IO_BANK0_GPIO0_CTRL_OFFSET);
    unsigned* SCLpinctrl = (void*)(IO_BANK0_BASE + IO_BANK0_GPIO1_CTRL_OFFSET);
    
    //unsigned* SDApin = (void*)(SIO_BASE + IO_BANK0_GPIO0_CTRL_FUNCSEL_VALUE_I2C0_SDA);
    //unsigned* SCLpin = (void*)(IO_BANK0_GPIO1_CTRL_FUNCSEL_VALUE_I2C0_SCL);
    
    
    unsigned* asdf ;
    
    
    Pascal Koch's avatar
    Pascal Koch committed
    
    int main() {
    
    Pascal Koch's avatar
    Pascal Koch committed
        //*SDApinctrl = IO_BANK0_GPIO0_CTRL_FUNCSEL_VALUE_I2C0_SDA;
        //*SCLpinctrl = IO_BANK0_GPIO1_CTRL_FUNCSEL_VALUE_I2C0_SCL;
        i2c_init
    
    
    
        gpio_set_function_masked(*SCLpinctrl , IO_BANK0_GPIO1_CTRL_FUNCSEL_VALUE_I2C0_SCL); //selbe funktion wie veroderung
        gpio_set_function_masked(*SCLpinctrl , IO_BANK0_GPIO0_CTRL_FUNCSEL_VALUE_I2C0_SDA); //selbe funktion wie veroderung
    
        //gpio_set_function_masked(1 | 2, GPIO_FUNC_I2C); // macht beides 
    
    
    Pascal Koch's avatar
    Pascal Koch committed
        
    
    Pascal Koch's avatar
    Pascal Koch committed
        /*
    
    Pascal Koch's avatar
    Pascal Koch committed
        *resetspace &= ~(1u<<5);
    
    Pascal Koch's avatar
    Pascal Koch committed
        *gpioregister = 5;
        *enablerregister = 0x01 << PICO_DEFAULT_LED_PIN;
    
    Pascal Koch's avatar
    Pascal Koch committed
    
        if(*resetdone & (0x1 <<5)){
    
        }
    
    
    Pascal Koch's avatar
    Pascal Koch committed
        for(int i = 0; i< 10 ;i++){
    
    Pascal Koch's avatar
    Pascal Koch committed
            for(int j = 0; j <1000000; j++){
    
    Pascal Koch's avatar
    Pascal Koch committed
                *outregister = 0x01 << PICO_DEFAULT_LED_PIN;
            }
    
    Pascal Koch's avatar
    Pascal Koch committed
            for(int j = 0; j <1000000; j++){
                //*outregister = 0x00 << SIO_GPIO_HI_OUT_CLR_OFFSET;
                *outclearregister = 0x01 << PICO_DEFAULT_LED_PIN;
    
                
    
    Pascal Koch's avatar
    Pascal Koch committed
    
            }
        }
    
    Pascal Koch's avatar
    Pascal Koch committed
        */
    
    Pascal Koch's avatar
    Pascal Koch committed
        return 0;
    }