ESP32C3 > GPIO > Struct

BugSimpson
Posts: 6
Joined: Fri Oct 11, 2024 2:14 pm

ESP32C3 > GPIO > Struct

Postby BugSimpson » Fri Oct 11, 2024 3:06 pm

Hello Bit Friends,

can someone explain to me why I can't get the LED on GPIO 8 to live?

Code: Select all

//Mapping Address
//GPIO 0x6000_4000 to 0x6000_4FFF 

#include <stdint.h>
#include <stdio.h>


#define GPIO_BASE 0x60004000ul
typedef struct 
{
    // mapped @GPIO_BASE
    uint32_t Bt_Select_Reg;
    uint32_t Out_Reg;
    uint32_t Out_W1TS_Reg;
    uint32_t Out_W1TC_Reg;
    uint32_t Enable_Reg;
    uint32_t Enable_W1TS_Reg;
    uint32_t Enable_W1TC_Reg;
    uint32_t Strap_Reg;
    uint32_t In_Reg;
    uint32_t Status_Reg;
    uint32_t Status_W1TS_Reg;
    uint32_t Status_W1TC_Reg;
    uint32_t PCPU_Int_Reg;
    uint32_t Status_Next_Reg;    
}GPIO_Cnfg_Reg_t;

 
typedef struct
{
  //mapped @GPIO_BASE + 0x554
    uint32_t Func0_Out_Sel_Cnfg;
    uint32_t Func1_Out_Sel_Cnfg;
    uint32_t Func2_Out_Sel_Cnfg;
    uint32_t Func3_Out_Sel_Cnfg;
    uint32_t Func4_Out_Sel_Cnfg;
    uint32_t Func5_Out_Sel_Cnfg;
    uint32_t Func6_Out_Sel_Cnfg;
    uint32_t Func7_Out_Sel_Cnfg;
    uint32_t Func8_Out_Sel_Cnfg;
}GPIO_Func_Sel_Reg_t;


volatile GPIO_Func_Sel_Reg_t*     const sGPIO_Func_Sel_Reg  = (GPIO_Func_Sel_Reg_t*)(GPIO_BASE + 0x0554);
volatile GPIO_Cnfg_Reg_t*         const sGPIO_Cnfg_Reg      = (GPIO_Cnfg_Reg_t*)GPIO_BASE;


int main() 
{
  sGPIO_Func_Sel_Reg->Func8_Out_Sel_Cnfg |= 0x80;
  
  sGPIO_Cnfg_Reg->Enable_Reg |= 1<<8;
  
  // gpio8 auf low setzen
  sGPIO_Cnfg_Reg->Out_Reg &= ~(1<<8);
  
  return 0;
  
}

Who is online

Users browsing this forum: No registered users and 37 guests