π
<-
Chat plein-écran
[^]

Using GPIO22

C, C++, ASM...

Using GPIO22

Message non lude wodz94 » 13 Jan 2019, 00:48

Hello all!

(Scroll down for the answer! :) )


I'm trying to understand the logic behind the mapping of the GPIO sections and bits, so I can do some fancy shizzle with them.
In this post, the master vogtinator wrote a short snippet of code controlling the GPIO4 on pin 6 of the dock connector.

Here's the code:

Code: Tout sélectionner
*(volatile uint32_t*)(0x90000010) &= ~(1<<4);
while(!any_key_pressed()) {
    *(volatile uint32_t*)(0x90000014) &= ~(1<<4);
    sleep(2000);
    *(volatile uint32_t*)(0x90000014) |= 1<<4;
    sleep(2000);
}


Now that works a dream with me in the c++ app that I'm writing, but as soon as I leave the application, the pin voltage reverts to 2.75v.

That's mildly inconvenient, because I'm looking to have a pin at 0v until I use the app to set it to 3.3v
Through measuring, I realised that on pin 18 of the dock connector, where GPIO22 sits, there isn't a voltage by system-default.
Exactly what I'm looking for.

Now I've been trying to understand how to set GPIO22 to 1 but maybe I've blown one braincell too many over christmas...I just can't figure it out.

Any suggestions would be greatly appreciated.
Warm regards from Switzerland!

____________________________________________________________________________
EDIT:

So after another long day of staring at hex numbers, I've just figured it out.
I'll try and explain it, so even I would understand it... and please correct me if I'm wrong.

So the GPIO registers are split into a few sections (Hackspire):

Section 0: 0x90000000-0x9000003F
Section 1: 0x90000040-0x9000007F
Section 2: 0x90000080-0x900000BF
Section 3: 0x900000C0-0x900000FF
Section 5: 0x90000140-0x9000017F


Each GPIO has a corresponding bit in one of those sections.
Here's the allocation table for all the GPIOs attached to this post.(Hackspire).

Say you want to write to GPIO22 (which happens to be pin 18 on the dock connector), this is what needs doing:

1)
Find your GPIO in the table. For me it's Section 2, bit 6.

2)
Set your GPIO as an output.
To do this, you find the
start
of the section. - for me it's 0x90000080
Now the i/o bits are allocated at +0x10 from the start of the section. - for me: 0x90000090
In there we want to set the 6th bit to our desired state (false).

Code: Tout sélectionner
*(volatile uint32_t*)(0x90000090) &= ~(1<<6);


3)
Now let's set the Output to true.
These bits lie at the start address +0x14 - for me: 0x90000094
Here we also want to set the 6th bit.

Code: Tout sélectionner
*(volatile uint32_t*)(0x90000094) |= 1<<6;



There's probably a sleaker way to implement the code but here's a small method:

Code: Tout sélectionner
void setGPIO22(bool value){
  *(volatile uint32_t*)(0x90000090) &= ~(1<<6);
  if(value == TRUE){
    *(volatile uint32_t*)(0x90000094) |= 1<<6;
  }

  if(value == FALSE){
    *(volatile uint32_t*)(0x90000094) &= ~(1<<6);
  }
}



Many thanks to all who do the good work and write the documentation allowing ndless to happen so well!

Best,
wodz
Fichiers joints
Screenshot 2019-01-13 at 21.15.11.png
Avatar de l’utilisateur
wodz94
Niveau 0: MI (Membre Inactif)
Niveau 0: MI (Membre Inactif)
Prochain niv.: 0%
 
Messages: 1
Inscription: 13 Jan 2019, 00:33
Genre: Non spécifié
Calculatrice(s):

Re: Using GPIO22

Message non lude Adriweb » 14 Jan 2019, 05:23

Well, congrats for figuring it out :)
Avatar de l’utilisateur
AdriwebAdmin.
Niveau 16: CC2 (Commandeur des Calculatrices)
Niveau 16: CC2 (Commandeur des Calculatrices)
Prochain niv.: 42.5%
 
Messages: 12092
Images: 847
Inscription: 01 Juin 2007, 00:00
Localisation: France
Genre: Homme
Calculatrice(s):
Classe: (ingénieur)
Twitter: adriweb
GitHub: adriweb


Retourner vers Native: Ndless, Linux, ...

Qui est en ligne

Utilisateurs parcourant ce forum: Aucun utilisateur enregistré et 2 invités

-
Rechercher
-
Sujets à la une
"NumWorks++": Challenge de modification matérielle pour rajouter une puce de mémoire Flash !
Offre TI-Planet/Jarrety pour avoir la TI-83 Premium CE avec son chargeur pour 79,79€ port inclus !
Offre TI-Planet/Jarrety pour avoir la TI-Nspire CX CAS à seulement 130€ TTC port inclus!
Jailbreake ta TI-Nspire avec Ndless et profite des meilleurs jeux et applications !
Transforme ta TI-Nspire CX en console Game Boy Advance!
12345
-
Donations/Premium
Pour plus de concours, de lots, de tests, nous aider à payer le serveur et les domaines...
PayPal : paiement en ligne sécurisé - secure online payments
Découvrez les avantages d'un compte donateur !
JoinRejoignez the donors and/or premium!les donateurs et/ou premium !


Partenaires et pub
Notre partenaire Jarrety 
-
Stats.
387 utilisateurs:
>363 invités
>19 membres
>5 robots
Record simultané (sur 6 mois):
6892 utilisateurs (le 07/06/2017)
-
Autres sites intéressants
Texas Instruments Education
Global | France
 (English / Français)
Banque de programmes TI
ticalc.org
 (English)
La communauté TI-82
tout82.free.fr
 (Français)