#include <gpio.h> not found - make file edited and library added Topic is solved

If you have a simple question and just want an answer.
User avatar
xlordofpainx
Experienced Member
Posts: 78
Joined: Thu Mar 08, 2018 2:44 pm

#include <gpio.h> not found - make file edited and library added

Post by xlordofpainx »

So I am trying to flash some LEDs on the Xcore2-- audio MC and I am getting fatal error gpio.h not found. I have inported the library into the work space and I have added it in the make file- i have also added assert.h and I am not getting the error for it.
#include <platform.h>
#include <xs1.h>
#include <timer.h>
#include <gpio.h>
#include <assert.h>

port p=X1D14;
port d=X1D16;

void col(unsigned n){
p <: 0;
delay_milliseconds (500) ;
p <: 1;
delay_milliseconds (200) ;
p <: 0;
delay_milliseconds (50000) ;
p <: 1;
delay_milliseconds (200) ;
p <: 0;
delay_milliseconds (50000) ;
p <: 1;
delay_milliseconds (200) ;
}
void row(unsigned n){
d <: 0;
delay_milliseconds (500) ;
d <: 1;
delay_milliseconds (200) ;
d <: 0;
delay_milliseconds (50000) ;
d <: 1;
delay_milliseconds (200) ;
d <: 0;
delay_milliseconds (50000) ;
d <: 1;
delay_milliseconds (200) ;
}

int main () {

par{
row(1);
col(2);
}
return 0;
}
I just chose row 1 column 1 and am trying
View Solution
User avatar
mon2
XCore Legend
Posts: 1913
Joined: Thu Jun 10, 2010 11:43 am

Post by mon2 »

Hi. You are causing more "pain" than required :)

Suggestion:

1) start a fresh workspace
2) goto examples on the left side of the toolchain
3) select AN00155 for the XCORE-200 Explorer Kit
4) Allow for the importing of this example
5) Proceed to compile. During this process, the toolchain will import some dependencies including lib_gpio and others. Then the gpio.h will resolve ok.
6) After a successful compilation -> proceed to kill the source code that is not required and now modify the GPIO pins for your custom code.

Summary: Use the foundation example to correct the raised issue for you and then tweak to suit. Good luck :)
User avatar
xlordofpainx
Experienced Member
Posts: 78
Joined: Thu Mar 08, 2018 2:44 pm

Post by xlordofpainx »

Thank you sensei, but I am still unable to get the LEds to light up-
I flashed the default N00155 for the XCORE-200 Explorer Kit -> no Leds went on
I changed the target to xk-audio-216-mc - no lights
I changed to default ports to on tile[0] : in port explorer_buttons = XS1_PORT_D14;
on tile[0] : out port explorer_leds = XS1_PORT_D16;
from:
X1D14 4C0 8B0 16A8 32A28 LED_ROW_0
X1D15 4C1 8B1 16A9 32A29 LED_ROW_1
X1D16 4D0 8B2 16A10 LED_COL_0
X1D17 4D1 8B3 16A11 LED_COL_1
X1D18 4D2 8B4 16A12 LED_COL_2
X1D19 4D3 8B5 16A13 LED_COL_3
X1D20 4C2 8B6 16A14 32A30 LED_ROW_2
X1D21 4C3 8B7 16A15 32A31 LED_ROW_3
As they are given in the datasheet, but now i get an error on them - undeclared identifier multiple markers at this line.
User avatar
mon2
XCore Legend
Posts: 1913
Joined: Thu Jun 10, 2010 11:43 am

Post by mon2 »

Can you post your code / project?

Review this thread. LEDs are on tile 1.

http://www.xcore.com/viewtopic.php?f=3& ... eds#p31562.
User avatar
xlordofpainx
Experienced Member
Posts: 78
Joined: Thu Mar 08, 2018 2:44 pm

Post by xlordofpainx »

Awesomeee. Thanks! Worked. I am ready for next Christmas!
Kronoh
Junior Member
Posts: 6
Joined: Wed May 10, 2023 10:01 am

Post by Kronoh »

Hi, I have the same problem but i work with an xcore.ai evaluation kit XK-EVK-XU316 which is not available on the xTIME Composer toolchain, so I have to use only the XTC. When i try to build this program :
#include <xs1.h>
#include <platform.h>
#include "gpio.h"

#define LED_PIN 14

int main() {
// Configuration de la broche en sortie
gpio_set_port_mode(PORT_1, XS1_PORT_1O); // Configurer le port 1 comme sortie
gpio_set_port_val(PORT_1, 1 << LED_PIN); // Mettre la broche LED_PIN à l'état haut

while (1) {
// Allumer la LED
gpio_set_port_val(PORT_1, 1 << LED_PIN);

// Attendre pendant un certain temps
for (int i = 0; i < 1000000; i++) {
asm("nop");
}

// Éteindre la LED
gpio_set_port_val(PORT_1, 0);

// Attendre pendant un certain temps
for (int i = 0; i < 1000000; i++) {
asm("nop");
}
}

return 0;
}

the XTC Tools print this :

TestFlashGPT.cpp:3:10: fatal error: 'gpio.h' file not found
#include "gpio.h"
^
1 error generated.

Somebody can help me ? :,)