started 2019 rewrite

This commit is contained in:
Kristjan Komlosi
2019-07-17 11:16:05 +02:00
parent 62c7ec38ae
commit 0aa4491dc6
5 changed files with 40 additions and 1 deletions

BIN
tinio/library/libcyusbserial.so.1 Executable file

Binary file not shown.

Binary file not shown.

BIN
tinio/tinio Executable file

Binary file not shown.

40
tinio/tinio.c Normal file
View File

@@ -0,0 +1,40 @@
// TinI/O code rewrite of 2019 - fixing a kid's mistakes
// This code is licensed under the ISC license
#include <stdbool.h>
#include <assert.h>
#include "header/CyUSBSerial.h"
#include <stdio.h>
typedef enum inErr {
USAGE = 0,
INVALID
} inErr;
void cyErrHandler(CY_RETURN_STATUS err);
void inErrHandler(inErr err);
bool setPin(CY_HANDLE h, int pinNumber, bool value) {
assert(pinNumber <= 11); // sanity checks, should be sanitized in the parser
assert(pinNumber >=0);
CY_RETURN_STATUS err = CySetGpioValue(h, pinNumber, value);
if (err) cyErrHandler(err);
return value;
}
bool getPin(CY_HANDLE h, int pinNumber){
assert(pinNumber <= 11); // sanity checks, should be sanitized in the parser
assert(pinNumber >=0);
}
bool flpPin(CY_HANDLE h, int pinNumber) {
assert(pinNumber <= 11); // sanity checks, should be sanitized in the parser
assert(pinNumber >=0);
bool val = getPin(h, pinNumber);
val = !val;
setPin(h, pinNumber, val);
return val;
}
void parser(int argc, char **args);
int main(int argc, char **args);

View File

@@ -18,7 +18,6 @@ const CY_VID_PID deviceVidPid{UINT16(0x04b4),
uint8_t deviceNumList[maxDevs];
uint8_t deviceCount;
CY_DEVICE_INFO deviceInfoList[maxDevs];
// vars for deviceOpen function
CY_HANDLE deviceHandleList[maxDevs];