started 2019 rewrite
This commit is contained in:
BIN
tinio/library/libcyusbserial.so.1
Executable file
BIN
tinio/library/libcyusbserial.so.1
Executable file
Binary file not shown.
BIN
tinio/testUtility/CyUSBSerialCommandUtility
Executable file
BIN
tinio/testUtility/CyUSBSerialCommandUtility
Executable file
Binary file not shown.
BIN
tinio/tinio
Executable file
BIN
tinio/tinio
Executable file
Binary file not shown.
40
tinio/tinio.c
Normal file
40
tinio/tinio.c
Normal 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);
|
||||||
@@ -18,7 +18,6 @@ const CY_VID_PID deviceVidPid{UINT16(0x04b4),
|
|||||||
uint8_t deviceNumList[maxDevs];
|
uint8_t deviceNumList[maxDevs];
|
||||||
uint8_t deviceCount;
|
uint8_t deviceCount;
|
||||||
CY_DEVICE_INFO deviceInfoList[maxDevs];
|
CY_DEVICE_INFO deviceInfoList[maxDevs];
|
||||||
|
|
||||||
// vars for deviceOpen function
|
// vars for deviceOpen function
|
||||||
|
|
||||||
CY_HANDLE deviceHandleList[maxDevs];
|
CY_HANDLE deviceHandleList[maxDevs];
|
||||||
|
|||||||
Reference in New Issue
Block a user