Commit 00978df2 authored by ryukoposting's avatar ryukoposting

add PC-side state machine

parent c48c1d43
......@@ -44,7 +44,7 @@ used with PC-GPIO with just a few dozen lines of code. However, implementations
exist for the microcontrollers listed below:
- Arduino
- DUE: fully supported. Supported natively in the Arduino IDE. Will also be supported
- DUE: in progress. Supported natively in the Arduino IDE. Will also be supported
without Arduino library dependencies via direct support for the SAM3X8E.
- UNO: planned.
- Atmel
......@@ -55,6 +55,33 @@ exist for the microcontrollers listed below:
- Infineon
- XMC1404: planned.
### Using the Library
Adding PC-GPIO to a CMake project:
1. Assuming the library is in a subdirectory of your project named 'PC-GPIO':
```
cmake_minimum_required(VERSION 3.5)
project(your_project_name LANGUAGES C)
set(CMAKE_C_STANDARD 11)
add_subdirectory(PC-GPIO)
set(CMAKE_EXE_LINKER_FLAGS "-pthread")
add_executable(your_project_name your_project_main.c)
target_link_libraries(your_project_name LINK_PUBLIC pcgpio)
```
Adding PC-GPIO to an Arduino project:
1. Download the complete PC-GPIO source.
2. Open your Arduino project folder (the one that includes the .ino file).
3. In this directory, extract the PC-GPIO source into a folder called "PC-GPIO"
So there will be 2 things in the project folder, the .ino file and a folder
called PC-GPIO.
4. Import PC-GPIO into your arduino project by adding `#include "PC-GPIO/pcgpio_global.h"
To the top of your arduino code.
### License
Copyright (C) 2018 ryukoposting
......
This diff is collapsed.
......@@ -36,21 +36,23 @@ extern "C" {
struct PCGPIO_Properties {
#if defined(__unix__)
int fd;
int state;
unsigned int state;
struct PCGPIO_Callback receiver_callback;
unsigned char checksum;
int running;
unsigned char rxbuffer[1024];
int start, end;
pthread_t rx_thread;
void*(*pthread_function)(void*);
#endif
void(*callback_handler)(struct PCGPIO_Callback *);
void(*callback_handler)(struct PCGPIO_Properties *, struct PCGPIO_Callback);
void(*error_handler)(struct PCGPIO_Properties *, enum PCGPIO_Status);
unsigned int mcu_identity;
char port_name[32];
};
enum PCGPIO_Status PCGPIO_Init(struct PCGPIO_Properties *const properties, char *port_name,
void(*callback_handler)(struct PCGPIO_Callback *callback),
void(*callback_handler)(struct PCGPIO_Properties *properties, struct PCGPIO_Callback callback),
void(*error_handler)(struct PCGPIO_Properties *properties, enum PCGPIO_Status status));
enum PCGPIO_Status PCGPIO_TransmitMethod(struct PCGPIO_Properties *const properties, struct PCGPIO_Method *const method);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment