简体   繁体   中英

How to use pinout with esp8266 from C file?

I have a very basic example of the task I'm trying to solve. From the main loop in arduino.ino I call the sample_run() function in device.c using the definition in sample.h . From here I'm trying to understand how I can use the GPIO pins from device.c . Can this be done using the arduino ide? I've attached some sample code of what I'm trying to do.

arduino.ino

#include "sample.h"
#include "esp8266/sample_init.h"

void setup() {
}

void loop() {
  sample_run();
}

sample.h

#ifndef SAMPLE_H
#define SAMPLE_H

#ifdef __cplusplus
extern "C" {
#endif

    void sample_run(void);

#ifdef __cplusplus
}
#endif

#endif /* SAMPLE_H */

device.c

#include "sample.h"
void sample_run(void)
{
    //I would like to turn on/off led here
}

In device.c: #include "Arduino.h"

Why are you using .c files and not .cpp?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM