mirror of
https://github.com/felis/USB_Host_Shield_2.0.git
synced 2024-03-22 11:31:26 +01:00
Fixes coding style.
Adds examples to travis.
This commit is contained in:
parent
401f4991e9
commit
1d7dbd640b
6 changed files with 37 additions and 35 deletions
|
@ -39,6 +39,9 @@ env:
|
|||
- PLATFORMIO_CI_SRC=examples/board_qc
|
||||
- PLATFORMIO_CI_SRC=examples/cdc_XR21B1411/XR_terminal
|
||||
- PLATFORMIO_CI_SRC=examples/ftdi/USBFTDILoopback
|
||||
- PLATFORMIO_CI_SRC=examples/GPIO/Blink
|
||||
- PLATFORMIO_CI_SRC=examples/GPIO/Blink_LowLevel
|
||||
- PLATFORMIO_CI_SRC=examples/GPIO/Input
|
||||
- PLATFORMIO_CI_SRC=examples/HID/le3dp
|
||||
- PLATFORMIO_CI_SRC=examples/HID/scale
|
||||
- PLATFORMIO_CI_SRC=examples/HID/SRWS1
|
||||
|
|
|
@ -38,14 +38,14 @@ UHS2_GPIO::UHS2_GPIO(USB *pUsb) : m_pUsb(pUsb)
|
|||
* @param val Value to set the pin to (zero value will clear output, non-zero value will assert output)
|
||||
*/
|
||||
void UHS2_GPIO::digitalWrite(uint8_t pin, uint8_t val) {
|
||||
if(pin > 7)
|
||||
return;
|
||||
uint8_t nValue = m_pUsb->gpioRdOutput();
|
||||
uint8_t nMask = 1 << pin;
|
||||
nValue &= (~nMask);
|
||||
if(val)
|
||||
nValue |= (nMask);
|
||||
m_pUsb->gpioWr(nValue);
|
||||
if(pin > 7)
|
||||
return;
|
||||
uint8_t nValue = m_pUsb->gpioRdOutput();
|
||||
uint8_t nMask = 1 << pin;
|
||||
nValue &= (~nMask);
|
||||
if(val)
|
||||
nValue |= (nMask);
|
||||
m_pUsb->gpioWr(nValue);
|
||||
}
|
||||
|
||||
/** @brief Read the value from a GPIO input pin
|
||||
|
@ -53,11 +53,11 @@ void UHS2_GPIO::digitalWrite(uint8_t pin, uint8_t val) {
|
|||
* @retval int Value of GPIO input (-1 on fail)
|
||||
*/
|
||||
int UHS2_GPIO::digitalRead(uint8_t pin) {
|
||||
if(pin > 7)
|
||||
return -1;
|
||||
uint8_t nMask = 1 << pin;
|
||||
uint8_t nValue = m_pUsb->gpioRd();
|
||||
return ((nValue & nMask)?1:0);
|
||||
if(pin > 7)
|
||||
return -1;
|
||||
uint8_t nMask = 1 << pin;
|
||||
uint8_t nValue = m_pUsb->gpioRd();
|
||||
return ((nValue & nMask)?1:0);
|
||||
}
|
||||
|
||||
/** @brief Read the value from a GPIO output pin
|
||||
|
@ -66,9 +66,9 @@ int UHS2_GPIO::digitalRead(uint8_t pin) {
|
|||
* @note Value of MAX3421E output register, i.e. what the device has been set to, not the physical value on the pin
|
||||
*/
|
||||
int UHS2_GPIO::digitalReadOutput(uint8_t pin) {
|
||||
if(pin > 7)
|
||||
return -1;
|
||||
uint8_t nMask = 1 << pin;
|
||||
uint8_t nValue = m_pUsb->gpioRdOutput();
|
||||
return ((nValue & nMask)?1:0);
|
||||
if(pin > 7)
|
||||
return -1;
|
||||
uint8_t nMask = 1 << pin;
|
||||
uint8_t nValue = m_pUsb->gpioRdOutput();
|
||||
return ((nValue & nMask)?1:0);
|
||||
}
|
||||
|
|
|
@ -29,16 +29,15 @@ UHS2_GPIO implements "wiring" style GPIO access. Implemented by Brian Walton bri
|
|||
|
||||
#include "Usb.h"
|
||||
|
||||
class UHS2_GPIO
|
||||
{
|
||||
public:
|
||||
class UHS2_GPIO {
|
||||
public:
|
||||
UHS2_GPIO(USB *pUsb);
|
||||
|
||||
void digitalWrite(uint8_t pin, uint8_t val);
|
||||
int digitalRead(uint8_t pin);
|
||||
int digitalReadOutput(uint8_t pin);
|
||||
|
||||
private:
|
||||
private:
|
||||
USB* m_pUsb;
|
||||
};
|
||||
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
|
||||
#define OUTPUT_PIN 0
|
||||
|
||||
USB Usb; //Create an UHS2 interface object
|
||||
UHS2_GPIO GPIO(&Usb); //Create a GPIO object
|
||||
USB Usb; // Create an UHS2 interface object
|
||||
UHS2_GPIO GPIO(&Usb); // Create a GPIO object
|
||||
|
||||
void setup()
|
||||
{
|
||||
|
@ -30,11 +30,11 @@ void setup()
|
|||
|
||||
void loop()
|
||||
{
|
||||
//Get the current output value, toggle then wait half a second
|
||||
// Get the current output value, toggle then wait half a second
|
||||
int nValue = GPIO.digitalReadOutput(OUTPUT_PIN);
|
||||
nValue = (nValue?0:1);
|
||||
nValue = (nValue ? 0 : 1);
|
||||
GPIO.digitalWrite(OUTPUT_PIN, nValue);
|
||||
Serial.print(nValue?"+":"."); //Debug to show what the output should be doing
|
||||
Serial.print(nValue ? "+" : "."); // Debug to show what the output should be doing
|
||||
delay(500);
|
||||
}
|
||||
|
||||
|
|
|
@ -28,13 +28,13 @@ void setup()
|
|||
|
||||
void loop()
|
||||
{
|
||||
//Get the current output value, toggle then wait half a second
|
||||
// Get the current output value, toggle then wait half a second
|
||||
uint8_t nGPO = Usb.gpioRdOutput();
|
||||
uint8_t nValue = ((nGPO & 0x01) == 0x01)?0:1;
|
||||
nGPO &= 0xFE; //clear bit 0
|
||||
uint8_t nValue = ((nGPO & 0x01) == 0x01) ? 0 : 1;
|
||||
nGPO &= 0xFE; // Clear bit 0
|
||||
nGPO |= nValue;
|
||||
Usb.gpioWr(nGPO);
|
||||
Serial.print(nValue?"+":"."); //Debug to show what the output should be doing
|
||||
Serial.print(nValue ? "+" : "."); // Debug to show what the output should be doing
|
||||
delay(500);
|
||||
}
|
||||
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
#define INPUT_PIN 0
|
||||
#define OUTPUT_PIN 0
|
||||
|
||||
USB Usb; //Create an UHS2 interface object
|
||||
UHS2_GPIO GPIO(&Usb); //Create a GPIO object
|
||||
USB Usb; // Create an UHS2 interface object
|
||||
UHS2_GPIO GPIO(&Usb); // Create a GPIO object
|
||||
|
||||
void setup()
|
||||
{
|
||||
|
@ -30,9 +30,9 @@ void setup()
|
|||
|
||||
void loop()
|
||||
{
|
||||
//Get the value of input, set value of output
|
||||
// Get the value of input, set value of output
|
||||
int nValue = GPIO.digitalRead(INPUT_PIN);
|
||||
nValue = (nValue?0:1);
|
||||
nValue = (nValue ? LOW : HIGH);
|
||||
GPIO.digitalWrite(OUTPUT_PIN, nValue);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue