FireflyApi hardware
3.3 Hardware interface
-
Enable watchdog
Function:public boolean watchDogEnable(boolean enable)Description:Open/close watchdogParameters:enable is set to true, it means to open watchdog, otherwise, false to disenableReturn:true on success, false on failureRemark:After opening the watchdog, you need to take care of feeding the watchdog once every 30s, otherwise, the watchdog will be closed.Example: -
Feeding the dog
Function:public boolean watchDogFeed()Description:Feeding the dog onceReturn:Returns true if it feeds the dog successfullyExample: -
Microphone switch(3128 board type is not supported)
Function:public boolean switchMic(int mic_type)Description:Microphone is switched to onboard/headphoneParameters:mic_type TYPE_DEFAULT_MIC onboard micTYPE_HEADSET_MIC headphone micReturn:Returns true if the switch is successfulExample: -
gpio control
Function:public boolean gpioCtrl(int gpio, String direction, int value)Description:Control gpioParameters:gpiodirection in, out, high, low high/lowvalue 1/0Return:true on successExample:boolean success = mFireflyApi.gpioCtrl(263,"out",1);//GPIO8_A7 gpio the node is 263 -
Read the value of gpio
Function:public int gpioRead(int gpio)Description:Read the value of gpioParameters:gpioReturn:Returns -1 when the read failsExample:int gpioValue = mFireflyApi.gpioRead(263);//GPIO8_A7 gpio the node is 263 -
Check if the gpio port is occupied by the system
Function:public boolean isGpioOccupied(int gpio)Description:Check if the gpio port is occupied by the systemParameters:gpioReturn:Returns true if occupiedExample:boolean occupied = mFireflyApi.isGpioOccupied(263);//GPIO8_A7 gpio the node is 263 -
Parse the node value of gpio
Function:public int gpioParse(String gpioStr)Description:Parse the node value of gpio, for example GPIO8_A7 is converted to node 263Parameters:gpioStrReturn:Returns -1 when the parse failsExample:int gpioValue= mFireflyApi.gpioParse("GPIO8_A7");//GPIO8_A7 gpio the node is 263 -
Set USB power, choose to control OTG or USB interface
Function:public boolean setUsbPower(int type, boolean connect )Description:Set USB power, choose to control OTG or USB interfaceParameters:type TYPE_USBHOST //Control USB portTYPE_OTG //Control OTG portconnectReturn:Returns to -1 if failedExample:mFireflyApi.setUsbPower("TYPE_USBHOST",ture);// connect USB HOSTmFireflyApi.setUsbPower("TYPE_USBHOST",false);// disconnect USB HOSTmFireflyApi.setUsbPower("TYPE_OTG",ture);// connect OTGmFireflyApi.setUsbPower("TYPE_OTG",false);// disconnect OTG** Note: Due to different hardware design, the OTG interface of the device with 3128 board type cannot be powered off when connected to the host. **
-
The use of serial port
-
Import header file
-
Open the serial port according to the path and baud rate, and set the callback function
-
Send a string to the serial port
-
Close the serial port