diff --git a/.github/workflows/spell_check.yml b/.github/workflows/spell_check.yml index 3d98d57..bbe54ae 100644 --- a/.github/workflows/spell_check.yml +++ b/.github/workflows/spell_check.yml @@ -21,6 +21,6 @@ jobs: uses: codespell-project/actions-codespell@v2 with: skip: source/_download/Education/NTNU/Ameba_AIoT_mini82_Arduino_Teaching_Material_EngVer.pdf,source/_download/Education/NTNU/Ameba_AIoT_mini82_Arduino_Teaching_Material_JPVer.pdf,source/Education/NTNU.rst - ignore_words_list: ameba,datas + ignore_words_list: ameba,datas,ser # ignore_words_file: .codespellignore path: ${{ matrix.path }} diff --git a/bak/ambd/_common/API_Documents/RTC/Class RTCClass.rst b/bak/ambd/_common/API_Documents/RTC/Class RTCClass.rst deleted file mode 100644 index 0bd8ddf..0000000 --- a/bak/ambd/_common/API_Documents/RTC/Class RTCClass.rst +++ /dev/null @@ -1,346 +0,0 @@ -Class RTC -========= - -.. contents:: - :local: - :depth: 2 - -**RTCClass Class** ------------------- - -**Description** -~~~~~~~~~~~~~~~ - -A class used for initializing, starting, stopping, and setting alarm with RTC. - -**Syntax** -~~~~~~~~~~ - -.. code-block:: c++ - - class WDT - -**Members** -~~~~~~~~~~~ - -+-----------------------------------+-----------------------------------+ -| **Public Constructors** | -+===================================+===================================+ -| RTCClass:: RTCClass | Constructs an RTC object. | -+-----------------------------------+-----------------------------------+ -| **Public Methods** | -+-----------------------------------+-----------------------------------+ -| RTCClass::Init | Initializes the RTC device, | -| | include clock, RTC registers and | -| | function. | -+-----------------------------------+-----------------------------------+ -| RTCClass::DeInit | Deinitializes the RTC device. | -+-----------------------------------+-----------------------------------+ -| RTCClass::Write | Set the specified timestamp in | -| | seconds to RTC. | -+-----------------------------------+-----------------------------------+ -| RTCClass::Read | Get current timestamp in seconds | -| | from RTC. | -+-----------------------------------+-----------------------------------+ -| RTCClass::Wait | Wait for seconds. A delay | -| | function. | -+-----------------------------------+-----------------------------------+ -| RTCClass::SetEpoch | Convert human readable time to | -| | epoch time. | -+-----------------------------------+-----------------------------------+ -| RTCClass::EnableAlarm | Enable the RTC alarm. | -+-----------------------------------+-----------------------------------+ -| RTCClass::DisableAlarm | Disable the RTC alarm. | -+-----------------------------------+-----------------------------------+ - -**RTCClass::Init** ------------------- - -**Description** -~~~~~~~~~~~~~~~ - -Initializes the RTC device, include clock, RTC registers and function. - -**Syntax** -~~~~~~~~~~ - -.. code-block:: c++ - - void Init(void); - -**Parameters** -~~~~~~~~~~~~~~ - -NA - -**Returns** -~~~~~~~~~~~ - -NA - -**Example Code** -~~~~~~~~~~~~~~~~ - -Example: `Simple_RTC `_, `Simple_RTC_Alarm `_ - -.. note :: "rtc.h" must be included to use the class function. - -**RTCClass::DeInit** --------------------- - -**Description** -~~~~~~~~~~~~~~~ - -Deinitializes the RTC device. - -**Syntax** -~~~~~~~~~~ - -.. code-block:: c++ - - void DeInit(void); - -**Parameters** -~~~~~~~~~~~~~~ - -NA - -**Returns** -~~~~~~~~~~~ - -NA - -**Example Code** -~~~~~~~~~~~~~~~~ - -Example: `Simple_RTC `_, `Simple_RTC_Alarm `_ - -.. note :: "rtc.h" must be included to use the class function. - -**RTCClass::Write** -------------------- - -**Description** -~~~~~~~~~~~~~~~ - -Set the specified timestamp in seconds to RTC. - -**Syntax** -~~~~~~~~~~ - -.. code-block:: c++ - - void Write(long long t); - -**Parameters** -~~~~~~~~~~~~~~ - -t: Seconds from 1970.1.1 00:00:00 to specified data and time which is to be set. - -**Returns** -~~~~~~~~~~~ - -NA - -**Example Code** -~~~~~~~~~~~~~~~~ - -Example: `Simple_RTC `_, `Simple_RTC_Alarm `_ - -.. note :: "rtc.h" must be included to use the class function. - -**RTCClass::Read** ------------------- - -**Description** -~~~~~~~~~~~~~~~ - -Get current timestamp in seconds from RTC. - -**Syntax** -~~~~~~~~~~ - -.. code-block:: c++ - - long long Read(void); - -**Parameters** -~~~~~~~~~~~~~~ - -NA - -**Returns** -~~~~~~~~~~~ - -The current timestamp in seconds which is calculated from 1970.1.100:00:00. - -**Example Code** -~~~~~~~~~~~~~~~~ - -Example: `Simple_RTC `_, `Simple_RTC_Alarm `_ - -.. note :: "rtc.h" must be included to use the class function. - -**RTCClass::Wait** ------------------- - -**Description** -~~~~~~~~~~~~~~~ - -Wait for seconds. A delay function. - -**Syntax** -~~~~~~~~~~ - -.. code-block:: c++ - - void Wait(int s); - -**Parameters** -~~~~~~~~~~~~~~ - -s: delay time in seconds. - -**Returns** -~~~~~~~~~~~ - -NA - -**Example Code** -~~~~~~~~~~~~~~~~ - -Example: `Simple_RTC `_, `Simple_RTC_Alarm `_ - -.. note :: "rtc.h" must be included to use the class function. - -**RTCClass::SetEpoch** ----------------------- - -**Description** -~~~~~~~~~~~~~~~ - -Convert human readable time to epoch time. - -**Syntax** -~~~~~~~~~~ - -long long SetEpoch(int year, int month, int day, int hour, int min, int sec); - -**Parameters** -~~~~~~~~~~~~~~ - -year: Input time in year. - -- Start from 1900 - -month: Input time in month. - -- 0 to 11 - -day: Input time unit in day. - -- 1 to 31 - -hour: Input time unit in hour. - -- 0 to 23 - -min: Input time unit in min. - -- 0 to 59 - -sec: Input time unit in sec. - -- 0 to 59 - -**Returns** -~~~~~~~~~~~ - -The epoch time of the input date. - -**Example Code** -~~~~~~~~~~~~~~~~ - -Example: `Simple_RTC `_, `Simple_RTC_Alarm `_ - -.. note :: "rtc.h" must be included to use the class function. - -**RTCClass::EnableAlarm** -------------------------- - -**Description** -~~~~~~~~~~~~~~~ - -Enable the RTC alarm. - -**Syntax** -~~~~~~~~~~ - -.. code-block:: c++ - - void EnableAlarm(int day, int hour, int min, int sec, void(*rtc_handler)(void)); - -**Parameters** -~~~~~~~~~~~~~~ - -day: Alarm time unit in day. - -- 1 to 31 - -hour: Alarm time unit in hour. - -- 0 to 23 - -min: Alarm time unit in min. - -- 0 to 59 - -sec: Alarm time unit in sec. - -- 0 to 59 - -rtc_handler: the callback function for rtc alarm interrupt. - -**Returns** -~~~~~~~~~~~ - -NA - -**Example Code** -~~~~~~~~~~~~~~~~ - -Example: `Simple_RTC `_, `Simple_RTC_Alarm `_ - -.. note :: "rtc.h" must be included to use the class function. - -**RTCClass::DisableAlarm** --------------------------- - -**Description** -~~~~~~~~~~~~~~~ - -Disable the RTC alarm. - -**Syntax** -~~~~~~~~~~ - -.. code-block:: c++ - - void DisableAlarm(void); - -**Parameters** -~~~~~~~~~~~~~~ - -NA - -**Returns** -~~~~~~~~~~~ - -NA - -**Example Code** -~~~~~~~~~~~~~~~~ - -Example: `Simple_RTC `_, `Simple_RTC_Alarm `_ - -.. note :: "rtc.h" must be included to use the class function. diff --git a/bak/ambd/_common/API_Documents/SoftwareSerial/Class Adafruit_GPS.rst b/bak/ambd/_common/API_Documents/SoftwareSerial/Class Adafruit_GPS.rst deleted file mode 100644 index f5248d3..0000000 --- a/bak/ambd/_common/API_Documents/SoftwareSerial/Class Adafruit_GPS.rst +++ /dev/null @@ -1,679 +0,0 @@ -#################### -Class Adafruit_GPS -#################### - -**Description** - -Defines a class to use GPS module on Ameba. - -**Syntax** - -.. code:: cpp - - class Adafruit_GPS - -**Members** - -+---------------------------------+-----------------------------------+ -| **Public Constructors** |   | -+=================================+===================================+ -| Adafruit_GPS::Adafruit_GPS | Constructs an Adafruit_GPS object | -+---------------------------------+-----------------------------------+ -| **Public Methods** |   | -+---------------------------------+-----------------------------------+ -| Adafruit_GPS::begin | Initialize serial communication | -+---------------------------------+-----------------------------------+ -| \*Adafruit_GPS:: lastNMEA | Returns the last NMEA line | -| | received and unsets the received | -| | flag | -+---------------------------------+-----------------------------------+ -| Adafruit_GPS:: newNMEAreceived | Check to see if a new NMEA line | -| | has been received | -+---------------------------------+-----------------------------------+ -| Adafruit_GPS:: common_init | Initialization code used by all | -| | constructor types | -+---------------------------------+-----------------------------------+ -| Adafruit_GPS:: sendCommand | Send a command to the GPS device | -+---------------------------------+-----------------------------------+ -| Adafruit_GPS:: pause | Pause/unpause receiving new data | -+---------------------------------+-----------------------------------+ -| Adafruit_GPS:: parseHex | Read a Hex value and return the | -| | decimal equivalent | -+---------------------------------+-----------------------------------+ -| Adafruit_GPS:: read | Read one character from the GPS | -| | device | -+---------------------------------+-----------------------------------+ -| Adafruit_GPS:: parse | Parse an NMEA string | -+---------------------------------+-----------------------------------+ -| Adafruit_GPS:: wakeup | Wake the sensor up | -+---------------------------------+-----------------------------------+ -| Adafruit_GPS:: standby | Standby Mode Switches | -+---------------------------------+-----------------------------------+ -| Adafruit_GPS::waitForSentence | Wait for a specified sentence | -| | from the device | -+---------------------------------+-----------------------------------+ -| Adafruit_GPS::LOCUS_StartLogger | Start the LOCUS logger | -+---------------------------------+-----------------------------------+ -| Adafruit_GPS::LOCUS_StopLogger | Stop the LOCUS logger | -+---------------------------------+-----------------------------------+ -| Adafruit_GPS::LOCUS_ReadStatus | Read the logger status | -+---------------------------------+-----------------------------------+ - --------------------------------------------------------------------------------------- - -.. method:: Adafruit_GPS::Adafruit_GPS - - -**Description** - -Constructs an Adafruit_GPS object and initialize serial using a -SoftSerial object. - -**Syntax** - -.. code:: cpp - - Adafruit_GPS::Adafruit_GPS(SoftwareSerial *ser) - -.. code:: cpp - - Adafruit_GPS::Adafruit_GPS(HardwareSerial *ser) - -**Parameters** - -``ser`` : a Serial instance - -**Returns** - -The function returns nothing. - -**Example Code** - -This example code from Adafruit demonstrates GPS modules using -MTK3329/MTK3339 driver. This code shows how to listen to the GPS -module in an interrupt which allows the program to have more ‘freedom’ -– just parse when a new NMEA sentence is available! Then access data -when desired. - -.. code-block:: cpp - :caption: Adafruit_GPS_parsing.ino - :linenos: - - #include - #include - - // If you're using a GPS module: - // Connect the GPS Power pin to 3.3V - // Connect the GPS Ground pin to ground - // Connect the GPS TX (transmit) pin to Digital 0 - // Connect the GPS RX (receive) pin to Digital 1 - #if defined(BOARD_RTL8195A) - SoftwareSerial mySerial(0, 1); - #elif defined(BOARD_RTL8710) - SoftwareSerial mySerial(17, 5); // RTL8710 need change GPS TX/RX to pin 17 and 5 - #else - SoftwareSerial mySerial(0, 1); - #endif - - Adafruit_GPS GPS(&mySerial); - - // Set GPSECHO to 'false' to turn off echoing the GPS data to the Serial console - // Set to 'true' if you want to debug and listen to the raw GPS sentences. - #define GPSECHO false - - void setup() - { - Serial.begin(38400); - Serial.println("Adafruit GPS library basic test!"); - - // 9600 NMEA is the default baud rate for Adafruit MTK GPS's- some use 4800 - GPS.begin(9600); - - // uncomment this line to turn on RMC (recommended minimum) and GGA (fix data) including altitude - GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA); - // uncomment this line to turn on only the "minimum recommended" data - //GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCONLY); - // For parsing data, we don't suggest using anything but either RMC only or RMC+GGA since - // the parser doesn't care about other sentences at this time - - // Set the update rate - GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ); // 1 Hz update rate - // For the parsing code to work nicely and have time to sort thru the data, and - // print it out we don't suggest using anything higher than 1 Hz - - // Request updates on antenna status, comment out to keep quiet - GPS.sendCommand(PGCMD_ANTENNA); - - delay(1000); - // Ask for firmware version - mySerial.println(PMTK_Q_RELEASE); - } - - uint32_t timer = millis(); - void loop() // run over and over again - { - // in case you are not using the interrupt above, you'll - // need to 'hand query' the GPS, not suggested :( - // read data from the GPS in the 'main loop' - char c = GPS.read(); - // if you want to debug, this is a good time to do it! - if (GPSECHO) - if (c) Serial.print(c); - - // if a sentence is received, we can check the checksum, parse it... - if (GPS.newNMEAreceived()) { - // a tricky thing here is if we print the NMEA sentence, or data - // we end up not listening and catching other sentences! - // so be very wary if using OUTPUT_ALLDATA and trytng to print out data - //Serial.println(GPS.lastNMEA()); // this also sets the newNMEAreceived() flag to false - - if (!GPS.parse(GPS.lastNMEA())) // this also sets the newNMEAreceived() flag to false - return; // we can fail to parse a sentence in which case we should just wait for another - } - - // if millis() or timer wraps around, we'll just reset it - if (timer > millis()) timer = millis(); - - // approximately every 2 seconds or so, print out the current stats - if (millis() - timer > 2000) { - timer = millis(); // reset the timer - - Serial.print("\nTime: "); - Serial.print(GPS.hour, DEC); Serial.print(':'); - Serial.print(GPS.minute, DEC); Serial.print(':'); - Serial.print(GPS.seconds, DEC); Serial.print('.'); - Serial.println(GPS.milliseconds); - Serial.print("Date: "); - Serial.print(GPS.day, DEC); Serial.print('/'); - Serial.print(GPS.month, DEC); Serial.print("/20"); - Serial.println(GPS.year, DEC); - Serial.print("Fix: "); Serial.print((int)GPS.fix); - Serial.print(" quality: "); Serial.println((int)GPS.fixquality); - if (GPS.fix) { - Serial.print("Location: "); - Serial.print(GPS.latitude, 4); Serial.print(GPS.lat); - Serial.print(", "); - Serial.print(GPS.longitude, 4); Serial.println(GPS.lon); - Serial.print("Location (in degrees, works with Google Maps): "); - Serial.print(GPS.latitudeDegrees, 4); - Serial.print(", "); - Serial.println(GPS.longitudeDegrees, 4); - - Serial.print("Speed (knots): "); Serial.println(GPS.speed); - Serial.print("Angle: "); Serial.println(GPS.angle); - Serial.print("Altitude: "); Serial.println(GPS.altitude); - Serial.print("Satellites: "); Serial.println((int)GPS.satellites); - } - } - } - -**Notes and Warnings** - -.. important:: - SoftSerial is using hardware serial so pin mapping cannot be altered. - -------------------------------------------------------------------------------------------------------------- - -.. method:: Adafruit_GPS::begin - -**Description** - -Initialize serial communication - -**Syntax** - -.. code-block:: cpp - - void Adafruit_GPS::begin(uint16_t baud) - -**Parameters** - -``baud`` : serial baud rate - -**Returns** - -The function returns nothing. - -**Example Code** - -Example: Adafruit_GPS_parsing - -The details of the code can be found in the previous section of -Adafruit_GPS:: Adafruit_GPS. - -**Notes and Warnings** - -NA - ------------------------------------------------------------------------------------------------------------ - -.. method:: Adafruit_GPS::lastNMEA - -**Description** - -Returns the last NMEA line received and unsets the received flag - -**Syntax** - -.. code:: cpp - - char *Adafruit_GPS::lastNMEA(void0) - -**Parameters** - -The function requires no input parameter. - -**Returns** - -Pointer to the last line string - -**Example Code** - -Example: Adafruit_GPS_parsing - -The details of the code can be found in the previous section of -Adafruit_GPS:: Adafruit_GPS. - -**Notes and Warnings** - -NA - ------------------------------------------------------------------------------------------------------------- - -.. method:: Adafruit_GPS::newNMEAreceived - -**Description** - -Check to see if a new NMEA line has been received - -**Syntax** - -.. code:: cpp - - boolean Adafruit_GPS::newNMEAreceived(void) - -**Parameters** - -The function requires no input parameter. - -**Returns** - -True if received, false if not - -**Example Code** - -Example: Adafruit_GPS_parsing -The details of the code can be found in the previous section of -Adafruit_GPS:: Adafruit_GPS. - -**Notes and Warnings** - -NA - ------------------------------------------------------------------------------------------------------------- - -.. method:: Adafruit_GPS::common_init - -**Description** - -Initialization code used by all constructor types - -**Syntax** - -.. code:: cpp - - void Adafruit_GPS::common_init(void) - -**Parameters** - -The function requires no input parameter. - -**Returns** - -The function returns nothing. - -**Example Code** - -NA - -**Notes and Warnings** - -NA - ------------------------------------------------------------------------------------------------------------- - -.. method:: Adafruit_GPS::sendCommand  - -**Description** - -Send a command to the GPS device - -**Syntax** - -.. code:: cpp - - void Adafruit_GPS::sendCommand(const char * str) - -**Parameters** - -``str`` : Pointer to a string holding the command to send - -**Returns** - -The function returns nothing. - -**Example Code** - -Example: Adafruit_GPS_parsing - -The details of the code can be found in the previous section of -Adafruit_GPS:: Adafruit_GPS. - -**Notes and Warnings** - -NA -  ---------------------------------------------------------------------------------------------------------------- - -.. method:: Adafruit_GPS::pause - -**Description** - -Pause/unpause receiving new data - -**Syntax** - -.. code:: cpp - - void Adafruit_GPS::pause(boolean p) - -**Parameters** - -``p`` : True = pause, false = unpause - -**Returns** - -The function returns nothing. - -**Example Code** - -NA - -**Notes and Warnings** - -NA - ---------------------------------------------------------------------------------------------------------------- - -.. method:: Adafruit_GPS::parseHex - -**Description** - -Read a Hex value and return the decimal equivalent - -**Syntax** - -.. code:: cpp - - uint8_t Adafruit_GPS::parseHex(char c) - -**Parameters** - -``c`` : Hex value - -**Returns** - -The decimal equivalent of the Hex value - -**Example Code** - -NA - -**Notes and Warnings** - -NA -  --------------------------------------------------------------------------------------------------------------- - -.. method:: Adafruit_GPS::read - -**Description** - -Read one character from the GPS device - -**Syntax** - -.. code:: cpp - - char Adafruit_GPS::read(void) - -**Parameters** - -The function requires no input parameter. - -**Returns** - -The character that we received, or 0 if nothing was available - -**Example Code** - -Example: Adafruit_GPS_parsing - -The details of the code can be found in the previous section of -Adafruit_GPS:: Adafruit_GPS. - -**Notes and Warnings** - -NA -   ------------------------------------------------------------------------------------------------------------------- - -.. method:: Adafruit_GPS::parse - -**Description** - -Parse an NMEA string - -**Syntax** - -.. code:: cpp - - boolean Adafruit_GPS::parse(char * nmea) - -**Parameters** - -``nmea`` : an NMEA string - -**Returns** - -True if we parsed it, false if it has invalid data - -**Example Code** - -Example: Adafruit_GPS_parsing - -**Notes and Warnings** - -NA -  ----------------------------------------------------------------------------------------------------------------------- - -.. method:: Adafruit_GPS::wakeup - -**Description** - -Wake the sensor up - -**Syntax** - -.. code:: cpp - - boolean Adafruit_GPS::wakeup(void) - -**Parameters** - -The function requires no input parameter. - -**Returns** - -True if woken up, false if not in standby or failed to wake - -**Example Code** - -NA - -**Notes and Warnings** - -NA -  ------------------------------------------------------------------------------------------------------------------------- - -.. method:: Adafruit_GPS::standby - -**Description** - -Standby Mode Switches - -**Syntax** - -.. code:: cpp - - boolean Adafruit_GPS::standby(void) - -**Parameters** - -The function requires no input parameter. - -**Returns** - -False if already in standby, true if it entered standby - -**Example Code** - -NA - -**Notes and Warnings** - -NA - --------------------------------------------------------------------------------------------------------------------------- - -.. method:: Adafruit_GPS::waitForSentence   - -**Description** - -Wait for a specified sentence from the device - -**Syntax** - -.. code:: cpp - - boolean Adafruit_GPS::waitForSentence(const char * wait4me, uint8_tmax) - -**Parameters** - -wait4me: Pointer to a string holding the desired response -max: How long to wait, default is MAXWAITSENTENCE - -**Returns** - -True if we got what we wanted, false otherwise - -**Example Code** - -NA - -**Notes and Warnings** - -NA - --------------------------------------------------------------------------------------------------------------------------- - -.. method:: Adafruit_GPS::LOCUS_StartLogger  - -**Description** - -Start the LOCUS logger - -**Syntax** - -.. code:: cpp - - boolean Adafruit_GPS::LOCUS_StartLogger(void) - -**Parameters** - -The function requires no input parameter. - -**Returns** - -True on success, false if it failed - -**Example Code** - -NA - -**Notes and Warnings** - -NA -   --------------------------------------------------------------------------------------------------------------------------- - -.. method:: Adafruit_GPS::LOCUS_StopLogger - -**Description** - -Stop the LOCUS logger - -**Syntax** - -.. code:: cpp - - boolean Adafruit_GPS::LOCUS_StopLogger(void) - -**Parameters** - -The function requires no input parameter. - -**Returns** - -True on success, false if it failed - -**Example Code** - -NA - -**Notes and Warnings** - -NA - --------------------------------------------------------------------------------------------------------------------------- - -.. method:: Adafruit_GPS::LOCUS_ReadStatus  - -**Description** - -Read the logger status - -**Syntax** - -.. code:: cpp - - boolean Adafruit_GPS::LOCUS_ReadStatus(void) - -**Parameters** - -The function requires no input parameter. - -**Returns** - -True if we read the data, false if there was no response - -**Example Code** - -NA - -**Notes and Warnings** - -NA -   diff --git a/bak/ambd/_common/API_Documents/SoftwareSerial/Class SoftwareSerial.rst b/bak/ambd/_common/API_Documents/SoftwareSerial/Class SoftwareSerial.rst deleted file mode 100644 index 9fb7b94..0000000 --- a/bak/ambd/_common/API_Documents/SoftwareSerial/Class SoftwareSerial.rst +++ /dev/null @@ -1,653 +0,0 @@ -##################### -Class SoftwareSerial -##################### - - -**Description** - -Defines a class of software serial implementation for Ameba. - -**Syntax** - -.. code:: cpp - - class SoftwareSerial - -**Members** - -+----------------------------------+----------------------------------+ -| **Public Constructors** |   | -+==================================+==================================+ -| SoftwareSerial::SoftwareSerial | Constructs a SoftwareSerial | -| | object | -+----------------------------------+----------------------------------+ - -+----------------------------------+----------------------------------+ -| **Public Methods** |   | -+==================================+==================================+ -| SoftwareSerial::begin | Sets the speed (baud rate) for | -| | the serial communication | -+----------------------------------+----------------------------------+ -| SoftwareSerial::listen | Enables the selected software | -| | serial port to listen | -+----------------------------------+----------------------------------+ -| SoftwareSerial::end | Same as stopListening | -+----------------------------------+----------------------------------+ -| SoftwareSerial::stopListening | Stop listening on the port | -+----------------------------------+----------------------------------+ -| SoftwareSerial::peek | Return a character that was | -| | received on the RX pin of the | -| | software serial port | -+----------------------------------+----------------------------------+ -| SoftwareSerial::write | Prints data to the transmit pin | -| | of the software serial port as | -| | raw bytes | -+----------------------------------+----------------------------------+ -| SoftwareSerial::read | Return a character that was | -| | received on the RX pin of the | -| | software serial port | -+----------------------------------+----------------------------------+ -| SoftwareSerial::available | Get the number of bytes | -| | (characters) available for | -| | reading from a software serial | -| | port | -+----------------------------------+----------------------------------+ -| SoftwareSerial::flush | Flush the received buffer | -+----------------------------------+----------------------------------+ -| SoftwareSerial::setBufferSize | Set buffer size | -+----------------------------------+----------------------------------+ -| Soft | Set available callback | -| wareSerial::setAvailableCallback | | -+----------------------------------+----------------------------------+ -| SoftwareSerial::handle_interrupt | Private methods handles | -| | interrupt | -+----------------------------------+----------------------------------+ - ------ - -.. method:: SoftwareSerial::SoftwareSerial - - -**Description** - -Constructs a SoftwareSerial object and sets RX and TX pin, and inverse -logic. - -**Syntax** - -.. code:: cpp - - SoftwareSerial::SoftwareSerial(uint8_t receivePin, uint8_t transmitPin, bool inverse_logic /* = false */) - -**Parameters** - -``receivePin`` : the pin on which to receive serial data - -``transmitPin`` : the pin on which to transmit serial data - -``inverse_logic``: is used to invert the sense of incoming bits - -**Returns** - -The function returns nothing. - -**Example Code** - -Example: SoftwareSerialExample - -The example demonstrates a software serial test, it receives from -serial RX and sends it to serial TX. - -.. code:: cpp - - /* - The circuit: (BOARD RTL8195A) - * RX is digital pin 0 (connect to TX of other devices) - * TX is digital pin 1 (connect to RX of other devices) - */ - #include "SoftwareSerial.h" - - #if defined(BOARD_RTL8195A) - SoftwareSerial mySerial(0, 1); // RX, TX - #elif defined(BOARD_RTL8710) - SoftwareSerial mySerial(17, 5); // RX, TX - #else - SoftwareSerial mySerial(0, 1); // RX, TX - #endif - - void setup() { - // Open serial communications and wait for port to open: - Serial.begin(57600); - while (!Serial) { - ; // wait for serial port to connect. Needed for native USB port only - } - - - Serial.println("Goodnight moon!"); - - // set the data rate for the SoftwareSerial port - mySerial.begin(4800); - mySerial.println("Hello, world?"); - } - - void loop() { // run over and over - if (mySerial.available()) { - mySerial.write(mySerial.read()); - } - } - - -**Notes and Warnings** - -Software Serial is using hardware serial thus DO NOT change the -default pins - ------ - -.. method:: SoftwareSerial::begin - - -**Description** - -Sets the speed (baud rate) for the serial communication - -**Syntax** - -.. code:: cpp - - void SoftwareSerial::begin(long speed) - -.. code:: cpp - - void SoftwareSerial::begin(long speed, int data_bits, int parity, int stop_bits) - -.. code:: cpp - - void SoftwareSerial::begin(long speed, int data_bits, int parity, int stop_bits, int flowctrl, int rtsPin, int ctsPin) - -**Parameters** - -``speed`` : the baud rate - -``data_bits`` : number of data bits, 8 bits(default) or 7 bits - -``stop_bits`` : number of stop bits, 1 bit(default), 1.5 bits or 2 bits - -``flowctrl`` : flow control pin - -``rtsPin`` : request to send pin - -``ctsPin`` : clear to send pin - -**Returns** - -The function returns nothing. - -**Example Code** - -Example: SoftwareSerialExample - -The example demonstrates a software serial test, it receives from -serial RX and sends it to serial TX. Details of the code can be found -in the previous section of SoftwareSerial_Basic:: SoftwareSerial. - -**Notes and Warnings** - -NA - ------ - -.. method:: SoftwareSerial::listen - -**Description** - -Enables the selected software serial port to listen - -**Syntax** - -.. code:: cpp - - bool SoftwareSerial::listen(void) - -**Parameters** - -The function requires no input parameter. - -**Returns** - -Returns true if it replaces another - -**Example Code** - -NA - -**Notes and Warnings** - -NA - ------ - -.. method:: SoftwareSerial::end - - -**Description** - -Same as stopListening - -**Syntax** - -.. code:: cpp - - void SoftwareSerial::end(void) - -**Parameters** - -The function requires no input parameter. - -**Returns** - -The function returns nothing. - -**Example Code** - -NA - -**Notes and Warnings** - -NA - ------ - -**SoftwareSerial::isListening** - - -**Description** - -Tests to see if requested software serial port is actively listening - -**Syntax** - -.. code:: cpp - - bool SoftwareSerial::isListening(void) - -**Parameters** - -The function requires no input parameter. - -**Returns** - -The function returns “True” if the port is listening. - -**Example Code** - -NA - -**Notes and Warnings** - -NA - ------ - -.. method:: SoftwareSerial::stopListening - - -**Description** - -Stop listening on the port - -**Syntax** - -.. code:: cpp - - bool SoftwareSerial::stopListening(void) - -**Parameters** - -The function requires no input parameter. - -**Returns** - -The function returns “True” if listening on the port is stopped. - -**Example Code** - -NA - -**Notes and Warnings** - -NA - ------ - -.. method:: SoftwareSerial::peek - - -**Description** - -Return a character that was received on the RX pin of the software -serial port - -**Syntax** - -.. code:: cpp - - int SoftwareSerial::peek(void) - -**Parameters** - -The function requires no input parameter. - -**Returns** - -The function returns the character read, or returns “-1” if none is - -available. - -**Example Code** - -NA - -**Notes and Warnings** - -NA - ------ - -.. method:: SoftwareSerial::write - - -**Description** - -Prints data to the transmit pin of the software serial port as raw -bytes - -**Syntax** - -.. code:: cpp - - size_t SoftwareSerial::write(uint8_t b) - -**Parameters** - -``b`` : byte to be written - -**Returns** - -The function returns the number of bytes written. - -**Example Code** - -Example: SoftwareSerialExample - -The example demonstrates a software serial test, it receives from -serial RX and sends it to serial TX. Details of the code can be found -in the previous section of SoftwareSerial:: SoftwareSerial. - -**Notes and Warnings** - -NA - ------- - -.. method:: SoftwareSerial::read - - -**Description** - -Return a character that was received on the RX pin of the software -serial port - -**Syntax** - -.. code:: cpp - - int SoftwareSerial::read(void) - -**Parameters** - -The function requires no input parameter. - -**Returns** - -The function returns the character read, or -1 if none is available. - -**Example Code** - -Example: SoftwareSerialExample - -The example demonstrates a software serial test, it receives from -serial RX and sends it to serial TX. Details of the code can be found -in the previous section of SoftwareSerial:: SoftwareSerial. - -**Notes and Warnings** - -NA - ------ - -.. method:: SoftwareSerial::available - - -**Description** - -Get the number of bytes available for reading from a software serial - -port - -**Syntax** - -.. code:: cpp - - int SoftwareSerial::available(void) - -**Parameters** - -The function requires no input parameter. - -**Returns** - -The function returns the number of bytes available to read. - -**Example Code** - -Example: SoftwareSerialExample - -The example demonstrates a software serial test, it receives from -serial RX and sends it to serial TX. Details of the code can be found -in the previous section of SoftwareSerial:: SoftwareSerial. - -**Notes and Warnings** - -NA - ------ - -.. method:: SoftwareSerial::flush - - -**Description** - -Flush the received buffer - -**Syntax** - -.. code:: cpp - - void SoftwareSerial::flush(void) - -**Parameters** - -The function requires no input parameter. - -**Returns** - -The function returns nothing. - -**Example Code** - -NA - -**Notes and Warnings** - -NA - ------ - -.. method:: SoftwareSerial::setBufferSize - - -**Description** - -Set buffer size - -**Syntax** - -.. code:: cpp - - void SoftwareSerial::setBufferSize(uint32_t buffer_size) - -**Parameters** - -``buffer_size`` : the size of the serial buffer - -**Returns** - -The function returns nothing. - -**Example Code** - -NA - -**Notes and Warnings** - -NA - ------ - -.. method:: SoftwareSerial::setAvailableCallback - - -**Description** - -Set available callback - -**Syntax** - -.. code:: cpp - - void SoftwareSerial::setAvailableCallback(void (*callback)(char c)) - -**Parameters** - -``*callback``: user-defined serial callback function - -**Returns** - -The function returns nothing. - -**Example Code** - -Example: SoftwareSerialIrqCallback - -This example demonstrates the software serial testing using IRQ -callback and semaphore. Set callback function “mySerialCalback” to -software serial. Whenever there is data comes in, “mySerialCallback” -is invoked. In this sketch, it does nothing until the end of the line. -And then it sends a semaphore. The loop() uses a non-busy loop to wait -for the semaphore. To test this sketch, you need to type something on -software serial and then press Enter. - -.. code:: cpp - - - /* - The circuit: (BOARD RTL8195A) - RX is digital pin 0 (connect to TX of other devices) - TX is digital pin 1 (connect to RX of other devices) - */ - #include "SoftwareSerial.h" - - #if defined(BOARD_RTL8195A) - SoftwareSerial mySerial(0, 1); // RX, TX - #elif defined(BOARD_RTL8710) - SoftwareSerial mySerial(17, 5); // RX, TX - #else - SoftwareSerial mySerial(0, 1); // RX, TX - #endif - - uint32_t semaID; - - // The callback is hooking at UART IRQ handler and please don't do heavy task here. - void mySerialCallback(char c) - { - /* The parameter c is only for peeking. The actual data is - * still in the buffer of SoftwareSerial. - */ - if (c == '\r' || c == '\n') { - os_semaphore_release(semaID); - } - } - - void setup() { - // use 1 count for binary semaphore - semaID = os_semaphore_create(1); - - // There is a token in the semaphore, clear it. - os_semaphore_wait(semaID, 0xFFFFFFFF); - - // set the data rate for the SoftwareSerial port - mySerial.begin(38400); - mySerial.setAvailableCallback(mySerialCallback); - } - - void loop() { // run over and over - // wait semaphore for 5s timeout - if (os_semaphore_wait(semaID, 5 * 1000)) { - // we got data before timeout - while(mySerial.available()) { - mySerial.print((char)mySerial.read()); - } - mySerial.println(); - } else { - mySerial.println("No data comes in."); - } - } - - -**Notes and Warnings** - -NA - ------ - -.. method:: SoftwareSerial::handle_interrupt - - -**Description** - -A private method handles the interrupt - -**Syntax** - -.. code:: cpp - - void handle_interrupt(uint32_t id, uint32_t event) - -**Parameters** - -``id`` : the interupt id - -``event`` : interrupt event - -**Returns** - -The function returns nothing. - -**Example Code** - -NA - -**Notes and Warnings** - -NA diff --git a/bak/ambd/_common/API_Documents/Sys/Wiring_OS_API.rst b/bak/ambd/_common/API_Documents/Sys/Wiring_OS_API.rst deleted file mode 100644 index 1ee2d78..0000000 --- a/bak/ambd/_common/API_Documents/Sys/Wiring_OS_API.rst +++ /dev/null @@ -1,473 +0,0 @@ -Wiring_OS_API -=================== -**Wiring OS API** - -| **Description** -| A wrapper to CMSIS (Cortex Microcontroller Software Interface - Standard) OS API which serve as a RTOS to create multi-threaded - application with real-time behaviour. - -| **Syntax** -| NA - -**Members** - -+--------------------------------+------------------------------------+ -| **Public Methods** |   | -+================================+====================================+ -| os_thread_create_arduino | Create a thread and add it to | -| | Active Threads and set it to state | -| | READY | -+--------------------------------+------------------------------------+ -| os_thread_get_id_arduino | Return the thread ID of the | -| | current running thread | -+--------------------------------+------------------------------------+ -| os_thread_terminate_arduino | Terminate execution of a thread | -| | and remove it from Active Threads | -+--------------------------------+------------------------------------+ -| os_thread_yield_arduino | Pass control to next thread that | -| | is in state READY | -+--------------------------------+------------------------------------+ -| os_thread_set_priority_arduino | Change priority of an active | -| | thread | -+--------------------------------+------------------------------------+ -| os_thread_get_priority_arduino | Get current priority of an active | -| | thread | -+--------------------------------+------------------------------------+ -| os_signal_set_arduino | Set the specified Signal Flags of | -| | an active thread | -+--------------------------------+------------------------------------+ -| os_signal_clear_arduino | Clear the specified Signal Flags | -| | of an active thread | -+--------------------------------+------------------------------------+ -| os_signal_wait_arduino | Wait for one or more Signal Flags | -| | to become signaled for the current | -| | RUNNING thread | -+--------------------------------+------------------------------------+ -| os_timer_create_arduino | Create a timer | -+--------------------------------+------------------------------------+ -| os_timer_start_arduino | Start or restart a timer | -+--------------------------------+------------------------------------+ -| os_timer_stop_arduino | Stop the timer | -+--------------------------------+------------------------------------+ -| os_timer_delete_arduino | Delete a timer that was created by | -| | os_timer_create | -+--------------------------------+------------------------------------+ -| os_semaphore_create_arduino | Create and Initialize a Semaphore | -| | object used for managing resources | -+--------------------------------+------------------------------------+ -| os_semaphore_wait_arduino | Wait until a Semaphore token | -| | becomes available | -+--------------------------------+------------------------------------+ -| os_semaphore_release_arduino | Release a Semaphore token | -+--------------------------------+------------------------------------+ -| os_semaphore_delete_arduino | Delete a Semaphore that was | -| | created by os_semaphore_create | -+--------------------------------+------------------------------------+ -| os_get_free_heap_size_arduino | Return the available heap memory | -| | space when called | -+--------------------------------+------------------------------------+ - -**os_thread_create_arduino** - -| **Description** -| Create a thread and add it to Active Threads and set it to state - READY. - -| **Syntax** -| uint32_t os_thread_create_arduino (void (\*task)(const void - \*argument), void \*argument, int priority, uint32_t stack_size); - -| **Parameters** -| task: task Function pointer which is the thread body. It should not - run into the end of function unless os_thread_terminate is invoked -| argument: the data pointer which brings to task -| priority: The underlying os is FreeRTOS. It executes tasks with - highest priority which are not in idle state. -| stack_size: The stack_size is used as memory heap only for this task. - -| **Returns** -| The thread id which is used in thread operation and signalling. - -| **Example Code** -| NA - -| **Notes and Warnings** -| NA -|   - -**os_thread_get_id_arduino** - -| **Description** -| Return the thread ID of the current running thread - -| **Syntax** -| uint32_t os_thread_get_id_arduino (void); - -| **Parameters** -| The function requires no input parameter. - -| **Returns** -| Current thread id which calls os_thread_get_id. - -| **Example Code** -| NA - -| **Notes and Warnings** -| NA -|   - -**os_thread_terminate_arduino** - -| **Description** -| Terminate execution of a thread and remove it from Active Threads - -| **Syntax** -| uint32_t os_thread_terminate_arduino (uint32_t thread_id); - -| **Parameters** -| thread_id: Terminate the thread with specific thread_id - -| **Returns** -| os_status code - -| **Example Code** -| NA - -| **Notes and Warnings** -| Thread should not ended without terminate first. -|   - -**os_thread_yield_arduino** - -| **Description** -| Pass control to next thread that is in state READY - -| **Syntax** -| uint32_t os_thread_yield_arduino (void); - -| **Parameters** -| The function requires no input parameter. - -| **Returns** -| os_status code - -| **Example Code** -| NA - -| **Notes and Warnings** -| By default, the minimal execution unit is 1 millisecond. In a scenario - that if a thread with smaller want to handout execution right to a - thread with higher priority immediately without waiting for the ending - of current 1 millisecond, then invoke os_thread_yield can transfer - exection right to OS’s idle task and check which is the next execution - thread. -|   - -**os_thread_set_priority_arduino** - -| **Description** -| Change priority of an active thread - -| **Syntax** -| uint32_t os_thread_set_priority_arduino (uint32_t thread_id, int - priority); - -| **Parameters** -| thread_id: The target thread with the thread id to be changed -| priority: The updated priority - -| **Returns** -| The function returns nothing. - -| **Example Code** -| NA - -| **Notes and Warnings** -| NA -|   - -**os_thread_get_priority_arduino** - -| **Description** -| Get current priority of an active thread - -| **Syntax** -| uint32_t os_thread_get_priority_arduino (uint32_t thread_id); - -| **Parameters** -| thread_id: The target thread with the thread id to be searched - -| **Returns** -| os_priority - -| **Example Code** -| NA - -| **Notes and Warnings** -| NA -|   - -**os_signal_set_arduino** - -| **Description** -| Set the specified Signal Flags of an active thread - -| **Syntax** -| int32_t os_signal_set_arduino (uint32_t thread_id, int32_t signals); - -| **Parameters** -| thread_id: Send signal to a thread with the thread id -| signals: the signals to be send - -| **Returns** -| os_status code - -| **Example Code** -| NA - -| **Notes and Warnings** -| NA -|   - -**os_signal_clear_arduino** - -| **Description** -| Clear the specified Signal Flags of an active thread - -| **Syntax** -| int32_t os_signal_clear_arduino (uint32_t thread_id, int32_t signals); - -| **Parameters** -| thread_id: Clear signal to a thread with the thread id -| signals: The signals to be clear - -| **Returns** -| os_status code - -| **Example Code** -| NA - -| **Notes and Warnings** -| NA -|   - -**os_signal_wait_arduino** - -| **Description** -| Wait for one or more Signal Flags to become signaled for the current - RUNNING thread - -| **Syntax** -| os_event_t os_signal_wait_arduino (int32_t signals, uint32_t - millisec); - -| **Parameters** -| signals: the signals to be wait -| millisec: the timeout value if no signal comes in. Fill in 0xFFFFFFFF - for infinite wait - -| **Returns** -| os_status code - -| **Example Code** -| NA - -| **Notes and Warnings** -| NA -|   - -**os_timer_create_arduino** - -| **Description** -| Create a timer - -| **Syntax** -| uint32_t os_timer_create_arduino (void (\*callback)(void const - \*argument), uint8_t isPeriodic, void \*argument); - -| **Parameters** -| callback: The function to be invoke when timer timeout -| isPeriodic: OS_TIMER_ONCE or OS_TIMER_PERIODIC -| argument: The argument that is bring into callback function - -| **Returns** -| timer id - -| **Example Code** -| NA - -| **Notes and Warnings** -| NA -|   - -**os_timer_start_arduino** - -| **Description** -| Start or restart a timer - -| **Syntax** -| uint32_t os_timer_start_arduino (uint32_t timer_id, uint32_t - millisec); - -| **Parameters** -| timer_id: The timer id obtained from by os_timer_create -| millisec: The delays after timer starts - -| **Returns** -| os_status code - -| **Example Code** -| NA - -| **Notes and Warnings** -| NA -|   - -**os_timer_stop_arduino** - -| **Description** -| Stop the timer - -| **Syntax** -| uint32_t os_timer_stop_arduino (uint32_t timer_id); - -| **Parameters** -| timer_id: The timer id obtained from by os_timer_create - -| **Returns** -| os_status code - -| **Example Code** -| NA - -| **Notes and Warnings** -| NA -|   - -**os_timer_delete_arduino** - -| **Description** -| Delete a timer that was created by os_timer_create - -| **Syntax** -| uint32_t os_timer_delete_arduino (uint32_t timer_id); - -| **Parameters** -| timer_id: The timer id obtained from by os_timer_create - -| **Returns** -| os_status code - -| **Example Code** -| NA - -| **Notes and Warnings** -| NA -|   - -**os_semaphore_create_arduino** - -| **Description** -| Create and Initialize a Semaphore object used for managing resources - -| **Syntax** -| uint32_t os_semaphore_create_arduino (int32_t count); - -| **Parameters** -| count: The number of available resources - -| **Returns** -| semaphore ID - -| **Example Code** -| NA - -| **Notes and Warnings** -| NA -|   - -**os_semaphore_wait_arduino** - -| **Description** -| Wait until a Semaphore token becomes available - -| **Syntax** -| int32_t os_semaphore_wait_arduino (uint32_t semaphore_id, uint32_t - millisec); - -| **Parameters** -| semaphore_id: semaphore id obtained from os_semaphore_create -| millisec: timeout value - -| **Returns** -| os_status code - -| **Example Code** -| NA - -| **Notes and Warnings** -| NA -|   - -**os_semaphore_release_arduino** - -| **Description** -| Release a Semaphore token - -| **Syntax** -| uint32_t os_semaphore_release_arduino (uint32_t semaphore_id); - -| **Parameters** -| semaphore_id: semaphore id obtained from os_semaphore_create - -| **Returns** -| os_status code - -| **Example Code** -| NA - -| **Notes and Warnings** -| NA -|   - -**os_semaphore_delete_arduino** - -| **Description** -| Delete a Semaphore that was created by os_semaphore_create - -| **Syntax** -| uint32_t os_semaphore_delete_arduino (uint32_t semaphore_id); - -| **Parameters** -| semaphore_id: semaphore id obtained from os_semaphore_create - -| **Returns** -| os_status code - -| **Example Code** -| NA - -| **Notes and Warnings** -| NA -|   - -**os_get_free_heap_size_arduino** - -| **Description** -| Return the available heap memory space when called - -| **Syntax** -| size_t os_get_free_heap_size_arduino(void); - -| **Parameters** -| The function requires no input parameter. - -| **Returns** -| current free heap size - -| **Example Code** -| Example: MemInfo - -| **Notes and Warnings** -| NA diff --git a/bak/ambd/_common/API_Documents/USB/Class USBCDCDevice.rst b/bak/ambd/_common/API_Documents/USB/Class USBCDCDevice.rst deleted file mode 100644 index e16443f..0000000 --- a/bak/ambd/_common/API_Documents/USB/Class USBCDCDevice.rst +++ /dev/null @@ -1,572 +0,0 @@ -#################### -Class USBCDCDevice -#################### - -**Description** - -A class for managing, transmitting, and receiving data using USB CDC ACM -device class. - -**Syntax** - -.. code:: cpp - - class USBCDCDevice - -**Members** - -**Public Constructors** - -The public constructor should not be used as this class is intended to -be a singleton class. Access member functions using the object instance -named ``SerialUSB``. - -**Public Methods** - -+------------------------------------+---------------------------------+ -| USBCDCDevice::setVID | Set USB vendor ID value | -+------------------------------------+---------------------------------+ -| USBCDCDevice::setPID | Set USB product ID value | -+------------------------------------+---------------------------------+ -| U | Set USB manufacturer string | -| SBCDCDevice::setManufacturerString | | -+------------------------------------+---------------------------------+ -| USBCDCDevice::setModelString | Set USB product model string | -+------------------------------------+---------------------------------+ -| USBCDCDevice::setSerialString | Set USB product serial number | -| | string | -+------------------------------------+---------------------------------+ -| USBCDCDevice::USBconnected | Check if the USB port is | -| | connected to a host | -+------------------------------------+---------------------------------+ -| USBCDCDevice::connected | Check if the USB CDC serial | -| | terminal is ready on the host | -+------------------------------------+---------------------------------+ -| USBCDCDevice::dtr | Check DTR signal state | -+------------------------------------+---------------------------------+ -| USBCDCDevice::rts | Check RTS signal state | -+------------------------------------+---------------------------------+ -| USBCDCDevice::begin | Start serial communication | -| | using USB CDC | -+------------------------------------+---------------------------------+ -| USBCDCDevice::end | Stop serial communication using | -| | USB CDC | -+------------------------------------+---------------------------------+ -| USBCDCDevice::available | Get the number of bytes | -| | (characters) available for | -| | reading from the USB serial | -| | port | -+------------------------------------+---------------------------------+ -| USBCDCDevice::peek | Returns the next byte | -| | (character) of incoming serial | -| | data without removing it from | -| | the internal buffer | -+------------------------------------+---------------------------------+ -| USBCDCDevice::read | Reads incoming serial data | -+------------------------------------+---------------------------------+ -| USBCDCDevice::flush | Waits for the transmission of | -| | outgoing serial data to | -| | complete | -+------------------------------------+---------------------------------+ -| USBCDCDevice::write | Writes binary data to the | -| | serial port | -+------------------------------------+---------------------------------+ - ----- - -.. method:: USBCDCDevice::setVID - -**Description** - -Set USB vendor ID value. - -**Syntax** - -.. code:: cpp - - void setVID (uint16_t VID); - -**Parameters** - -``VID`` : vendor ID - -**Returns** - -The function returns nothing. - -**Example Code** - -NA - -**Notes and Warnings** - -The VID should be configured before ``USBCDCDevice::begin()`` function is -called. - ------ - -.. method:: USBCDCDevice::setPID - -**Description** - -Set USB product ID value. - -**Syntax** - -.. code:: cpp - - void setPID (uint16_t PID); - -**Parameters** - -``PID`` : product ID - -**Returns** - -The function returns nothing. - -**Example Code** - -NA - -**Notes and Warnings** - -The PID should be configured before ``USBCDCDevice::begin()`` function is -called. - ----- - -.. method:: USBCDCDevice::setManufacturerString - -**Description** - -Set USB manufacturer string. - -**Syntax** - -.. code:: cpp - - void setManufacturerString (const char* manufacturer); - -**Parameters** - -``manufacturer`` : Character string containing manufacturer name - -**Returns** - -The function returns nothing. - -**Example Code** - -NA - -**Notes and Warnings** - -The manufacturer string should be configured before -``USBCDCDevice::begin()`` function is called. - ----- - -.. method:: USBCDCDevice::setModelString - -**Description** - -Set USB product model string. - -**Syntax** - -.. code:: cpp - - void setModelString (const char* model); - -**Parameters** - -``model`` : Character string containing model name - -**Returns** - -The function returns nothing. - -**Example Code** - -NA - -**Notes and Warnings** - -The model string should be configured before ``USBCDCDevice::begin()`` -function is called. - ----- - -.. method::: USBCDCDevice::setSerialString - -**Description** - -Set USB product serial number string. - -**Syntax** - -.. code:: cpp - - void setSerialString (const char* serial); - -**Parameters** - -``serial`` : Character string containing serial number - -**Returns** - -The function returns nothing. - -**Example Code** - -NA - -**Notes and Warnings** - -The serial string should be configured before ``USBCDCDevice::begin()`` -function is called. - ----- - -.. method:: USBCDCDevice::USBconnected - -**Description** - -Check if the USB port is connected to a host. - -**Syntax** - -.. code:: cpp - - uint8_t USBconnected (); - -**Parameters** - -The function requires no input parameter. - -**Returns** - -The function returns **TRUE** if the USB port is connected to a host, **FALSE** -if it is not connected. - -**Example Code** - -NA - -**Notes and Warnings** - -NA - ----- - -.. method:: USBCDCDevice::connected - -**Description** - -Check if the USB CDC serial terminal is ready on the host. - -**Syntax** - -.. code:: cpp - - uint8_t connected (); - -**Parameters** - -The function requires no input parameter. - -**Returns** - -The function returns **TRUE** if the USB port is connected to a host and the -DTR and RTS signals are set, **FALSE** otherwise. - -**Example Code** - -NA - -**Notes and Warnings** - -NA - ----- - -.. method:: USBCDCDevice::dtr - -**Description** - -Check DTR signal state. - -**Syntax** - -.. code:: cpp - - uint8_t dtr (); - -**Parameters** - -The function requires no input parameter. - -**Returns** - -The function returns the state of the DTR signal line. - -**Example Code** - -NA - -**Notes and Warnings** - -NA - ----- - -.. method:: USBCDCDevice::rts - -**Description** - -Check RTS signal state. - -**Syntax** - -.. code:: cpp - - uint8_t rts (); - -**Parameters** - -The function requires no input parameter. - -**Returns** - -The function returns the state of the RTS signal line. - -**Example Code** - -NA - -**Notes and Warnings** - -NA - ----- - -.. method:: USBCDCDevice::begin - -**Description** - -Start serial communication using USB CDC. - -**Syntax** - -.. code:: cpp - - void begin (uint32_t baud); - -**Parameters** - -``baud`` : baud rate - -**Returns** - -The function returns nothing. - -**Example Code** - -Example: USBCDCSerial - -**Notes and Warnings** - -The baud rate parameter has no significance in the context of a USB CDC -serial port and can be left empty. - ----- - -.. method:: USBCDCDevice::end - -**Description** - -Stop serial communication using USB CDC. - -**Syntax** - -.. code:: cpp - - void end (); - -**Parameters** - -The function requires no input parameter. - -**Returns** - -The function returns nothing. - -**Example Code** - -NA - -**Notes and Warnings** - -NA - ----- - -.. method:: USBCDCDevice::available - -**Description** - -Get the number of bytes (characters) available for reading from the USB -serial port. - -**Syntax** - -.. code:: cpp - - int available (); - -**Parameters** - -The function requires no input parameter. - -**Returns** - -The function returns the number of bytes received in the buffer. - -**Example Code** - -Example: USBCDCSerial - -**Notes and Warnings** - -NA - ----- - -.. method:: USBCDCDevice::peek - -**Description** - -Returns the next byte (character) of incoming serial data without -removing it from the internal buffer. - -**Syntax** - -.. code:: cpp - - int peek (); - -**Parameters** - -The function requires no input parameter. - -**Returns** - -The function returns the next byte of received serial data without -removing it from the internal buffer. - -**Example Code** - -NA - -**Notes and Warnings** - -NA - ----- - -.. method:: USBCDCDevice::read - -**Description** - -Reads incoming serial data. - -**Syntax** - -.. code:: cpp - - int read (); - -**Parameters** - -The function requires no input parameter. - -**Returns** - -The function returns the next byte of received serial data. - -**Example Code** - -Example: USBCDCSerial - -**Notes and Warnings** - -NA - ----- - -.. method:: USBCDCDevice::flush - -**Description** - -Waits for the transmission of outgoing serial data to complete. - -**Syntax** - -.. code:: cpp - - void flush (); - -**Parameters** - -The function requires no input parameter. - -**Returns** - -The function returns nothing. - -**Example Code** - -NA - -**Notes and Warnings** - -NA - ----- - -.. method:: USBCDCDevice::write - -**Description** - -Writes binary data to the serial port. - -**Syntax** - -.. code:: cpp - - size_t write (uint8_t data); - -.. code:: cpp - - size_t write (const uint8_t* buffer, size_t size); - -**Parameters** - -``data`` : 1 byte of data to write to serial port - -``buffer`` : pointer to buffer containing data to write to serial port - -``size`` : number of bytes of data in buffer to write to serial port - -**Returns** - -The function returns the number of bytes written to serial port. - -**Example Code** - -Example: USBCDCSerial - -**Notes and Warnings** - -NA \ No newline at end of file diff --git a/bak/ambd/_common/API_Documents/USB/Class USBHIDDevice.rst b/bak/ambd/_common/API_Documents/USB/Class USBHIDDevice.rst deleted file mode 100644 index 2042804..0000000 --- a/bak/ambd/_common/API_Documents/USB/Class USBHIDDevice.rst +++ /dev/null @@ -1,431 +0,0 @@ -#################### -Class USBHIDDevice -#################### - -**Description** - -A class used for creating and managing USB HID device class - -**Syntax** - -.. code:: cpp - - class USBHIDDevice - -**Members** - -**Public Constructors** - -The public constructor should not be used as this class is intended to -be a singleton class. Access member functions using the object instance -named ``USBHIDDev``. - -**Public Methods** - -+------------------------------------+---------------------------------+ -| USBHIDDevice::setReportDescriptor | Configure the HID report | -| | descriptor | -+------------------------------------+---------------------------------+ -| USBHIDDevice::setUSBEndpointMPS | Configure USB endpoint maximum | -| | packet size | -+------------------------------------+---------------------------------+ -| US | Configure USB endpoint polling | -| BHIDDevice::setUSBEndpointInterval | interval | -+------------------------------------+---------------------------------+ -| USBHIDDevice::setVID | Set USB vendor ID value | -+------------------------------------+---------------------------------+ -| USBHIDDevice::setPID | Set USB product ID value | -+------------------------------------+---------------------------------+ -| U | Set USB manufacturer string | -| SBHIDDevice::setManufacturerString | | -+------------------------------------+---------------------------------+ -| USBHIDDevice::setModelString | Set USB product model string | -+------------------------------------+---------------------------------+ -| USBHIDDevice::setSerialString | Set USB product serial number | -| | string | -+------------------------------------+---------------------------------+ -| USBHIDDevice::USBconnected | Check if the USB port is | -| | connected to a host | -+------------------------------------+---------------------------------+ -| USBHIDDevice::begin | Start USB HID device | -+------------------------------------+---------------------------------+ -| USBHIDDevice::end | Stop USB HID device | -+------------------------------------+---------------------------------+ -| USBHIDDevice::inputReport | Send a HID input report | -+------------------------------------+---------------------------------+ - ----- - -.. method:: USBHIDDevice::setReportDescriptor - -**Description** - -Configure the HID report descriptor. - -**Syntax** - -.. code:: cpp - - void setReportDescriptor (uint8_t* report_desc, uint16_t len); - -**Parameters** - -``report_desc`` : pointer to buffer containing HID report descriptor - -``len`` : HID report descriptor length in number of bytes - -**Returns** - -The function returns nothing. - -**Example Code** - -Example: USBHIDGamepad - -**Notes and Warnings** - -Default HID report descriptor is configured for mouse + keyboard + -consumer control. - ----- - -.. method:: USBHIDDevice::setUSBEndpointMPS - -**Description** - -Configure USB endpoint maximum packet size. - -**Syntax** - -.. code:: cpp - - void setUSBEndpointMPS (uint8_t max_packet_size); - -**Parameters** - -``max_packet_size`` : maximum HID report packet size in bytes - -**Returns** - -The function returns nothing. - -**Example Code** - -Example: USBHIDGamepad - -**Notes and Warnings** - -The USB endpoint maximum packet size should correspond to the size of -the largest HID report defined in the HID report descriptor. - ----- - -.. method:: USBHIDDevice::setUSBEndpointInterval - -**Description** - -Configure USB endpoint polling interval. - -**Syntax** - -.. code:: cpp - - void setUSBEndpointInterval (uint8_t poll_interval); - -**Parameters** - -``poll_interval`` : polling interval for USB interrupt endpoint, expressed in -milliseconds - -**Returns** - -The function returns nothing. - -**Example Code** - -NA - -**Notes and Warnings** - -Default polling interval is set at the minimum of 1 millisecond. - ----- - -.. method:: USBHIDDevice::setVID - -**Description** - -Set USB vendor ID value. - -**Syntax** - -.. code:: cpp - - void setVID (uint16_t VID); - -**Parameters** - -``VID`` : vendor ID - -**Returns** - -The function returns nothing. - -**Example Code** - -NA - -**Notes and Warnings** - -The VID should be configured before USBHIDDevice::begin() function is -called. - ----- - -.. method:: USBHIDDevice::setPID - -**Description** - -Set USB product ID value. - -**Syntax** - -.. code:: cpp - - void setPID (uint16_t PID); - -**Parameters** - -``PID`` : product ID - -**Returns** - -The function returns nothing. - -**Example Code** - -NA - -**Notes and Warnings** - -The PID should be configured before USBHIDDevice::begin() function is -called. - ----- - -.. method:: USBHIDDevice::setManufacturerString - -**Description** - -Set USB manufacturer string. - -**Syntax** - -.. code:: cpp - - void setManufacturerString (const char* manufacturer); - -**Parameters** - -``manufacturer`` : Character string containing manufacturer name - -**Returns** - -The function returns nothing. - -**Example Code** - -NA - -**Notes and Warnings** - -The manufacturer string should be configured before -``USBHIDDevice::begin()`` function is called. - ----- - -.. method:: USBHIDDevice::setModelString - -**Description** - -Set USB product model string. - -**Syntax** - -.. code:: cpp - - void setModelString (const char* model); - -**Parameters** - -``model`` : Character string containing model name - -**Returns** - -The function returns nothing. - -**Example Code** - -NA - -**Notes and Warnings** - -The model string should be configured before ``USBHIDDevice::begin()`` -function is called. - ----- - -.. method:: USBHIDDevice::setSerialString - -**Description** - -Set USB product serial number string. - -**Syntax** - -.. code:: cpp - - void setSerialString (const char* serial); - -**Parameters** - -``serial`` : Character string containing serial number - -**Returns** - -The function returns nothing. - -**Example Code** - -NA - -**Notes and Warnings** - -The serial string should be configured before USBHIDDevice::begin() -function is called. - ----- - -.. method:: USBHIDDevice::USBconnected - -**Description** - -Check if the USB port is connected to a host. - -**Syntax** - -.. code:: cpp - - uint8_t USBconnected (); - -**Parameters** - -The function requires no input parameter. - -**Returns** - -The function returns **TRUE** if the USB port is connected to a host, **FALSE** -if it is not connected. - -**Example Code** - -Example: USBHIDGamepad, USBHIDKeyboard, USBHIDMouse - -**Notes and Warnings** - -NA - ------ - -.. method:: USBHIDDevice::begin - -**Description** - -Start USB HID device. - -**Syntax** - -.. code:: cpp - - void begin (); - -**Parameters** - -The function requires no input parameter. - -**Returns** - -The function returns nothing. - -**Example Code** - -Example: USBHIDGamepad, USBHIDKeyboard, USBHIDMouse - -**Notes and Warnings** - -NA - ----- - -.. method:: USBHIDDevice::end - -**Description** - -Stop USB HID device. - -**Syntax** - -.. code:: cpp - - void end (); - -**Parameters** - -The function requires no input parameter. - -**Returns** - -The function returns nothing. - -**Example Code** - -NA - -**Notes and Warnings** - -NA - ----- - -.. method:: USBHIDDevice::inputReport - -**Description** - -Send a HID input report. - -**Syntax** - -.. code:: cpp - - void inputReport (uint8_t reportID, uint8_t* data, uint16_t len); - -**Parameters** - -``reportID`` : HID report ID of input report - -``data`` : pointer to HID input report data to send - -``len`` : length of HID input report data in bytes - -**Returns** - -The function returns nothing. - -**Example Code** - -NA - -**Notes and Warnings** - -A reportID value of 0 is not a valid report ID and will send an input -report without the report ID field. diff --git a/bak/ambd/_common/API_Documents/USB/Class USBHIDGamepad.rst b/bak/ambd/_common/API_Documents/USB/Class USBHIDGamepad.rst deleted file mode 100644 index 3715466..0000000 --- a/bak/ambd/_common/API_Documents/USB/Class USBHIDGamepad.rst +++ /dev/null @@ -1,474 +0,0 @@ -#################### -Class USBHIDGamepad -#################### - -**Description** - -A class used for creating and managing a USB HID Gamepad. - -**Syntax** - -.. code:: cpp - - class USBHIDGamepad - -**Members** - -**Public Constructors** - -+--------------------------------------+-------------------------------+ -| USBHIDGamepad::USBHIDGamepad | Constructs a USBHIDGamepad | -| | object | -+--------------------------------------+-------------------------------+ - -**Public Methods** - -+------------------------------------+---------------------------------+ -| USBHIDGamepad::setReportID | Set HID report ID for the HID | -| | Gamepad | -+------------------------------------+---------------------------------+ -| USBHIDGamepad::gamepadReport | Send a HID Gamepad report | -+------------------------------------+---------------------------------+ -| USBHIDGamepad::buttonPress | Send a HID Gamepad report | -| | indicating buttons pressed | -+------------------------------------+---------------------------------+ -| USBHIDGamepad::buttonRelease | Send a HID Gamepad report | -| | indicating buttons released | -+------------------------------------+---------------------------------+ -| USBHIDGamepad::buttonReleaseAll | Send a HID Gamepad report | -| | indicating no buttons pressed | -+------------------------------------+---------------------------------+ -| USBHIDGamepad::setHat | Send a HID Gamepad report | -| | indicating hat switch position | -+------------------------------------+---------------------------------+ -| USBHIDGamepad::setAxes | Send a HID Gamepad report | -| | indicating position of all axes | -+------------------------------------+---------------------------------+ -| USBHIDGamepad::setLeftStick | Send a HID Gamepad report | -| | indicating position of axes | -| | corresponding to left analog | -| | stick | -+------------------------------------+---------------------------------+ -| USBHIDGamepad::setRightStick | Send a HID Gamepad report | -| | indicating position of axes | -| | corresponding to right analog | -| | stick | -+------------------------------------+---------------------------------+ -| USBHIDGamepad::setTriggers | Send a HID Gamepad report | -| | indicating position of axes | -| | corresponding to triggers | -+------------------------------------+---------------------------------+ - ----- - -.. method:: USBHIDGamepad::USBHIDGamepad - -**Description** - -Constructs a USBHIDGamepad object. - -**Syntax** - -.. code:: cpp - - USBHIDGamepad::USBHIDGamepad (); - -**Parameters** - -The function requires no input parameter. - -**Returns** - -The function returns nothing. - -**Example Code** - -Example: USBHIDGamepad - -**Notes and Warnings** - -By default, the USBHIDGamepad class assumes the HID report descriptor -implements a gamepad device with 16 buttons, 6 axes with 16-bit -resolution and an 8-direction hat switch. This class will not work if a -different gamepad report descriptor is implemented. - ----- - -.. method:: USBHIDGamepad::setReportID - -**Description** - -Set HID report ID for the HID Gamepad. - -**Syntax** - -.. code:: cpp - - void setReportID (uint8_t reportID); - -**Parameters** - -``reportID`` : The report ID for the gamepad device, corresponding to the HID -report descriptor. - -**Returns** - -The function returns nothing. - -**Example Code** - -NA - -**Notes and Warnings** - -HID report ID should start at 1. Some systems may consider a report ID -of 0 as invalid. - ----- - -.. method:: USBHIDGamepad::gamepadReport - -**Description** - -Send a HID Gamepad report. - -**Syntax** - -.. code:: cpp - - void gamepadReport (hid_gamepad_report_t* report); - -.. code:: cpp - - void gamepadReport (uint16_t buttons, uint8_t hat, int16_t x, int16_t y, - int16_t z, int16_t Rz, int16_t Rx, int16_t Ry); - -**Parameters** - -``report`` : pointer to gamepad report structure containing data on all -inputs - -``buttons`` : bitmap indicating state of each button. 1 = pressed, 0 = -released. - -``hat`` : position of hat switch. Valid values: - -- GAMEPAD_HAT_CENTERED = 0 - -- GAMEPAD_HAT_UP = 1 - -- GAMEPAD_HAT_UP_RIGHT = 2 - -- GAMEPAD_HAT_RIGHT = 3 - -- GAMEPAD_HAT_DOWN_RIGHT = 4 - -- GAMEPAD_HAT_DOWN = 5 - -- GAMEPAD_HAT_DOWN_LEFT = 6 - -- GAMEPAD_HAT_LEFT = 7 - -- GAMEPAD_HAT_UP_LEFT = 8 - -``x`` : position of x axis. Integer value from -32767 to 32767. - -``y`` : position of y axis. Integer value from -32767 to 32767. - -``z`` : position of z axis. Integer value from -32767 to 32767. - -``Rz`` : position of Rz axis. Integer value from -32767 to 32767. - -``Rx`` : position of Rx axis. Integer value from -32767 to 32767. - -``Ry`` : position of Ry axis. Integer value from -32767 to 32767. - -**Returns** - -The function returns nothing. - -**Example Code** - -Example: USBHIDGamepad - -**Notes and Warnings** - -NA - ----- - -.. method:: USBHIDGamepad::buttonPress - -**Description** - -Send a HID Gamepad report indicating buttons pressed. - -**Syntax** - -.. code:: cpp - - void buttonPress (uint16_t buttons); - -**Parameters** - -``buttons`` : bitmap indicating buttons pressed. 1 = pressed. - -**Returns** - -The function returns nothing. - -**Example Code** - -NA - -**Notes and Warnings** - -NA - ----- - -.. method:: USBHIDGamepad::buttonRelease - -**Description** - -Send a HID Gamepad report indicating buttons released. - -**Syntax** - -.. code:: cpp - - void buttonRelease (uint16_t buttons); - -**Parameters** - -``buttons`` : bitmap indicating buttons released. 1 = released. - -**Returns** - -The function returns nothing. - -**Example Code** - -NA - -**Notes and Warnings** - -NA - ----- - -.. method:: USBHIDGamepad::buttonReleaseAll - -**Description** - -Send a HID Gamepad report indicating no buttons pressed. - -**Syntax** - -.. code:: cpp - - void buttonReleaseAll (); - -**Parameters** - -The function takes no parameter. - -**Returns** - -The function returns nothing. - -**Example Code** - -Example: USBHIDGamepad - -**Notes and Warnings** - -NA - ----- - -.. method:: USBHIDGamepad::setHat - -**Description** - -Send a HID Gamepad report indicating hat switch position. - -**Syntax** - -.. code:: cpp - - void setHat (uint8_t hat); - -**Parameters** - -``hat`` : position of hat switch. Valid values: - -- GAMEPAD_HAT_CENTERED = 0 - -- GAMEPAD_HAT_UP = 1 - -- GAMEPAD_HAT_UP_RIGHT = 2 - -- GAMEPAD_HAT_RIGHT = 3 - -- GAMEPAD_HAT_DOWN_RIGHT = 4 - -- GAMEPAD_HAT_DOWN = 5 - -- GAMEPAD_HAT_DOWN_LEFT = 6 - -- GAMEPAD_HAT_LEFT = 7 - -- GAMEPAD_HAT_UP_LEFT = 8 - -**Returns** - -The function returns nothing. - -**Example Code** - -NA - -**Notes and Warnings** - -NA - ----- - -.. method:: USBHIDGamepad::setAxes - -**Description** - -Send a HID Gamepad report indicating position of all axes. - -**Syntax** - -.. code:: cpp - - void setAxes (int16_t x, int16_t y, int16_t z, int16_t Rz, int16_t Rx, - int16_t Ry); - -**Parameters** - -``x`` : position of x axis. Integer value from -32767 to 32767. - -``y`` : position of y axis. Integer value from -32767 to 32767. - -``z`` : position of z axis. Integer value from -32767 to 32767. - -``Rz`` : position of Rz axis. Integer value from -32767 to 32767. - -``Rx`` : position of Rx axis. Integer value from -32767 to 32767. - -``Ry`` : position of Ry axis. Integer value from -32767 to 32767. - -**Returns** - -The function returns nothing. - -**Example Code** - -Example: USBHIDGamepad - -**Notes and Warnings** - -NA - ----- - -.. method:: USBHIDGamepad::setLeftStick - -**Description** - -Send a HID Gamepad report indicating position of axes corresponding to -left analog stick. - -**Syntax** - -.. code:: cpp - - void setLeftStick (int16_t x, int16_t y); - -**Parameters** - -``x``: position of x axis. Integer value from -32767 to 32767. - -``y`` : position of y axis. Integer value from -32767 to 32767. - -**Returns** - -The function returns nothing. - -**Example Code** - -NA - -**Notes and Warnings** - -NA - ----- - -.. method:: USBHIDGamepad::setRightStick** - -**Description** - -Send a HID Gamepad report indicating position of axes corresponding to -right analog stick. - -**Syntax** - -.. code:: cpp - - void setLeftStick (int16_t z, int16_t Rz); - -**Parameters** - -``z`` : position of z axis. Integer value from -32767 to 32767. - -``Rz`` : position of Rz axis. Integer value from -32767 to 32767. - -**Returns** - -The function returns nothing. - -**Example Code** - -NA - -**Notes and Warnings** - -NA - ----- - -.. method:: USBHIDGamepad::setTrigger - -**Description** - -Send a HID Gamepad report indicating position of axes corresponding to -triggers. - -**Syntax** - -.. code:: cpp - - void setTriggers (int16_t Rx, int16_t Ry); - -**Parameters** - -``Rx`` : position of Rx axis. Integer value from -32767 to 32767. - -``Ry`` : position of Ry axis. Integer value from -32767 to 32767. - -**Returns** - -The function returns nothing. - -**Example Code** - -NA - -**Notes and Warnings** - -NA \ No newline at end of file diff --git a/bak/ambd/_common/API_Documents/USB/Class USBHIDKeyboard.rst b/bak/ambd/_common/API_Documents/USB/Class USBHIDKeyboard.rst deleted file mode 100644 index 8ec5940..0000000 --- a/bak/ambd/_common/API_Documents/USB/Class USBHIDKeyboard.rst +++ /dev/null @@ -1,408 +0,0 @@ -#################### -Class USBHIDKeyboard -#################### - -**Description** - -A class used for creating and managing a USB HID Keyboard. - -**Syntax** - -.. code:: cpp - - class USBHIDKeyboard - -**Members** - -**Public Constructors** - -+-------------------------------------+--------------------------------+ -| USBHIDKeyboard::USBHIDKeyboard | Constructs a USBHIDKeyboard | -| | object | -+-------------------------------------+--------------------------------+ - -**Public Methods** - -+------------------------------------+---------------------------------+ -| USBHIDKeyboard::setReportID | Set HID report ID for the HID | -| | Keyboard and HID consumer | -| | control | -+------------------------------------+---------------------------------+ -| USBHIDKeyboard::consumerReport | Send a HID Consumer report | -+------------------------------------+---------------------------------+ -| USBHIDKeyboard::keyboardReport | Send a HID Keyboard report | -+------------------------------------+---------------------------------+ -| USBHIDKeyboard::consumerPress | Send a HID Consumer report | -| | indicating button pressed | -+------------------------------------+---------------------------------+ -| USBHIDKeyboard::consumerRelease | Send a HID Consumer report | -| | indicating button released | -+------------------------------------+---------------------------------+ -| USBHIDKeyboard::keyPress | Send a HID Keyboard report | -| | indicating keys pressed | -+------------------------------------+---------------------------------+ -| USBHIDKeyboard::keyRelease | Send a HID Keyboard report | -| | indicating keys released | -+------------------------------------+---------------------------------+ -| USBHIDKeyboard::keyReleaseAll | Send a HID Keyboard report | -| | indicating no keys pressed | -+------------------------------------+---------------------------------+ -| USBHIDKeyboard::keyCharPress | Send a HID Keyboard report | -| | indicating keys pressed to | -| | output an ASCII character | -+------------------------------------+---------------------------------+ -| USBHIDKeyboard::keySequence | Send a HID Keyboard report | -| | indicating keys pressed to | -| | output an ASCII string | -+------------------------------------+---------------------------------+ - ----- - -.. method:: USBHIDKeyboard::USBHIDKeyboard - -**Description** - -Constructs a USBHIDKeyboard object. - -**Syntax** - -.. code:: cpp - - USBHIDKeyboard::USBHIDKeyboard(); - -**Parameters** - -The function requires no input parameter. - -**Returns** - -The function returns nothing. - -**Example Code** - -Example: USBHIDKeyboard - -**Notes and Warnings** - -NA - ----- - -.. method:: USBHIDKeyboard::setReportID - -**Description** - -Set HID report ID for the HID Keyboard and HID consumer control. - -**Syntax** - -.. code:: cpp - - void setReportID (uint8_t reportIDKeyboard, uint8_t reportIDConsumer); - -**Parameters** - -``reportIDKeyboard`` : The report ID for the HID keyboard device, -corresponding to the HID report descriptor. - -``reportIDConsumer`` : The report ID for the HID consumer control device, -corresponding to the HID report descriptor. - -**Returns** - -The function returns nothing. - -**Example Code** - -NA - -**Notes and Warnings** - -NA - ----- - -.. method:: USBHIDKeyboard::consumerReport - -**Description** - -Send a HID Consumer report. - -**Syntax** - -.. code:: cpp - - void consumerReport (uint16_t usage_code); - -**Parameters** - -``usage_code`` : HID consumer control usage code for the button pressed. - -**Returns** - -The function returns nothing. - -**Example Code** - -NA - -**Notes and Warnings** - -NA - ----- - -.. method:: USBHIDKeyboard::keyboardReport - -**Description** - -Send a HID Keyboard report. - -**Syntax** - -.. code:: cpp - - void keyboardReport (); - -.. code:: cpp - - void keyboardReport (uint8_t modifiers, uint8_t keycode[6]); - -**Parameters** - -``modifiers`` : bitmap indicating key modifiers pressed (CTRL, ALT, SHIFT). - -``keycode`` : byte array indicating keys pressed. - -**Returns** - -The function returns nothing. - -**Example Code** - -NA - -**Notes and Warnings** - -NA - ----- - -.. method:: USBHIDKeyboard::consumerPress - -**Description** - -Send a HID Consumer report indicating button pressed. - -**Syntax** - -.. code:: cpp - - void consumerPress (uint16_t usage_code); - -**Parameters** - -``usage_code`` : HID consumer control usage code for the button pressed. - -**Returns** - -The function returns nothing. - -**Example Code** - -NA - -**Notes and Warnings** - -NA - ----- - -.. method:: USBHIDKeyboard::consumerRelease - -**Description** - -Send a HID Consumer report indicating button released. - -**Syntax** - -.. code:: cpp - - void consumerRelease (); - -**Parameters** - -The function requires no input parameter. - -**Returns** - -The function returns nothing. - -**Example Code** - -NA - -**Notes and Warnings** - -NA - ------ - -.. method:: USBHIDKeyboard::keyPress - -**Description** - -Send a HID Keyboard report indicating keys pressed. - -**Syntax** - -.. code:: cpp - - void keyPress (uint16_t key); - -**Parameters** - -``key`` : HID keycode for key pressed, value ranges from 0x00 to 0xE7. - -**Returns** - -The function returns nothing. - -**Example Code** - -Example: USBHIDKeyboard - -**Notes and Warnings** - -NA - ----- - -.. method:: USBHIDKeyboard::keyRelease - -**Description** - -Send a HID Keyboard report indicating keys released. - -**Syntax** - -.. code:: cpp - - void keyRelease (uint16_t key); - -**Parameters** - -``key`` : HID keycode for key pressed, value ranges from 0x00 to 0xE7. - -**Returns** - -The function returns nothing. - -**Example Code** - -NA - -**Notes and Warnings** - -NA - ----- - -.. method:: USBHIDKeyboard::keyReleaseAll - -**Description** - -Send a HID Keyboard report indicating no keys pressed. - -**Syntax** - -.. code:: cpp - - void keyReleaseAll (); - -**Parameters** - -The function requires no input parameter. - -**Returns** - -The function returns nothing. - -**Example Code** - -Example: USBHIDKeyboard - -**Notes and Warnings** - -NA - ----- - -.. method:: USBHIDKeyboard::keyCharPress - -**Description** - -Send a HID Keyboard report indicating keys pressed to output an ASCII -character. - -**Syntax** - -.. code:: cpp - - void keyCharPress (char ch); - -**Parameters** - -``ch`` : ASCII character to output. - -**Returns** - -The function returns nothing. - -**Example Code** - -NA - -**Notes and Warnings** - -NA - ----- - -.. method:: USBHIDKeyboard::keySequence - -**Description** - -Send a HID Keyboard report indicating keys pressed to output an ASCII -string. - -**Syntax** - -.. code:: cpp - - void keySequence (const char* str, uint16_t delayTime); - -.. code:: cpp - - void keySequence (String str, uint16_t delayTime); - -**Parameters** - -``str``: pointer to character string to output - -``str``: String object containing character string to output - -``delayTime``: time delay between key press and release, in milliseconds. -Default value of 5. - -**Returns** - -The function returns nothing. - -**Example Code** - -Example: USBHIDKeyboard - -**Notes and Warnings** - -NA diff --git a/bak/ambd/_common/API_Documents/USB/Class USBHIDMouse.rst b/bak/ambd/_common/API_Documents/USB/Class USBHIDMouse.rst deleted file mode 100644 index 3feef80..0000000 --- a/bak/ambd/_common/API_Documents/USB/Class USBHIDMouse.rst +++ /dev/null @@ -1,304 +0,0 @@ -#################### -Class USBHIDMouse -#################### - - -**Description** - -A class used for creating and managing a USB HID Mouse. - -**Syntax** - -.. code:: cpp - - class USBHIDMouse - -**Members** - -**Public Constructors** - -+--------------------------------+-------------------------------------+ -| USBHIDMouse::USBHIDMouse | Constructs a USBHIDMouse object | -+--------------------------------+-------------------------------------+ - -**Public Methods** - -+------------------------------------+---------------------------------+ -| USBHIDMouse::setReportID | Set HID report ID for the HID | -| | Mouse | -+------------------------------------+---------------------------------+ -| USBHIDMouse::mouseReport | Send a HID Mouse report | -+------------------------------------+---------------------------------+ -| USBHIDMouse::mousePress | Send a HID Mouse report | -| | indicating buttons pressed | -+------------------------------------+---------------------------------+ -| USBHIDMouse::mouseRelease | Send a HID Mouse report | -| | indicating buttons released | -+------------------------------------+---------------------------------+ -| USBHIDMouse::mouseReleaseAll | Send a HID Mouse report | -| | indicating no buttons pressed | -+------------------------------------+---------------------------------+ -| USBHIDMouse::mouseMove | Send a HID Mouse report | -| | indicating mouse movement | -+------------------------------------+---------------------------------+ -| USBHIDMouse::mouseScroll | Send a HID Mouse report | -| | indicating mouse scroll wheel | -| | movement | -+------------------------------------+---------------------------------+ - ----- - -.. method:: USBHIDMouse::USBHIDMouse - -**Description** - -Constructs a USBHIDMouse object. - -**Syntax** - -.. code:: cpp - - USBHIDMouse::USBHIDMouse (); - -**Parameters** - -The function requires no input parameter. - -**Returns** - -The function returns nothing. - -**Example Code** - -Example: USBHIDMouse - -**Notes and Warnings** - -NA - ----- - -.. method:: USBHIDMouse::setReportID - -**Description** - -Set HID report ID for the HID Mouse. - -**Syntax** - -.. code:: cpp - - void setReportID (uint8_t reportID); - -**Parameters** - -``reportID`` : The report ID for the HID mouse device, corresponding to the -HID report descriptor. - -**Returns** - -The function returns nothing. - -**Example Code** - -NA - -**Notes and Warnings** - -NA - ----- - -.. method:: USBHIDMouse::mouseReport - -**Description** - -Send a HID Mouse report. - -**Syntax** - -.. code:: cpp - - void mouseReport (hid_mouse_report_t* report); - -.. code:: cpp - - void mouseReport (uint8_t buttons, int8_t x, int8_t y, int8_t scroll); - -**Parameters** - -``report`` : pointer to mouse report structure containing data on mouse -inputs - -``buttons`` : bitmap indicating state of each button. 1 = pressed, 0 = -released. - -``x`` : mouse x-axis movement. Integer value from -127 to 127. - -``y`` : mouse y-axis movement. Integer value from -127 to 127. - -``scroll`` : mouse scroll wheel movement. Integer value from -127 to 127. - -**Returns** - -The function returns nothing. - -**Example Code** - -NA - -**Notes and Warnings** - -NA - ------ - -.. method:: USBHIDMouse::mousePress - -**Description** - -Send a HID Mouse report indicating buttons pressed. - -**Syntax** - -.. code:: cpp - - void mousePress (uint8_t buttons); - -**Parameters** - -``buttons`` : bitmap indicating buttons pressed. 1 = pressed. - -**Returns** - -The function returns nothing. - -**Example Code** - -Example: USBHIDMouse - -**Notes and Warnings** - -NA - ----- - -.. method:: USBHIDMouse::mouseRelease - -**Description** - -Send a HID Mouse report indicating buttons released. - -**Syntax** - -.. code:: cpp - - void mouseRelease (uint8_t buttons); - -**Parameters** - -``buttons`` : bitmap indicating buttons released. 1 = released. - -**Returns** - -The function returns nothing. - -**Example Code** - -Example: USBHIDMouse - -**Notes and Warnings** - -NA - ----- - -.. method:: USBHIDMouse::mouseReleaseAll - -**Description** - -Send a HID Mouse report indicating no buttons pressed. - -**Syntax** - -.. code:: cpp - - void mouseReleaseAll (); - -**Parameters** - -The function requires no input parameter. - -**Returns** - -The function returns nothing. - -**Example Code** - -NA - -**Notes and Warnings** - -NA - ----- - -.. method:: USBHIDMouse::mouseMove - -**Description** - -Send a HID Mouse report indicating mouse movement. - -**Syntax** - -.. code:: cpp - - void mouseMove (int8_t x, int8_t y); - -**Parameters** - -``x`` : mouse x-axis movement. Integer value from -127 to 127. - -``y`` : mouse y-axis movement. Integer value from -127 to 127. - -**Returns** - -The function returns nothing. - -**Example Code** - -Example: USBHIDMouse - -**Notes and Warnings** - -NA - ----- - -.. method:: USBHIDMouse::mouseScroll - -**Description** - -Send a HID Mouse report indicating mouse scroll wheel movement. - -**Syntax** - -.. code:: cpp - - void mouseScroll (int8_t scroll); - -**Parameters** - -``scroll`` : mouse scroll wheel movement. Integer value from -127 to 127. - -**Returns** - -The function returns nothing. - -**Example Code** - -Example: USBHIDMouse - -**Notes and Warnings** - -NA diff --git a/bak/ambd/_common/API_Documents/WS2812B/Class WS2812B.rst b/bak/ambd/_common/API_Documents/WS2812B/Class WS2812B.rst deleted file mode 100644 index 5be4b1c..0000000 --- a/bak/ambd/_common/API_Documents/WS2812B/Class WS2812B.rst +++ /dev/null @@ -1,359 +0,0 @@ -################### -Class WS2812B -################### - -**Description** - -Defines a class to use WS2812B LED with AmebaD. - -**Syntax** - -.. code:: cpp - - class WS2812B - -**Members** - -**Public Constructors** - -+--------------------------------------------+-------------------------+ -| WS2812B::WS2812B | Constructs a WS2812B | -| | object | -+--------------------------------------------+-------------------------+ - -**Public Methods** - -+-------------------------------------------+--------------------------+ -| WS2812B::begin | Check for correct pin | -| | settings and prepare to | -| | drive the WS2812B | -+-------------------------------------------+--------------------------+ -| WS2812B::show | Pushes the color data | -| | out to the LEDs | -+-------------------------------------------+--------------------------+ -| WS2812B::clear | Clear the memory | -+-------------------------------------------+--------------------------+ -| WS2812B::setLEDCount | Allocate memory for all | -| | the LEDs | -+-------------------------------------------+--------------------------+ -| WS2812B::setPixelColor | Set the color of a LED | -+-------------------------------------------+--------------------------+ -| WS2812B::fill | Set multiple LEDs with | -| | the same color | -+-------------------------------------------+--------------------------+ -| WS2812B::colorHSV | Convert to RGB values | -| | from HSV | -+-------------------------------------------+--------------------------+ -| WS2812B::rainbow | Fill all the LEDs with | -| | one or more cycle of | -| | hues | -+-------------------------------------------+--------------------------+ - ----- - -.. method:: WS2812B::WS2812B - -**Description** - -Constructs a WS2812B object - -**Syntax** - -.. code:: cpp - - WS2812B::WS2812(uint8_t input_pin, uint16_t num_leds) - -**Parameters** - -``input_pin`` : The MOSI pin that is connected to the WS2812B LED. - -``num_leds`` : The number of LEDs that needs to be light up - -**Returns** - -The function returns nothing - -**Example Code** - -Example: WS2812B_Basics; WS2812B_Patterns - -**Notes and Warnings** - -Only SPI MOSI pin is valid for driving WS2812B LEDs. - ----- - -.. method:: WS2812B::begin - -**Description** - -Check for correct pin settings and prepare to drive the WS2812B - -**Syntax** - -.. code:: cpp - - void WS2812B::begin(void) - -**Parameters** - -This function does not require any input parameters - -**Returns** - -The function returns nothing - -**Example Code** - -Example: WS2812B_Basics; WS2812B_Patterns - -**Notes and Warnings** - -NA - ----- - -.. method:: WS2812B::show - -**Description** - -Pushes the color data out to the LEDs - -**Syntax** - -.. code:: cpp - - void WS2812B::show(void) - -**Parameters** - -This function does not require any input parameters - -**Returns** - -The function returns nothing - -**Example Code** - -Example: WS2812B_Basics; WS2812B_Patterns - -**Notes and Warnings** - -The amount of time needed to push the color data will increase with more -LEDs. - ----- - -.. method:: WS2812B::clear - -**Description** - -Clear the memory - -**Syntax** - -.. code:: cpp - - void WS2812B::clear(void) - -**Parameters** - -This function does not require any input parameters - -**Returns** - -The function returns nothing - -**Example Code** - -Example: WS2812B_Patterns - -**Notes and Warnings** - -This function only clears the color data from memory. To turn off the -LED, please use ``WS2812B::show()``. - ----- - -.. method:: WS2812B::setLEDCount - -**Description** - -Allocate memory for all the LEDs - -**Syntax** - -.. code:: cpp - - void WS2812B::setLEDCount(uint16_t num_leds) - -**Parameters** - -This function does not require any input parameters - -**Returns** - -The function returns nothing - -**Example Code** - -NA - -**Notes and Warnings** - -NA - ------ - -.. method:: WS2812B::setPixelColor - -**Description** - -Set the color of a LED - -**Syntax** - -.. code:: cpp - - void WS2812B::setPixelColor(uint16_t led_Number, uint8_t rColor, uint8_t gColor, uint8_t bColor) - -**Parameters** - -``Led_Number`` : The LED number, with 0 being the LED closest to the data -input pin - -``rColor`` : Red brightness level, from 0 (Off) – 255 (Maximum brightness) - -``gColor`` : Green brightness level, from 0 (Off) – 255 (Maximum brightness) - -``bColor`` : Blue brightness level, from 0 (Off) – 255 (Maximum brightness) - -**Returns** - -The function returns nothing - -**Example Code** - -Example: WS2812B_Basics; WS2812B_Patterns - -**Notes and Warnings** - -NA - ----- - -.. method:: WS2812B::fill - -**Description** - -Set multiple LEDs with the same colors - -**Syntax** - -.. code:: cpp - - WS2812B::fill(uint8_t rColor, uint8_t gColor, uint8_t bColor, uint16_t first, uint16_t count) - -**Parameters** - -``rColor`` : Red brightness level, from 0 (Off) – 255 (Maximum brightness) - -``gColor`` : Green brightness level, from 0 (Off) – 255 (Maximum brightness) - -``bColor`` : Blue brightness level, from 0 (Off) – 255 (Maximum brightness) - -``first`` : The index of the first LED to start filling with color - -``count`` : Total number of LEDs to be set with the color - -**Returns** - -The function returns nothing - -**Example Code** - -Example: WS2812B_Basics - -**Notes and Warnings** - -If the first and count is not provided, the default behaviour would be -to fill all LEDs. - ------ - -.. method:: WS2812B::colorHSV - -**Description** - -Convert to RGB values from HSV - -**Syntax** - -.. code:: cpp - - uint32_t colorHSV(uint16_t hue, uint8_t sat, uint8_t val); - -**Parameters** - -``hue`` : Expressed as 16-bit number. Starting from 0 for red, it increments -first towards yellow, and on through green, cyan, blue, magenta, and -black to red. - -``sat`` : Intensity or purity of the color. Expressed as 8-bit number ranging -from 0 to 255. In the middle, you will get something sort of pastel. - -``val`` : Brightness of a color. Expressed as an 8-bit number ranging from 0 -to 255. - -**Returns** - -The function returns the RGB values converted from HSV. - -**Example Code** - -Example: WS2812B_Patterns - -**Notes and Warnings** - -NA - ------ - -.. method:: WS2812B::rainbow - -**Description** - -Fill all the LEDs with one or more cycle of hues - -**Syntax** - -.. code:: cpp - - void rainbow(uint16_t first_hue = 0, int8_t reps = 1, uint8_t saturation = 255, uint8_t brightness = 60); - -**Parameters** - -``first_hue`` : hue of first LED, 0 – 65535, representing one full cycle of -the color wheel. - -``reps`` : Number of cycles of the color wheel over the length of the strip. -Default is 1. Negative values can be used to reverse the hue order. - -``saturation`` : Intensity or purity of the color. Expressed as 8-bit number -ranging from 0 to 255. In the middle, you will get something sort of -pastel. - -``brightness`` : Brightness of a color. Expressed as an 8-bit number ranging -from 0 to 255. - -**Returns** - -The function returns nothing - -**Example Code** - -Example: WS2812B_Patterns - -**Notes and Warnings** - -NA diff --git a/bak/ambd/_common/API_Documents/index.rst b/bak/ambd/_common/API_Documents/index.rst deleted file mode 100644 index 0fa70b8..0000000 --- a/bak/ambd/_common/API_Documents/index.rst +++ /dev/null @@ -1,30 +0,0 @@ -API Documents -============= - -.. toctree:: - :maxdepth: 1 - - Analog/index - AudioCodec/index - BLE/index - EPDIF/index - FatfsSDcard/index - FlashMemory/index - GPIO/index - Gtimer/index - Http/index - IRDevice/index - MDNS/index - MQTTClient/index - NTPClient/index - OTA/index - PowerSave/index - RTC/index - SoftwareSerial/index - SPI/index - Sys/index - USB/index - WDT/index - WiFi/index - Wire/index - WS2812B/index diff --git a/bak/ambd/_common/Example_Guides/BLE/BLE - BLE Battery Service.rst b/bak/ambd/_common/Example_Guides/BLE/BLE - BLE Battery Service.rst deleted file mode 100644 index 61059a1..0000000 --- a/bak/ambd/_common/Example_Guides/BLE/BLE - BLE Battery Service.rst +++ /dev/null @@ -1,122 +0,0 @@ -################################################# -BLE - BLE Battery Service -################################################# - -.. role:: raw-html(raw) - :format: html - -:raw-html:`

` -**Materials** -:raw-html:`

` - - - AmebaD [AMB21 / AMB22 / AMB23 / BW16] x 1 - - Android / iOS mobile phone - -:raw-html:`

` -**Example** -:raw-html:`

` - -**Introduction** - -BLE connections use a server client model. The server contains the data -of interest, while the client connects to the server to read the data. -Commonly, a Bluetooth peripheral device acts as a server, while a -Bluetooth central device acts as a client. Servers can contain many -services, with each service containing a some set of data. Clients can -send requests to read or write some data and can also subscribe to -notifications so that the server can send data updates to a client. - -In this example, a basic battery service is set up on the Ameba -Bluetooth stack. A mobile phone is used to connect to the Ameba -peripheral device and read the battery data. - -**Procedure** - -Ensure that the following Bluetooth apps are installed on your mobile -phone. These apps will show you the raw data sent by Ameba and allow you -to interact with the data. - -The recommended application is nRF connect, and is available at the -links below: - - - Android: https://play.google.com/store/apps/details?id=no.nordicsemi.android.mcp - - iOS : https://apps.apple.com/us/app/nrf-connect/id1054362403 - -LightBlue is an alternative application that can also be used, but has -less features: - - - Android: https://play.google.com/store/apps/details?id=com.punchthrough.lightblueexplorer - - iOS : https://apps.apple.com/us/app/lightblue/id557428110 - -Open the example, ``“Files” → “Examples” → “AmebaBLE” → -“BLEBatteryService”`` - -.. image:: /media/ambd_arduino/BLE_Battery_Service/image1.png - :align: center - :width: 1058 - :height: 972 - :scale: 72 % - -Upload the code and press the reset button on Ameba once the upload is -finished. -On your mobile phone, open the Bluetooth app and scan for the -Bluetooth signal broadcast by Ameba, it should appear as a device -named “AMEBA_BLE_DEV”. - -.. image:: /media/ambd_arduino/BLE_Battery_Service/image2.png - :align: center - :width: 1148 - :height: 2880 - :scale: 34 % - -Connect to the Ameba Bluetooth device, and a list of available services -should appear. Click on the battery service to expand it, and you can -see the battery level data value. The arrows highlighted in the box on -the right are used to read data and subscribe to notifications. Click on -the single arrow to read the battery level value, and a 90% value will -appear. - -.. image:: /media/ambd_arduino/BLE_Battery_Service/image3.png - :align: center - :width: 1148 - :height: 2880 - :scale: 34 % - -Click on the triple arrow to subscribe to updates on the battery level -value, and the battery value will start updating by itself. - -.. image:: /media/ambd_arduino/BLE_Battery_Service/image4.png - :align: center - :width: 1148 - :height: 2880 - :scale: 34 % - -The serial monitor will show the sketch increasing the battery level -every second. When you click on either of the arrows, the sketch running -on the Ameba will be notified, and will print out the action taken. - -.. image:: /media/ambd_arduino/BLE_Battery_Service/image5.png - :align: center - :width: 749 - :height: 509 - -:raw-html:`

` -**Code Reference** -:raw-html:`

` - -BLEService and BLECharacteristic classes are used to create and define -the battery service to run on the Bluetooth device. - -``BLE.configAdvert() → setAdvType(GAP_ADTYPE_ADV_IND)`` is used to set the -advertisement type to a general undirected advertisement that allows for -connections. - -``setReadCallback()`` and ``setCCCDCallback()`` is used to register functions -that will be called when the battery level data is read, or notification -is enabled by the user. - -``BLE.configServer(1)`` is used to tell the Bluetooth stack that there will -be one service running. - -``addService()`` registers the battery service to the Bluetooth stack. - diff --git a/bak/ambd/_common/Example_Guides/BLE/BLE - BLE Beacon.rst b/bak/ambd/_common/Example_Guides/BLE/BLE - BLE Beacon.rst deleted file mode 100644 index 55fc47e..0000000 --- a/bak/ambd/_common/Example_Guides/BLE/BLE - BLE Beacon.rst +++ /dev/null @@ -1,112 +0,0 @@ -################################################# -BLE – BLE Beacon -################################################# - -.. role:: raw-html(raw) - :format: html - -:raw-html:`

` -**Materials** -:raw-html:`

` - - - AmebaD [AMB21 / AMB22 / AMB23 / BW16] x 1 - - Android / iOS mobile phone - -:raw-html:`

` -**Example** -:raw-html:`

` - -**Introduction** - -A BLE beacon broadcasts its identity to nearby Bluetooth devices, to -enable the other devices to determine their location relative to the -beacon, and to perform actions based on information broadcasted by the -beacon. - -Example applications of beacons include indoor positioning system, -location-based advertising and more. - -From the definition of its purpose as a broadcast device, a BLE beacon -thus cannot be connected to, and can only send information in its -Bluetooth advertisement packets. - -There are several BLE beacon protocols. The Ameba BLEBeacon library -supports the iBeacon and AltBeacon protocols. - -**Procedure** - -First, you need to install some Bluetooth apps on your mobile phone. -These apps will show you the raw data sent by Ameba and allow you to -interact with the data. - -The recommended application is nRF connect, and is available at the -links below: - -- Android: https://play.google.com/store/apps/details?id=no.nordicsemi.android.mcp - -- iOS :https://apps.apple.com/us/app/nrf-connect/id1054362403 - -LightBlue is an alternative application that can also be used, but has -less features: - -- Android: https://play.google.com/store/apps/details?id=com.punchthrough.lightblueexplorer - -- iOS :https://apps.apple.com/us/app/lightblue/id557428110 - -Open the example, ``“Files” → “Examples” → “AmebaBLE” → “BLEBeacon”`` - -.. image:: /media/ambd_arduino/BLE_Beacon/image1.png - :align: center - :width: 722 - :height: 1006 - :scale: 69 % - - -Upload the code and press the reset button on Ameba once the upload is -finished. - -On your mobile phone, open the Bluetooth app and scan for the beacon -signal broadcast by Ameba. - -.. image:: /media/ambd_arduino/BLE_Beacon/image2.png - :align: center - :width: 1440 - :height: 2880 - :scale: 24 % - -If you happen to be in an environment with multiple BLE beacons, you can -tap the entries to expand them, and verify that the beacon data is -identical to the data in the sketch. - -:raw-html:`

` -**Code Reference** -:raw-html:`

` - -``setRssi()`` is used to set the received signal strength indicator (rssi) -data field for a beacon. The specification states that this should be -the received signal strength from the beacon at a 1 meter distance. With -no method to measure this, it is set to -65dBm as an estimate. - -``setMajor()`` and ``setMinor()`` are used to set the two data fields. The -purpose of these data are left for the manufacturer of the beacon to -define, and can be used in any way. - -``setUUID()`` is used to give the beacon a universally unique identifier -(UUID). This is a 128-bit number usually expressed as a hexadecimal -string. It is used to identify each unique beacon, and can be randomly -generated for free online. - -The BLEBeacon library includes both iBeacon and AltBeacon classes, -replace line 6 iBeacon with altBeacon to create an AltBeacon instead. -The data fields are mostly the same, with only minor changes, please -look at the header files for more details. - -``BLE.init()`` is used to allocate memory and prepare Ameba for starting the -Bluetooth stack. - -``BLE.configAdvert()`` is used to configure the Bluetooth advertisement -settings, to which we pass the beacon data and set the device as -non-connectable. - -``BLE.beginPeripheral()`` starts Ameba in Bluetooth peripheral mode, after -which it will begin to advertise with the beacon data provided. diff --git a/bak/ambd/_common/Example_Guides/BLE/BLE - BLE Scan.rst b/bak/ambd/_common/Example_Guides/BLE/BLE - BLE Scan.rst deleted file mode 100644 index cfea6f7..0000000 --- a/bak/ambd/_common/Example_Guides/BLE/BLE - BLE Scan.rst +++ /dev/null @@ -1,79 +0,0 @@ -################################################# -BLE – BLE Scan -################################################# - -.. role:: raw-html(raw) - :format: html - -:raw-html:`

` -**Materials** -:raw-html:`

` - - - AmebaD [AMB21 / AMB22 / AMB23 / BW16] x 1 - - Android / iOS mobile phone - -:raw-html:`

` -**Example** -:raw-html:`

` - -**Introduction** - -This example configures the Ameba as a Bluetooth central device, uses -the scan functionality to scan for other Bluetooth devices, and prints -out the results to the serial monitor. - -**Procedure** - -Open the example, ``“Files” → “Examples” → “AmebaBLE” → “BLEScan”`` - -.. image:: /media/ambd_arduino/BLE_Scan/image1.png - :align: center - :width: 711 - :height: 1006 - :scale: 79 % - -Upload the code and press the reset button on Ameba once the upload is -finished. -Open the Arduino serial monitor, and you should see the scan results -of nearby Bluetooth devices formatted and printed out. - -.. image:: /media/ambd_arduino/BLE_Scan/image2.png - :align: center - :width: 757 - :height: 907 - :scale: 88 % - -If you have the Bluetooth app nRF Connect installed, you can also use it -to send out Bluetooth advertisements for the Ameba to pick up. - -:raw-html:`

` -**Code Reference** -:raw-html:`

` - -``setScanMode(GAP_SCAN_MODE_ACTIVE)`` is used to set the scan mode. Active -scanning will request for an additional scan response data packet from a -device when it is found. Passive scanning will only look at the -advertisement data, and not request for additional data. - -``setScanInterval()`` and ``setScanWindow()`` are used to set the frequency and -duration of scans in milliseconds. A scan will start every interval -duration, and each scan will last for the scan window duration. The scan -window duration should be lesser or equal to the scan interval. Set a -short interval to discover devices rapidly, set a long interval to -conserve power. - -``setScanCallback(scanFunction)`` is used to register a function to be -called when scan results are received. This can be used to set a user -function for additional processing of scan data, such as looking for a -specific device. If no function is registered, the scan results are -formatted and printed to the serial monitor by default. - -``beginCentral(0)`` is used to start the Bluetooth stack in Central mode. -The argument 0 is used to indicate that no clients will be operating in -central mode. - -``startScan(5000)`` is used to start the scanning process for a specified -duration of 5000 milliseconds. The scan will repeat according to the set -scan interval and scan window values. After 5000 milliseconds, the scan -process will stop, and will be ready to be started again. - diff --git a/bak/ambd/_common/Example_Guides/BLE/BLE - BLE UART Client.rst b/bak/ambd/_common/Example_Guides/BLE/BLE - BLE UART Client.rst deleted file mode 100644 index 210e67c..0000000 --- a/bak/ambd/_common/Example_Guides/BLE/BLE - BLE UART Client.rst +++ /dev/null @@ -1,64 +0,0 @@ -################################################# -BLE – BLE UART Client -################################################# - -.. role:: raw-html(raw) - :format: html - -:raw-html:`

` -**Materials** -:raw-html:`

` - - - AmebaD [AMB21 / AMB22 / AMB23 / BW16] x 2 - -:raw-html:`

` -**Example** -:raw-html:`

` - -**Introduction** - -In this example, two RTL8722 boards are connected using BLE. One board -runs a BLE UART service, while the other connects to the service using a -client and both boards are able to communicate with text messages over -the UART service. - -**Procedure** - -On the first board, upload the BLE UART service example code. Refer to -the example guide for detailed instructions. - -For the second board, open the example, ``“Files” → “Examples” → -“AmebaBLE” → “BLEUartClient”``. - -.. image:: /media/ambd_arduino/BLE_UART_Client/image1.png - :align: center - :width: 682 - :height: 1202 - :scale: 83 % - -Upload the code and press the reset button on Ameba once the upload is -finished. -Reset the UART service board first, wait for the BLE advertisement -process to begin, and reset the UART client board. The client board -should scan, discover, and connect to the service board. After -connecting, the client board will verify that the correct UART service -exists on the service board, before enabling notifications on the TX -characteristic. Any message typed in the serial terminal will be sent -to the other board using the UART service. - -.. image:: /media/ambd_arduino/BLE_UART_Client/image2.png - :align: center - :width: 779 - :height: 619 - -:raw-html:`

` -**Code Reference** -:raw-html:`

` - -The BLEClient class is used to discover the services that exist on a -connected BLE device. The discovery process will create -BLERemoteService, BLERemoteCharacteristic and BLERemoteDescriptor -objects corresponding to the services, characteristics and descriptors -that exist on the connected device. These objects can then be used to -read and write data to the connected device. - diff --git a/bak/ambd/_common/Example_Guides/BLE/BLE - BLE UART Service.rst b/bak/ambd/_common/Example_Guides/BLE/BLE - BLE UART Service.rst deleted file mode 100644 index 3ca9a1d..0000000 --- a/bak/ambd/_common/Example_Guides/BLE/BLE - BLE UART Service.rst +++ /dev/null @@ -1,110 +0,0 @@ -################################################# -BLE – BLE UART Service -################################################# - -.. role:: raw-html(raw) - :format: html - -:raw-html:`

` -**Materials** -:raw-html:`

` - - - AmebaD [AMB21 / AMB22 / AMB23 / BW16] x 1 - - Android / iOS smartphone - -:raw-html:`

` -**Example** -:raw-html:`

` - -**Introduction** - -With BLE, application data is sent and received using the GATT system. -GATT uses services, characteristics, and attributes to organise data -and control how the data can be read from and written to. The -Bluetooth SIG specification for BLE includes several predefined -services for common applications, but users are free to implement -custom services and characteristics to best fit their data structure -and application needs. - -In this example, the BLEService and BLECharacteristic classes are used -to implement a custom service for transmitting ASCII characters -similar to regular UART. This custom service is the Nordic UART -Service, which is supported in several smartphone apps. - -**Procedure** - -Ensure that a compatible BLE UART app is installed on your smartphone, -it is available at: - -– Google Play Store: -https://play.google.com/store/apps/details?id=com.adafruit.bluefruit.le.connect -https://play.google.com/store/apps/details?id=de.kai_morich.serial_bluetooth_terminal - -– Apple App Store: -https://apps.apple.com/us/app/bluefruit-connect/id830125974 - -Open the example, ``“Files” → “Examples” → “AmebaBLE” → -“BLEUartService”``. - -.. image:: /media/ambd_arduino/BLE_UART_Service/image1.png - :align: center - :width: 696 - :height: 1126 - :scale: 88 % - -Upload the code and press the reset button on Ameba once the upload is -finished. -Open the app on your smartphone, scan and connect to the Ameba board -shown as “AMEBA_BLE_DEV” and choose the UART function in the app. Note -that the BLE UART service on the Ameba board will only work with the -UART and Plotter functions in the Bluefruit Connect app, other -functions (Pin I/O, Image Transfer) require other BLE services that -are not included in this example. - -.. image:: /media/ambd_arduino/BLE_UART_Service/image1-2.png - :align: center - :width: 1440 - :height: 2880 - :scale: 34 % - -.. image:: /media/ambd_arduino/BLE_UART_Service/image1-3.png - :align: center - :width: 1440 - :height: 2880 - :scale: 34 % - -In the UART terminal section of the app, enter a message and click -send. You should see the message appear in the Arduino serial monitor. -In the Arduino serial monitor, enter a message and click send. The -message will appear in the smartphone app. - -.. image:: /media/ambd_arduino/BLE_UART_Service/image1-4.png - :align: center - :width: 1440 - :height: 2880 - :scale: 34 % - -.. image:: /media/ambd_arduino/BLE_UART_Service/image5.png - :align: center - :width: 779 - :height: 619 - -:raw-html:`

` -**Code Reference** -:raw-html:`

` - -The BLECharacteristic class is used to create two characteristics, one -for receive (Rx) and one for transmit (Tx), and added to a service -created with the BLEService class. -The required read/write/notify properties are set for each -characteristic using the ``set__Property()`` methods, and callback -functions are registered using the ``set__Callback()`` methods. The -required buffer size is also set for each characteristic so that it -has enough memory to store a complete string. -When data is written to the receive characteristic, the registered -callback function is called, which prints out the received data as a -string to the serial monitor. -When data is received on the serial port, it is copied into the -transmit characteristic buffer, and the ``notify()`` method is used to -inform the connected device of the new data. - diff --git a/bak/ambd/_common/Example_Guides/BLE/BLE - Battery Client.rst b/bak/ambd/_common/Example_Guides/BLE/BLE - Battery Client.rst deleted file mode 100644 index 3cf07d4..0000000 --- a/bak/ambd/_common/Example_Guides/BLE/BLE - Battery Client.rst +++ /dev/null @@ -1,83 +0,0 @@ -################################################# -BLE – Battery Client -################################################# - -.. role:: raw-html(raw) - :format: html - -:raw-html:`

` -**Materials** -:raw-html:`

` - - - AmebaD [AMB21 / AMB22 / AMB23 / BW16] x 1 - -:raw-html:`

` -**Example** -:raw-html:`

` - -**Introduction** - -BLE connections use a server client model. The server contains the data -of interest, while the client connects to the server to read the data. -Commonly, a Bluetooth peripheral device acts as a server, while a -Bluetooth central device acts as a client. Servers can contain many -services, with each service containing a some set of data. Clients can -send requests to read or write some data and can also subscribe to -notifications so that the server can send data updates to a client. - -In this example, a basic battery client is set up on the Ameba Bluetooth -stack. The client connects to another Ameba board running the -corresponding BLE battery service to read the battery level data. - -**Procedure** - -On the first Ameba board, upload the BLEBatteryService example code and -let it run. - -For the second Ameba board, open the example ``“Files” → “Examples” → -“AmebaBLE” → “BLEBatteryClient”``. - -.. image:: /media/ambd_arduino/BLE_Battery_Client/image1.png - :align: center - :width: 832 - :height: 1006 - :scale: 70 % - -Upload the code and press the reset button on Ameba once the upload is -finished. - -Open the serial monitor and observe the log messages as the Ameba board -with the battery client scans, connects, and reads data from the Ameba -board with the battery service. - -.. image:: /media/ambd_arduino/BLE_Battery_Client/image2.png - :align: center - :width: 741 - :height: 588 - -Highlighted in yellow, the Ameba board with the battery client first -scans for advertising BLE devices with the advertised device name -“AMEBA_BLE_DEV” and the advertised service UUID of 0x180F representing -the battery service. - -After finding the target device, the Ameba board with the battery client -forms a BLE connection and searches for a battery service on the -connected device, highlighted in blue. - -With the client connected to the service, the battery client begins to -read data using both regular data reads and notifications, highlighted -in green. - -:raw-html:`

` -**Code Reference** -:raw-html:`

` - -BLEClient is used to create a client object to discover services and -characteristics on the connected device. - - - ``setNotifyCallback()`` is used to register a function that will be called - when a battery level notification is received. - - ``BLE.configClient()`` is used to configure the Bluetooth stack for client - operation. - - ``addClient(connID)`` creates a new BLEClient object that corresponds to the - connected device. \ No newline at end of file diff --git a/bak/ambd/_common/Example_Guides/BLE/BLE - DHT over BLE UART.rst b/bak/ambd/_common/Example_Guides/BLE/BLE - DHT over BLE UART.rst deleted file mode 100644 index e76146d..0000000 --- a/bak/ambd/_common/Example_Guides/BLE/BLE - DHT over BLE UART.rst +++ /dev/null @@ -1,109 +0,0 @@ -################################################# -BLE – DHT over BLE UART -################################################# - -.. role:: raw-html(raw) - :format: html - -:raw-html:`

` -**Materials** -:raw-html:`

` - - - AmebaD [AMB21 / AMB22 / AMB23 / BW16] x 1 - - DHT11 or DHT22 or DHT21 - - Android / iOS smartphone - -:raw-html:`

` -**Example** -:raw-html:`

` - -**Introduction** - -In this example, the data obtained from a DHT temperature and humidity -sensor are transmitted over a BLE UART service to a smartphone. Refer to -the other examples for detailed explanations of using the DHT sensor and -the BLE UART service. - -**Procedure** - -Connect the DHT sensor to the Ameba board following the diagram. - -**AMB21 / AMB22:** - -.. image:: /media/ambd_arduino/BLE_DHT_over_BLE_UART/image1.png - :align: center - :width: 1077 - :height: 930 - :scale: 64 % - -**AMB23:** - -.. image:: /media/ambd_arduino/BLE_DHT_over_BLE_UART/image1-1.png - :align: center - :width: 863 - :height: 789 - :scale: 75 % - -**BW16:** - -.. image:: /media/ambd_arduino/BLE_DHT_over_BLE_UART/image1-2.png - :align: center - :width: 869 - :height: 1179 - :scale: 50 % - -**BW16-TypeC:** - -.. image:: /media/ambd_arduino/BLE_DHT_over_BLE_UART/image1-3.png - :align: center - :width: 683 - :height: 772 - :scale: 77 % - - -Ensure that a compatible BLE UART app is installed on your smartphone, -it is available at: - -– Google Play Store: -https://play.google.com/store/apps/details?id=com.adafruit.bluefruit.le.connect -https://play.google.com/store/apps/details?id=de.kai_morich.serial_bluetooth_terminal - -– Apple App Store: -https://apps.apple.com/us/app/bluefruit-connect/id830125974 - - -Open the example, ``“Files” → “Examples” → “AmebaBLE” → -“DHT_over_BLEUart”``. - -.. image:: /media/ambd_arduino/BLE_DHT_over_BLE_UART/image2.png - :align: center - :width: 750 - :height: 1044 - :scale: 86 % - -Upload the code and press the reset button on Ameba once the upload is -finished. -Open the app on your smartphone, scan and connect to the Ameba board -shown as “AMEBA_BLE_DEV” and choose the UART function in the app. - -.. image:: /media/ambd_arduino/BLE_DHT_over_BLE_UART/image3.png - :align: center - :width: 1440 - :height: 2880 - :scale: 34 % - -.. image:: /media/ambd_arduino/BLE_DHT_over_BLE_UART/image4.png - :align: center - :width: 1440 - :height: 2880 - :scale: 34 % - -After starting the UART function, notifications should be received every -5 seconds containing the measured temperature and humidity. - -.. image:: /media/ambd_arduino/BLE_DHT_over_BLE_UART/image5.png - :align: center - :width: 1440 - :height: 2880 - :scale: 34 % - diff --git a/bak/ambd/_common/Example_Guides/BLE/BLE - HID Gamepad.rst b/bak/ambd/_common/Example_Guides/BLE/BLE - HID Gamepad.rst deleted file mode 100644 index 6f8fa6b..0000000 --- a/bak/ambd/_common/Example_Guides/BLE/BLE - HID Gamepad.rst +++ /dev/null @@ -1,96 +0,0 @@ -################################################# -BLE - HID Gamepad -################################################# - -.. role:: raw-html(raw) - :format: html - -:raw-html:`

` -**Materials** -:raw-html:`

` - - - AmebaD [AMB21 / AMB22 / AMB23 / BW16] x 1 - - BLE capable host device [Windows / Linux / MacOS / Android - -:raw-html:`

` -**Example** -:raw-html:`

` - -**Introduction** - -In this example, the RTL8722 board emulates a HID gamepad connected using BLE. - -**Procedure** - -Open the example, ``“Files” → “Examples” → “AmebaBLE” → BLEHIDGamepad``. - -.. image:: /media/ambd_arduino/BLE_HID_Gamepad/1.png - :align: center - :width: 637 - :height: 1202 - :scale: 83 % - - -Upload the code and press the reset button once the upload is finished. -Immediately after reset, the board will begin BLE advertising as “AMEBA_BLE_HID”. -On your host device, go to the Bluetooth settings menu, scan, and connect to the board. -You should ensure that the connection process is completed before proceeding. -On Windows, ensure that any driver installation is finished, and the board shows up -in the Bluetooth menu under the “Mouse, keyboard & pen” category. - -.. image:: /media/ambd_arduino/BLE_HID_Gamepad/2.png - :align: center - :width: 2560 - :height: 1397 - :scale: 50 % - -On Android, ensure that “Input device” is enabled for the board. - -.. image:: /media/ambd_arduino/BLE_HID_Gamepad/3.png - :align: center - :width: 1440 - :height: 2880 - :scale: 34 % - -After the Bluetooth connection process is completed, the board is ready to send -gamepad input to the host device. Connect digital pin 8 to 3.3V to start sending input, -and connect to GND to stop. -To view the input, open a browser window and go to `Gamepad Tester `_. -The connected gamepad device should show up here, and some of the buttons and axes should show changing values. - -.. image:: /media/ambd_arduino/BLE_HID_Gamepad/4.png - :align: center - :width: 1006 - :height: 585 - -On Windows, gamepad input can also be viewed by going to -“Control Panel” -> “Devices and Printers” -> “AMEBA_BLE_HID” -> “Game Controller Settings” -> “Properties”. -The buttons and axes should also show changing values here. - -.. image:: /media/ambd_arduino/BLE_HID_Gamepad/5.png - :align: center - :width: 952 - :height: 658 - -.. image:: /media/ambd_arduino/BLE_HID_Gamepad/6.png - :align: center - :width: 952 - :height: 658 - -On Android, gamepad testing apps such as `Andriod Gamepad Tester `_ -can also be used to view the gamepad input. - -.. image:: /media/ambd_arduino/BLE_HID_Gamepad/7.png - :align: center - :width: 2880 - :height: 1440 - :scale: 34 % - -:raw-html:`

` -**Code Reference** -:raw-html:`

` - -By default, the board emulates a gamepad with an 8-direction hat switch (d-pad), 6 analog axes and 16 buttons. How the inputs are interpreted is -dependent on the host device, and the button ordering may differ between devices. -Also, some axes or buttons may be disabled or missing on certain host devices. - diff --git a/bak/ambd/_common/Example_Guides/BLE/BLE - HID Keyboard.rst b/bak/ambd/_common/Example_Guides/BLE/BLE - HID Keyboard.rst deleted file mode 100644 index 6189627..0000000 --- a/bak/ambd/_common/Example_Guides/BLE/BLE - HID Keyboard.rst +++ /dev/null @@ -1,64 +0,0 @@ -################################################# -BLE - HID Keyboard -################################################# - -.. role:: raw-html(raw) - :format: html - -:raw-html:`

` -**Materials** -:raw-html:`

` - - - AmebaD [AMB21 / AMB22 / AMB23 / BW16] x 1 - - BLE capable host device [Windows / Linux / MacOS / Android - -:raw-html:`

` -**Example** -:raw-html:`

` - -**Introduction** - -In this example, the RTL8722 board emulates a HID keyboard connected using BLE. - -**Procedure** - -Open the example, ``“Files” -> “Examples” -> “AmebaBLE” -> BLEHIDKeyboard``. - - |1| - -Upload the code and press the reset button once the upload is finished. -Immediately after reset, the board will begin BLE advertising as “AMEBA_BLE_HID”. -On your host device, go to the Bluetooth settings menu, scan, and connect to the board. -You should ensure that the connection process is completed before proceeding. -On Windows, ensure that any driver installation is finished, and the board shows up -in the Bluetooth menu under the “Mouse, keyboard & pen” category. - - |2| - -On Android, ensure that “Input device” is enabled for the board. - - |3| - -After the Bluetooth connection process is completed, the board is ready to send -mouse input to the host device. Connect digital pin 8 to 3.3V to start sending input, -and connect to GND to stop. -You should see the text “Hello World !” typed out and deleted repeatedly. - - |4| - -.. |1| image:: /media/ambd_arduino/BLE_HID_Keyboard/1.png - :width: 637 - :height: 1202 - :scale: 100 % -.. |2| image:: /media/ambd_arduino/BLE_HID_Keyboard/2.png - :width: 2560 - :height: 1397 - :scale: 30 % -.. |3| image:: /media/ambd_arduino/BLE_HID_Keyboard/3.png - :width: 1440 - :height: 2880 - :scale: 25 % -.. |4| image:: /media/ambd_arduino/BLE_HID_Keyboard/4.png - :width: 753 - :height: 596 - :scale: 100 % \ No newline at end of file diff --git a/bak/ambd/_common/Example_Guides/BLE/BLE - HID Mouse.rst b/bak/ambd/_common/Example_Guides/BLE/BLE - HID Mouse.rst deleted file mode 100644 index fc015d5..0000000 --- a/bak/ambd/_common/Example_Guides/BLE/BLE - HID Mouse.rst +++ /dev/null @@ -1,67 +0,0 @@ -################################################# -BLE - HID Mouse -################################################# - -.. role:: raw-html(raw) - :format: html - -:raw-html:`

` -**Materials** -:raw-html:`

` - - - AmebaD [AMB21 / AMB22 / AMB23 / BW16] x 1 - - BLE capable host device [Windows / Linux / MacOS / Android - -:raw-html:`

` -**Example** -:raw-html:`

` - -**Introduction** - -In this example, the RTL8722 board emulates a HID mouse connected using BLE. - -**Procedure** - -Open the example, ``“Files” → “Examples” → “AmebaBLE” → “BLEHIDMouse”``. - - |1| - -Upload the code and press the reset button once the upload is finished. -Immediately after reset, the board will begin BLE advertising as “AMEBA_BLE_HID”. -On your host device, go to the Bluetooth settings menu, scan, and connect to the board. -You should ensure that the connection process is completed before proceeding. -On Windows, ensure that any driver installation is finished, and the board shows up -in the Bluetooth menu under the “Mouse, keyboard & pen” category. - - |2| - -On Android, ensure that “Input device” is enabled for the board. - - |3| - -After the Bluetooth connection process is completed, the board is ready to send -mouse input to the host device. Connect digital pin 8 to 3.3V to start sending input, -and connect to GND to stop. -You should see the mouse cursor move around four points in a square, performing -right and left clicks, and scrolling up and down. - -:raw-html:`

` -**Code Reference** -:raw-html:`

` - -How the mouse input is interpreted is dependent on the host system. -Some systems, such as mobile operating systems, may not support all mouse button input functions. - - -.. |1| image:: /media/ambd_arduino/BLE_HID_Mouse/1.png - :width: 637 - :height: 1202 - :scale: 70 % -.. |2| image:: /media/ambd_arduino/BLE_HID_Mouse/2.png - :width: 2560 - :height: 1397 - :scale: 40 % -.. |3| image:: /media/ambd_arduino/BLE_HID_Mouse/3.png - :width: 1440 - :height: 2880 - :scale: 25 % \ No newline at end of file diff --git a/bak/ambd/_common/Example_Guides/BLE/BLE - PWM over BLE UART.rst b/bak/ambd/_common/Example_Guides/BLE/BLE - PWM over BLE UART.rst deleted file mode 100644 index 76acaab..0000000 --- a/bak/ambd/_common/Example_Guides/BLE/BLE - PWM over BLE UART.rst +++ /dev/null @@ -1,128 +0,0 @@ -################################################# -BLE – PWM over BLE UART -################################################# - -.. role:: raw-html(raw) - :format: html - -:raw-html:`

` -**Materials** -:raw-html:`

` - - - AmebaD [AMB21 / AMB22 / AMB23 / BW16] x 1 - - RGB LED - - Android / iOS smartphone - -:raw-html:`

` -**Example** -:raw-html:`

` - -**Introduction** - -In this example, a smartphone app is used to transmit commands over BLE -UART to control the PWM outputs and change the color of a RGB LED. Refer -to the other example guides for detailed explanations of the BLE UART -service. - -**Procedure** - -Connect the RGB LED to the RTL8722 board following the diagram, the -common LED pin may need to connect to 3.3V or GND depending on the type -of LED (common anode / common cathode). - -**AMB21 /AMB22:** - -.. image:: /media/ambd_arduino/BLE_PWM_over_BLE_UART/image1.png - :align: center - :width: 1383 - :height: 1048 - :scale: 66 % - - -**AMB23:** - -.. image:: /media/ambd_arduino/BLE_PWM_over_BLE_UART/image1-1.png - :align: center - :width: 1012 - :height: 699 - -**BW16:** - -.. image:: /media/ambd_arduino/BLE_PWM_over_BLE_UART/image1-2.png - :align: center - :width: 1564 - :height: 1079 - :scale: 64 % - - -**BW16-TypeC:** - -.. image:: /media/ambd_arduino/BLE_PWM_over_BLE_UART/image1-3.png - :align: center - :width: 1058 - :height: 715 - :scale: 97 % - -| Ensure that the required app is installed on your smartphone, it is - available at: -| – Google Play Store: -| https://play.google.com/store/apps/details?id=com.adafruit.bluefruit.le.connect - -| – Apple App Store: -| https://apps.apple.com/us/app/bluefruit-connect/id830125974 - -Open the example, ``“Files” → “Examples” → “AmebaBLE” → -“PWM_over_BLEUart”``. - -Upload the code and press the reset button on Ameba once the upload is -finished. - -.. image:: /media/ambd_arduino/BLE_PWM_over_BLE_UART/image2.png - :align: center - :width: 682 - :height: 1202 - :scale: 83 % - -| Open the app on your smartphone, scan and connect to the board shown as - “AMEBA_BLE_DEV” and choose the controller → color picker function in - the app. - -.. image:: /media/ambd_arduino/BLE_PWM_over_BLE_UART/image3.png - :align: center - :width: 1440 - :height: 2880 - :scale: 34 % - -.. image:: /media/ambd_arduino/BLE_PWM_over_BLE_UART/image4.png - :align: center - :width: 1440 - :height: 2880 - :scale: 34 % - -.. image:: /media/ambd_arduino/BLE_PWM_over_BLE_UART/image5.png - :align: center - :width: 1440 - :height: 2880 - :scale: 34 % - -Using the color selection wheel, saturation, and brightness sliders, -choose a desired color and click select to send the RGB values to the -board. You should see the RGB LED change to the matching color. - -.. image:: /media/ambd_arduino/BLE_PWM_over_BLE_UART/image6.png - :align: center - :width: 1440 - :height: 2880 - :scale: 34 % - -:raw-html:`

` -**Code Reference** -:raw-html:`

` - -The RGB values are sent as three consecutive bytes prefixed by “!C” -characters. The “!” exclamation mark is used to indicate that the -following data is a command, and the “C” character is used to indicate -that the data is RGB values. The received UART message is checked in the -callback function for “!C” first, otherwise it is treated as a regular -message and printed to the serial terminal. - diff --git a/bak/ambd/_common/Example_Guides/BLE/BLE - V7RC Car.rst b/bak/ambd/_common/Example_Guides/BLE/BLE - V7RC Car.rst deleted file mode 100644 index d845877..0000000 --- a/bak/ambd/_common/Example_Guides/BLE/BLE - V7RC Car.rst +++ /dev/null @@ -1,2 +0,0 @@ -BLE - V7RC Car -============== \ No newline at end of file diff --git a/bak/ambd/_common/Example_Guides/BLE/BLE - WiFi Configuration Service.rst b/bak/ambd/_common/Example_Guides/BLE/BLE - WiFi Configuration Service.rst deleted file mode 100644 index 4928b37..0000000 --- a/bak/ambd/_common/Example_Guides/BLE/BLE - WiFi Configuration Service.rst +++ /dev/null @@ -1,113 +0,0 @@ -################################################# -BLE – WiFi Configuration Service -################################################# - -.. role:: raw-html(raw) - :format: html - -:raw-html:`

` -**Materials** -:raw-html:`

` - - - AmebaD [AMB21 / AMB22 / AMB23 / BW16] x 1 - - Android / iOS mobile phone - -:raw-html:`

` -**Example** -:raw-html:`

` - -**Introduction** - -In this example, a WiFi configuration service is set up on the Ameba -Bluetooth stack. A mobile phone with the configuration app connects to -the Ameba device using BLE and configures the Ameba to connect to the -correct WiFi access point. - -**Procedure** - -Ensure that the Realtek WiFi configuration app is installed on your -mobile phone, it is available at: - -– Google Play -Store: https://play.google.com/store/apps/details?id=com.rtk.btconfig - -– Apple App -Store: https://apps.apple.com/sg/app/easy-wifi-config/id1194919510 - -Open the example, ``“Files” -> “Examples” -> “AmebaBLE” -> -“BLEWifiConfigService”``. - -|1| - - -Upload the code and press the reset button on Ameba once the upload is -finished. - -On your mobile phone, open the Realtek WiFiConfig app and tap the round -button to scan for Ameba boards. - -|2| - -Select the correct Ameba board from the scan results. The app will -connect to the Ameba board and ask the board to scan for WiFi networks -and send the scan results back to the app using BLE. - -|3| - -|4| - -|5| - -If your phone is currently connected to a WiFi network, the app will ask -for the WiFi password to connect the Ameba board to the same WiFi -network. Tap “Select AP” to choose another WiFi network, or enter the -password and tap continue to connect Ameba to the selected WiFi network. - -|6| - -After the Ameba board connects to the WiFi network, the following -message will be shown. Tap “Try another AP” to connect to another WiFi -network or tap “Confirm” to keep the current WiFi network and disconnect -BLE from the Ameba board. - -|7| - -:raw-html:`

` -**Code Reference** -:raw-html:`

` - -BLEWifiConfigService is used to create an instance of the WiFi -configuration service to run on the Bluetooth device. - -``BLE.configAdvert()->setAdvType(configService.advData())`` is used to set -the correct advertisement data necessary for the phone app to find the -Ameba Bluetooth device. - -.. |1| image:: /media/ambd_arduino/BLE_WiFi_Configuration_Service/image1.png - :width: 832 - :height: 1016 - :scale: 60 % -.. |2| image:: /media/ambd_arduino/BLE_WiFi_Configuration_Service/image2.png - :width: 1440 - :height: 2880 - :scale: 25 % -.. |3| image:: /media/ambd_arduino/BLE_WiFi_Configuration_Service/image3.png - :width: 1440 - :height: 2880 - :scale: 25 % -.. |4| image:: /media/ambd_arduino/BLE_WiFi_Configuration_Service/image4.png - :width: 1440 - :height: 2880 - :scale: 25 % -.. |5| image:: /media/ambd_arduino/BLE_WiFi_Configuration_Service/image5.png - :width: 1440 - :height: 2880 - :scale: 25 % -.. |6| image:: /media/ambd_arduino/BLE_WiFi_Configuration_Service/image6.png - :width: 1440 - :height: 2880 - :scale: 25 % -.. |7| image:: /media/ambd_arduino/BLE_WiFi_Configuration_Service/image7.png - :width: 1440 - :height: 2880 - :scale: 25 % \ No newline at end of file diff --git a/bak/ambd/_common/Example_Guides/Debugging/Debugging - Using the Debug Interface.rst b/bak/ambd/_common/Example_Guides/Debugging/Debugging - Using the Debug Interface.rst deleted file mode 100644 index 332f50c..0000000 --- a/bak/ambd/_common/Example_Guides/Debugging/Debugging - Using the Debug Interface.rst +++ /dev/null @@ -1,2 +0,0 @@ -Debugging - Using the Debug Interface -===================================== \ No newline at end of file diff --git a/bak/ambd/_common/Example_Guides/Flash Memory/Flash Memory - Store data in FlashEEProm.rst b/bak/ambd/_common/Example_Guides/Flash Memory/Flash Memory - Store data in FlashEEProm.rst deleted file mode 100644 index ab63e97..0000000 --- a/bak/ambd/_common/Example_Guides/Flash Memory/Flash Memory - Store data in FlashEEProm.rst +++ /dev/null @@ -1,60 +0,0 @@ -########################################################################## -Flash Memory - Store data in FlashEEProm -########################################################################## - -.. role:: raw-html(raw) - :format: html - -:raw-html:`

` -**Preparation** -:raw-html:`

` - - - AmebaD [AMB21 / AMB22 / AMB23 / BW16] x 1 - -:raw-html:`

` -**Example** -:raw-html:`

` - -| Ameba provides Flash Memory component for data storage and the data - can be preserved when the power is off if necessary, e.g., compiled - program. To avoid the memory space overlapped with the program on - Ameba, the Flash API uses the tail part of the address space, with - sector size 4K. -| In this example, we store the value of boot times in flash memory. - Every time Ameba reboots, it reads the boot times from flash, - increases the value by 1, and writes it back to flash memory. - -| First open the example, ``“File” → “Example” → “AmebaFlashMemory” → - “FlashMemoryBasic”`` -| |1| - -| Compile and upload to Ameba, then press the reset button. -| Open the Serial Monitor, press the reset button for a few times. Then - you can see the boot times value increases. -| |2| - -:raw-html:`

` -**Code Reference** -:raw-html:`

` - -By default, the Flash Memory API uses address 0xFF000~0xFFFFF to store -data. - -There is limitation when writing to flash memory. That is, you can not -directly write data to the same address you used in last write. To do -that correctly, you need erase the sector first. The Flash API of Ameba -uses a 4K SRAM to record the user modification and do the erase/write -task together. - -| Use ``FlashMemory.read()`` to read from Flash memory. -| Use ``FlashMemory.buf[0] = 0x00;`` to manipulate the 4K buf. -| Use ``FlashMemory.update();`` to update the data in buf to Flash Memory. - -.. |1| image:: /media/ambd_arduino/Flash_Memory_Store_Data_In_Flash_EEProm/image1.png - :width: 581 - :height: 1116 - :scale: 50 % -.. |2| image:: /media/ambd_arduino/Flash_Memory_Store_Data_In_Flash_EEProm/image2.png - :width: 677 - :height: 591 - :scale: 100 % \ No newline at end of file diff --git a/bak/ambd/_common/Example_Guides/Flash Memory/Flash Memory - Use Flash Memory Larger Than 4K.rst b/bak/ambd/_common/Example_Guides/Flash Memory/Flash Memory - Use Flash Memory Larger Than 4K.rst deleted file mode 100644 index 233c305..0000000 --- a/bak/ambd/_common/Example_Guides/Flash Memory/Flash Memory - Use Flash Memory Larger Than 4K.rst +++ /dev/null @@ -1,66 +0,0 @@ -########################################################################## -Flash Memory - Use Flash Memory Larger Than 4K -########################################################################## - -.. role:: raw-html(raw) - :format: html - -:raw-html:`

` -**Preparation** -:raw-html:`

` - - - AmebaD [AMB21 / AMB22 / AMB23 / BW16] x 1 - -:raw-html:`

` -**Example** -:raw-html:`

` - -| Flash Memory API uses memory of 4K bytes, which is normally sufficient - for most application. However, larger memory can be provided by - specifying a specific memory address and required size. - -| First, open the sample code in ``“File” → “Examples” → - “AmebaFlashMemory” → “ReadWriteOneWord”`` - -| In this example, we specify the starting address of flash memory is - 0xFC000 and size is 0x4000 (The default starting address is 0xFF000 - and size is 0x1000). -| Then calculate correct address according to the specified offset and - perform read/write operation. In the sample code we use offset 0x3F00, - that is, 0xFC000 + 0x3F00 = 0xFFF00 in flash. We set the value to 0 at - first, then increase by 1 every time Ameba reboots. - - |1| - -:raw-html:`

` -**Code Reference** -:raw-html:`

` - -We can use the flash api we used in previous flash memory example, but -we need to use ``begin()`` function to specify the desired starting address -and memory size. - -.. code-block:: C - - FlashMemory.begin(0xFC000, 0x4000); - -Use ``readWord()`` to read the value stored in a memory address. In the -example, we read the value stored in memory offset 0x3F00, that is -0xFC000 + 0x3F00 = 0xFFF00. ``readWord()`` function reads a 32-bit value and -returns it. - -.. code-block:: C - - value = FlashMemory.readWord(0x3F00); - -Use ``writeWord()`` to write to a memory address. The first argument is the -memory offset, the second argument is the value to write to memory. - -.. code-block:: C - - FlashMemory.writeWord(0x3F0C, value); - -.. |1| image:: /media/ambd_arduino/Flash_Memory_Use_Flash_Memory_larger_than_4K/image1.png - :width: 677 - :height: 591 - :scale: 100 % \ No newline at end of file diff --git a/bak/ambd/_common/Example_Guides/GPIO/GPIO - Measure Distance By Ultrasound Module.rst b/bak/ambd/_common/Example_Guides/GPIO/GPIO - Measure Distance By Ultrasound Module.rst deleted file mode 100644 index 423dd12..0000000 --- a/bak/ambd/_common/Example_Guides/GPIO/GPIO - Measure Distance By Ultrasound Module.rst +++ /dev/null @@ -1,150 +0,0 @@ -########################################################################## -GPIO - Measure Distance By Ultrasound Module -########################################################################## - -.. role:: raw-html(raw) - :format: html - -:raw-html:`

` -**Preparation** -:raw-html:`

` - - - AmebaD [AMB21 / AMB22 / AMB23 / BW16] x 1 - - HC-SR04 Ultrasonic x 1 - - Dropping resistor or Level converter - -:raw-html:`

` -**Example** -:raw-html:`

` - -HC-SR04 is a module that uses ultrasound to measure the distance. It -looks like a pair of eyes in its appearance, therefore it’s often -installed onto robot-vehicle or mechanical bugs to be their eyes. -The way it works is that first we “toggle high” the TRIG pin (that is to -pull high then pull low). The HC-SR04 would send eight 40kHz sound wave -signal and pull high the ECHO pin. When the sound wave returns back, it -pull low the ECHO pin. - -.. image:: /media/ambd_arduino/GPIO_Measure_Distance_By_Ultrasound_Module/image1.png - :align: center - :width: 1103 - :height: 679 - -Assume the velocity of sound is 340 m/s, the time it takes for the sound to advance 1 cm in the air is 340*100*10^-6 = 29 us. -The sound wave actually travels twice the distance between HC-SR04 and the object, therefore the distance can be calculated by (time/29) / 2 = time / 58. -The working voltage of HC-SR04 is 5V. When we pull high the ECHO pin to 5V, the voltage might cause -damage to the GPIO pin of Ameba. To avoid this situation, we need to -drop the voltage as follows: - -**AMB21 / AMB22** Wiring Diagram: - -.. image:: /media/ambd_arduino/GPIO_Measure_Distance_By_Ultrasound_Module/image2.png - :align: center - :width: 1103 - :height: 679 - -**AMB23** Wiring Diagram: - -.. image:: /media/ambd_arduino/GPIO_Measure_Distance_By_Ultrasound_Module/image2-1.png - :align: center - :width: 1019 - :height: 768 - :scale: 91 % - -**BW16** Wiring Diagram: - -.. image:: /media/ambd_arduino/GPIO_Measure_Distance_By_Ultrasound_Module/image2-3.png - :align: center - :width: 939 - :height: 747 - :scale: 93 % - -**BW16-TypeC** Wiring Diagram: - -.. image:: /media/ambd_arduino/GPIO_Measure_Distance_By_Ultrasound_Module/image2-4.png - :align: center - :width: 995 - :height: 762 - :scale: 91 % - -We pick the resistors with resistance 1:2, in the example we use 10kΩ and 20kΩ. -If you do not have resistors in hand, you can use level converter instead.The TXB0108 8 channel level -converter is a suitable example: - -**AMB21 / AMB22** Wiring Diagram: - -.. image:: /media/ambd_arduino/GPIO_Measure_Distance_By_Ultrasound_Module/image3.png - :align: center - :width: 1501 - :height: 1083 - :scale: 64 % - -**AMB23** Wiring Diagram: - -.. image:: /media/ambd_arduino/GPIO_Measure_Distance_By_Ultrasound_Module/image3-1.png - :align: center - :width: 989 - :height: 700 - -**BW16** Wiring Diagram: - -.. image:: /media/ambd_arduino/GPIO_Measure_Distance_By_Ultrasound_Module/image3-3.png - :align: center - :width: 1140 - :height: 757 - :scale: 92 % - -**BW16-TypeC** Wiring Diagram: - -.. image:: /media/ambd_arduino/GPIO_Measure_Distance_By_Ultrasound_Module/image3-4.png - :align: center - :width: 1137 - :height: 696 - -Next, open the sample code in ``“File” → “Examples” → “AmebaGPIO” → “HCSR04_Ultrasonic”`` - -.. image:: /media/ambd_arduino/GPIO_Measure_Distance_By_Ultrasound_Module/image4.png - :align: center - :width: 599 - :height: 1006 - -Compile and upload to Ameba, then press the reset button. Open the Serial Monitor, the calculated result is -output to serial monitor every 2 seconds. - -.. image:: /media/ambd_arduino/GPIO_Measure_Distance_By_Ultrasound_Module/image5.png - :align: center - :width: 649 - :height: 372 - - -Note that the HCSR04 module uses the reflection of sound wave to calculate the distance, thus -the result can be affected by the surface material of the object (e.g., -harsh surface tends to cause scattering of sound wave, and soft surface -may cause the sound wave to be absorbed). - -:raw-html:`

` -**Code Reference** -:raw-html:`

` - -Before the measurement starts, we need to pull high the TRIG pin for -10us and then pull low. By doing this, we are telling the HC-SR04 that -we are about to start the measurement: - -.. code-block:: c - - digitalWrite(trigger_pin, HIGH); - delayMicroseconds(10); - digitalWrite(trigger_pin, LOW); - -Next, use pulseIn to measure the time when the ECHO pin is pulled high. - -.. code-block:: c - - duration = pulseIn (echo_pin, HIGH); - -Finally, use the formula to calculate the distance. - -.. code-block:: c - - distance = duration / 58; - diff --git a/bak/ambd/_common/Example_Guides/GPIO/GPIO - Measure Temperature and Humidity.rst b/bak/ambd/_common/Example_Guides/GPIO/GPIO - Measure Temperature and Humidity.rst deleted file mode 100644 index ac642ff..0000000 --- a/bak/ambd/_common/Example_Guides/GPIO/GPIO - Measure Temperature and Humidity.rst +++ /dev/null @@ -1,115 +0,0 @@ -########################################################################## -GPIO - Measure Temperature and Humidity -########################################################################## - -.. role:: raw-html(raw) - :format: html - -:raw-html:`

` -**Preparation** -:raw-html:`

` - - - AmebaD [AMB21 / AMB22 / AMB23 / BW16] x 1 - - DHT11 or DHT22 or DHT21 - -:raw-html:`

` -**Example** -:raw-html:`

` - -DHT11 is a temperature and humidity sensor which operates at voltage -3.3V~5V. At room temperature, the measurable range of the humidity is -20% ~ 90%RH with ±5%RH precision, the measurable range of the -temperature is 0 ~ 50℃ with ±2℃ precision. - -Another choice of temperature and humidity sensor is DHT22 sensor, -which has better precision. Its measurable range of the humidity is -0%~100%RH with ±5%RH precision, the measurable range of the -temperature is -40~125 ℃ with ±0.2℃ precision. -There are 4 pins on the sensor: - -.. image:: /media/ambd_arduino/GPIO_Measure_Temperature_And_Humidity/image1.png - :align: center - :width: 259 - :height: 332 - -Since one of the 4 pins has no function, there are temperature/humidity -sensors with only 3 pins on the market: - -.. image:: /media/ambd_arduino/GPIO_Measure_Temperature_And_Humidity/image2.png - :align: center - :width: 114 - :height: 276 - -DHT is normally in the sleeping mode. To get the temperature/humidity -data, please follow the steps: - - 1. Awake DHT: Ameba toggles low its DATA pin of GPIO. Now the DATA pin - of GPIO serves as digital out to Ameba. - - 2. DHT response: DHT also toggle low its DATA pin of GPIO. Now the DATA - pin of GPIO serves as digital in for Ameba. - - 3. DHT sends data: DHT sends out the temperature/humidity data (which - has size 5 bytes) in a bit by bit manner. To represent each bit, - DHT first pull low the DATA GPIO pin for a while and then pull - high. If the duration of high is smaller than low, it stands for - bit 0. Otherwise it stands for bit 1. - -.. image:: /media/ambd_arduino/GPIO_Measure_Temperature_And_Humidity/image3.png - :align: center - :width: 1429 - :height: 415 - -**AMB21 / AMB22** Wiring Diagram: - -.. image:: /media/ambd_arduino/GPIO_Measure_Temperature_And_Humidity/image4.png - :align: center - :width: 1077 - :height: 930 - :scale: 75 % - -**AMB23** Wiring Diagram: - -.. image:: /media/ambd_arduino/GPIO_Measure_Temperature_And_Humidity/image4-1.png - :align: center - :width: 863 - :height: 789 - :scale: 88 % - -**BW16** Wiring Diagram: - -.. image:: /media/ambd_arduino/GPIO_Measure_Temperature_And_Humidity/image4-3.png - :align: center - :width: 654 - :height: 670 - -**BW16-TypeC** Wiring Diagram: - -.. image:: /media/ambd_arduino/GPIO_Measure_Temperature_And_Humidity/image4-4.png - :align: center - :width: 724 - :height: 650 - - -Open the sample code in ``“Files” → “Examples” → “AmebaGPIO” → -“DHT_Tester”``. Compile and upload to Ameba, then press the reset button. -The result would be shown on the Serial Monitor. - -.. image:: /media/ambd_arduino/GPIO_Measure_Temperature_And_Humidity/image5.png - :align: center - :width: 1077 - :height: 930 - :scale: 75 % - -:raw-html:`

` -**Code Reference** -:raw-html:`

` - -Use ``dht.readHumidity()`` read the humidity value, and -use ``dht.readTemperature()`` to read the temperature value. - -Every time we read the temperature/humidity data, Ameba uses the -buffered temperature/humidity data unless it found the data has expired -(i.e., has not been updated for over 2 seconds). If the data is expired, -Ameba issues a request to DHT to read the latest data. - diff --git a/bak/ambd/_common/Example_Guides/GPIO/GPIO - Use GPIO Interrupt To Control LED.rst b/bak/ambd/_common/Example_Guides/GPIO/GPIO - Use GPIO Interrupt To Control LED.rst deleted file mode 100644 index 6058ac9..0000000 --- a/bak/ambd/_common/Example_Guides/GPIO/GPIO - Use GPIO Interrupt To Control LED.rst +++ /dev/null @@ -1,112 +0,0 @@ -########################################################################## -GPIO - Use GPIO Interrupt To Control LED -########################################################################## - -.. role:: raw-html(raw) - :format: html - -:raw-html:`

` -**Preparation** -:raw-html:`

` - - - AmebaD [AMB21 / AMB22 / AMB23 / BW16] x 1 - - LED x 1 - - Button x 1 - -:raw-html:`

` -**Example** -:raw-html:`

` - -In this example, we use a button to trigger interrupt and control the -LED. When we press and release the button, the LED dims, press and -release the button again, and the LED lights.Note that in the Arduino -example “Button and LED”, LED only lights when the button is pressed and -hold, when we release the button, the LED dims. - -Open the example, ``“Files” → “Examples” → “AmebaGPIO” → -“LED_InterruptCtrl”`` - -**AMB21 / AMB22** Wiring Diagram: - -.. image:: /media/ambd_arduino/GPIO_Use_GPIO_Interrupt_To_Control_LED/image1.png - :align: center - :width: 1335 - :height: 934 - :scale: 74 % - -**AMB23** Wiring Diagram: - -.. image:: /media/ambd_arduino/GPIO_Use_GPIO_Interrupt_To_Control_LED/image2.png - :align: center - :width: 831 - :height: 797 - :scale: 87 % - -**BW16** Wiring Diagram: - -.. image:: /media/ambd_arduino/GPIO_Use_GPIO_Interrupt_To_Control_LED/image2-2.png - :align: center - :width: 763 - :height: 777 - :scale: 90 % - -**BW16-TypeC** Wiring Diagram: - -.. image:: /media/ambd_arduino/GPIO_Use_GPIO_Interrupt_To_Control_LED/image2-3.png - :align: center - :width: 668 - :height: 665 - -| Compile and upload the program, press reset. -| The LED lights at first. Press and release the button, then the LED - should dim. Press again, then the LED should light. - -:raw-html:`

` -**Code Reference** -:raw-html:`

` - -In - -.. code-block:: c - - setup() - -we set Pin 12 to - -.. code-block:: c - - INPUT_IRQ_RISE - -, this means that an interrupt occurs when the voltage of this pin -changes from GND to 3V3. Therefore, we connect the other side of the -button to 3V3, so as to trigger interrupt event when the button is -pressed. - -.. code-block:: c - - pinMode(button, INPUT_IRQ_RISE); - -On the other hand, we can set pin 12 to - -.. code-block:: c - - INPUT_IRQ_FALL - -, this means that an interrupt occurs when the voltage of this pin -changes from 3V3 to GND. In this case, the other side of the button is -connected to GND.Next, we need to specify the funtion to be execute to -handle the interrupt: - -.. code-block:: c - - digitalSetIrqHandler(button, button_handler); - -The second parameter is a function pointer, with prototype: - -.. code-block:: c - - void button_handler(uint32_t id, uint32_t event) - -In this handler, every time we press and release the button, we trigger -an interrupt, and change the status of the LED. - diff --git a/bak/pro2/Example_Guides/Debugging/Debugging - Using the Debug Interface.rst b/bak/pro2/Example_Guides/Debugging/Debugging - Using the Debug Interface.rst deleted file mode 100644 index 7a8b105..0000000 --- a/bak/pro2/Example_Guides/Debugging/Debugging - Using the Debug Interface.rst +++ /dev/null @@ -1,115 +0,0 @@ -Preparation - -- AMB82-Mini x 1 - -- SEGGER debug probe x 1 - -Example - -Using the debugging feature available in the Arduino 2.0 IDE to debug -your board. In this example, we will use SEGGER’s debug probe with -Arduino IDE’s debug interface. Begin by installing the SEGGER debugging -software. This can be found on SEGGER’s official website: -https://www.segger.com/downloads/jlink/. - -Before debugging, ensure that the code is optimized for debugging. -Enable it by navigating to Sketch -> Optimize for Debugging. - -|image1| - -Open the Debug example, “File” -> “Examples” -> “Debugging” -> -“ExampleDebug” - -|image2| - -Two files will open in the IDE; ExampleDebug.ino and debug_custom.json. -Click on debug_custom.json. Under “serverArgs”, insert the directory -path to Arduino15 folder, as well as the current version number of the -tools folder. - -|image3| - -Connect the JLink Debug Probe and AMB82 Mini board to the computer. -Refer to the table below for the wiring connection between JLink Debug -Probe and AMB82 Mini board. For more information, please refer to: -https://www.segger.com/products/debug-probes/j-link/technology/interface-description/ - -+-----------------------------------+-----------------------------------+ -| **JLink Debug Probe** | **AMB82 Mini Board** | -+===================================+===================================+ -| VTref | 3.3V | -+-----------------------------------+-----------------------------------+ -| GND | GND | -+-----------------------------------+-----------------------------------+ -| SWDIO | SWDIO | -+-----------------------------------+-----------------------------------+ -| SWCLK | SWCLK | -+-----------------------------------+-----------------------------------+ - -|image4| |image5| - -[STRIKEOUT:Note that, VTref (Pin 1) is indicate by the blue/red wire on -the cable depending on the JLink Debug Probe that you are using.] - -AMB82 Mini boards have 4 hardware breakpoints. Hardware breakpoints can -be set at the left of the code and are indicated by a red dot shown in -line 42. Setting more than 4 hardware breakpoints will cause debugging -to fail. You will need to stop debugging and reset if this happens. - -If 4 hardware breakpoint is not enough, software breakpoint can be used. -Either of the instructions (\__BKPT() or \__asm\_\_("BKPT")) can be used -to add a software breakpoint in the program execution. - -|image6| - -Upload the code and press the reset button on Ameba once the upload is -finished. - -Once uploading is completed, reset the board. Start debugging by -selecting the Debug button. This is located to the right of the upload -button. Arduino will proceed with opening a gdb-server tab in the same -window as the output window if all connections were connected correctly -between JLink and board. This can sometimes take up to 10 seconds to set -up. - -|image7| - -The line highlighted in yellow indicates which line of code the program -is currently halted at. Debug console will appear to show the debugging -information. - -|image8| - -To continue running the code after the breakpoint, use any of the -single-stepping functions highlighted in the red box (continue, step -over, step into, step out, restart, stop). - -|image9| - -.. |image1| image:: ../../_static/Example_Guides/Debugging_-_Using_the_Debug_Interface/Debugging_-_Using_the_Debug_Interface_images/image01.png - :width: 5.93023in - :height: 2.54068in -.. |image2| image:: ../../_static/Example_Guides/Debugging_-_Using_the_Debug_Interface/Debugging_-_Using_the_Debug_Interface_images/image02.png - :width: 5.71875in - :height: 4.7006in -.. |image3| image:: ../../_static/Example_Guides/Debugging_-_Using_the_Debug_Interface/Debugging_-_Using_the_Debug_Interface_images/image03.png - :width: 6.25in - :height: 1.57292in -.. |image4| image:: ../../_static/Example_Guides/Debugging_-_Using_the_Debug_Interface/Debugging_-_Using_the_Debug_Interface_images/image04.png - :width: 2.02326in - :height: 2.5703in -.. |image5| image:: ../../_static/Example_Guides/Debugging_-_Using_the_Debug_Interface/Debugging_-_Using_the_Debug_Interface_images/image5.jpeg - :width: 3.18657in - :height: 2.39178in -.. |image6| image:: ../../_static/Example_Guides/Debugging_-_Using_the_Debug_Interface/Debugging_-_Using_the_Debug_Interface_images/image06.png - :width: 6.26389in - :height: 4.11111in -.. |image7| image:: ../../_static/Example_Guides/Debugging_-_Using_the_Debug_Interface/Debugging_-_Using_the_Debug_Interface_images/image07.png - :width: 5.74799in - :height: 3.25in -.. |image8| image:: ../../_static/Example_Guides/Debugging_-_Using_the_Debug_Interface/Debugging_-_Using_the_Debug_Interface_images/image08.png - :width: 6.25694in - :height: 3.33333in -.. |image9| image:: ../../_static/Example_Guides/Debugging_-_Using_the_Debug_Interface/Debugging_-_Using_the_Debug_Interface_images/image09.png - :width: 5.34328in - :height: 3.96943in diff --git a/bak/pro2/Example_Guides/index.rst b/bak/pro2/Example_Guides/index.rst deleted file mode 100644 index c8d3b85..0000000 --- a/bak/pro2/Example_Guides/index.rst +++ /dev/null @@ -1,27 +0,0 @@ -Example Guides -============== - -.. toctree:: - :maxdepth: 2 - - BLE/index - Debugging/index - E-Paper/index - File System/index - Flash Memory/index - GPIO/index - GTimer/index - HTTP/index - I2C/index - MQTT/index - Multimedia/index - Neural Network/index - NTP/index - PowerMode/index - PWM/index - QR Code Scanner/index - RTC/index - SPI/index - USB/index - Watchdog/index - WiFi/index diff --git a/source/_common/ameba_d/API_Documents/RTC/Class RTCClass.rst b/source/_common/ameba_d/API_Documents/RTC/Class RTCClass.rst new file mode 100644 index 0000000..d8c8a18 --- /dev/null +++ b/source/_common/ameba_d/API_Documents/RTC/Class RTCClass.rst @@ -0,0 +1,265 @@ +Class RTC +========= + +.. contents:: + :local: + :depth: 2 + +**RTCClass Class** +------------------ + +**Description** +~~~~~~~~~~~~~~~ + +A class used for displaying date and time. It is also used for alarm configuration using RTC (Real Time Clock), the independent BCD (Binary-Coded-Decimal) timer. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + class RTC + +**Members** +~~~~~~~~~~~ + ++-----------------------------------+-----------------------------------+ +| **Public Constructors** | ++===================================+===================================+ +| A public constructor should not be used as this class is intended | +| to be a singleton class. Access member functions using the | +| object instance named RTC. | ++-----------------------------------+-----------------------------------+ +| **Public Methods** | ++-----------------------------------+-----------------------------------+ +| RTC::Init | Initializes the RTC device, | +| | include clock, RTC registers and | +| | function. | ++-----------------------------------+-----------------------------------+ +| RTC::DeInit | Deinitializes the RTC device. | ++-----------------------------------+-----------------------------------+ +| RTC::Write | Set the specified timestamp in | +| | seconds to RTC. | ++-----------------------------------+-----------------------------------+ +| RTC::Read | Get current timestamp in seconds | +| | from RTC. | ++-----------------------------------+-----------------------------------+ +| RTC::Wait | Wait for 1 second (1,000,000 us) | ++-----------------------------------+-----------------------------------+ +| RTC::SetEpoch | Convert human readable time to | +| | epoch time. | ++-----------------------------------+-----------------------------------+ + +----------------------------------------- + +**RTC::Init** +------------------ + +**Description** +~~~~~~~~~~~~~~~ + +Initialize the RTC device, including the RTC clock source, the RTC registers, and RTC peripheral with corresponding configurations. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + void Init(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `RTC `_ + +.. note :: "rtc.h" must be included to use the class function. + +------------------------------------ + +**RTC::DeInit** +-------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Deinitialize the RTC device by disable RTC flag and disable the RTC alarm. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + void DeInit(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `RTC `_ + +.. note :: "rtc.h" must be included to use the class function. + +------------------------------------ + +**RTC::Write** +------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Set the specified timestamp (in s) to RTC. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + void Write(int t); + +**Parameters** +~~~~~~~~~~~~~~ + +``t``: seconds from 1970-01-01 00:00:00 (YEAR.MONTH.DAY, HOUR: MIN: SECONDS) to specified date and time which is to be set. + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `RTC `_ + +.. note :: "rtc.h" must be included to use the class function. + +------------------------------------ + +**RTC::Read** +------------------ + +**Description** +~~~~~~~~~~~~~~~ + +Get the current timestamp in seconds from RTC. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + int32_t Read(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +This function returns the current timestamp in seconds which is calculated from 1970.1.1 00:00:00 (YEAR.MONTH.DAY, HOUR: MIN: SECONDS). + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `RTC `_ + +.. note :: "rtc.h" must be included to use the class function. + +------------------------------------ + +**RTC::Wait** +------------------ + +**Description** +~~~~~~~~~~~~~~~ + +Wait for 1s/1000000 us. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + void wait (float s); + +**Parameters** +~~~~~~~~~~~~~~ + +``s``: delay time in seconds. + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `RTC `_ + +.. note :: "rtc.h" must be included to use the class function. + +------------------------------------ + +**RTC::SetEpoch** +---------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Convert human-readable time to epoch time. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + int SetEpoch (int year, int month, int day, int hour, int min, int sec); + +**Parameters** +~~~~~~~~~~~~~~ + +``year``: user input year (Default 4 digits year value - 1970) + +``month``: user input month (Acceptable value ranges from 0 - 11, 0 represents January) + +``day``: user input day of the month (Acceptable value ranges from 1-31) + +``hour``: user input hour (Acceptable value ranges from 0-23) + +``min``: user input minutes (Acceptable value ranges from 0-59) + +``sec``: user input seconds (Acceptable value ranges from 0-59 or 60 for leap seconds) + +**Returns** +~~~~~~~~~~~ + +This function returns epoch time in seconds for RTC use. + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `RTC `_ + +.. note :: "rtc.h" must be included to use the class function. diff --git a/bak/ambd/_common/API_Documents/RTC/index.rst b/source/_common/ameba_d/API_Documents/RTC/index.rst similarity index 100% rename from bak/ambd/_common/API_Documents/RTC/index.rst rename to source/_common/ameba_d/API_Documents/RTC/index.rst diff --git a/bak/ambd/_common/API_Documents/SPI/Class AmebaILI9341.rst b/source/_common/ameba_d/API_Documents/SPI/Class AmebaILI9341.rst similarity index 58% rename from bak/ambd/_common/API_Documents/SPI/Class AmebaILI9341.rst rename to source/_common/ameba_d/API_Documents/SPI/Class AmebaILI9341.rst index df46e43..752459d 100644 --- a/bak/ambd/_common/API_Documents/SPI/Class AmebaILI9341.rst +++ b/source/_common/ameba_d/API_Documents/SPI/Class AmebaILI9341.rst @@ -62,6 +62,9 @@ A class to use ILI9341 TFT SPI display driver on Ameba. | AmebaILI9341::drawCircle | Draw a circle shape and display on the | | | screen | +-------------------------------+-------------------------------------------+ +| AmebaILI9341::drawBitmap | Draw an image in bitmap format on the | +| | screen | ++-------------------------------+-------------------------------------------+ | AmebaILI9341::write | Display a character and display on the | | | screen | +-------------------------------+-------------------------------------------+ @@ -81,6 +84,8 @@ A class to use ILI9341 TFT SPI display driver on Ameba. | AmebaILI9341::reset | Reset the module | +-------------------------------+-------------------------------------------+ +------------------------------------------------- + **AmebaILI9341::AmebaILI9341** ------------------------------ @@ -99,11 +104,11 @@ The main class constructor when using AmebaILI9341 SPI display modules. **Parameters** ~~~~~~~~~~~~~~ -csPin: the Chip Select pin +``csPin``: the Chip Select pin in AmebaD development board -dcPin: the Data Command pin +``dcPin``: the Data Command pin in AmebaD development board -resetPin: the Reset pin +``resetPin``: the Reset pin in AmebaD development board **Returns** ~~~~~~~~~~~ @@ -113,10 +118,12 @@ NA **Example Code** ~~~~~~~~~~~~~~~~ -Example: `LCD_Screen_ILI9341_TFT `_ +Example: `ILI9341_TFT_LCD_PM2.5 `_ .. note :: "AmebaILI9341.h" must be included to use the class function. +------------------------------------------------- + **AmebaILI9341::begin** ----------------------- @@ -145,9 +152,13 @@ NA **Example Code** ~~~~~~~~~~~~~~~~ -Example: `LCD_Screen_ILI9341_TFT `_ +Example: `ILI9341_TFT_LCD_PM2.5 `_ + +.. important :: This method is required to run first before other operations on the display. + +.. note :: "AmebaILI9341.h" must be included to use the class function. -.. note :: "AmebaILI9341.h" must be included to use the class function. This method is required to run first before other operations on the display. +------------------------------------------------- **AmebaILI9341::setAddress** ---------------------------- @@ -167,13 +178,13 @@ Initialize image size and positioning on the display **Parameters** ~~~~~~~~~~~~~~ -x0: leftmost coordinate of the image +``x0``: leftmost coordinate of the image -y0: top coordinate of the image +``y0``: top coordinate of the image -x1: rightmost coordinate of the image +``x1``: rightmost coordinate of the image -y1: bottom coordinate of the image +``y1``: bottom coordinate of the image **Returns** ~~~~~~~~~~~ @@ -185,7 +196,11 @@ NA NA -.. note :: Do not use this to set the cursor, use "setCursor" method instead. "AmebaILI9341.h" must be included to use the class function. +.. Caution :: Do not use this to set the cursor, use "setCursor" method instead. + +.. note :: "AmebaILI9341.h" must be included to use the class function. + +------------------------------------------------- **AmebaILI9341::writecommand** ------------------------------ @@ -205,7 +220,7 @@ Write a SPI command to the hardware peripheral **Parameters** ~~~~~~~~~~~~~~ -command: SPI command in 8-bit +``command``: SPI command in 8-bit **Returns** ~~~~~~~~~~~ @@ -218,6 +233,8 @@ NA .. note :: "AmebaILI9341.h" must be included to use the class function. +------------------------------------------------- + **AmebaILI9341::writedata** --------------------------- @@ -236,7 +253,7 @@ Write a SPI data to the hardware peripheral **Parameters** ~~~~~~~~~~~~~~ -data: SPI data in 8-bit +``data``: SPI data in 8-bit **Returns** ~~~~~~~~~~~ @@ -248,7 +265,11 @@ NA NA -.. note :: Only use this method to write 1 byte at a time. "AmebaILI9341.h" must be included to use the class function. +.. important :: Only use this method to write 1 byte at a time. + +.. note :: "AmebaILI9341.h" must be included to use the class function. + +------------------------------------------------- **AmebaILI9341::setRotation** ----------------------------- @@ -268,7 +289,7 @@ Setting screen orientation, "0" for no rotation, "1" for 90 degrees rotation, "2 **Parameters** ~~~~~~~~~~~~~~ -m: select desired screen orientation, expressing it as an integer. Defualt value is "0". +``m``: select desired screen orientation, expressing it as an integer. Default value is "0". **Returns** ~~~~~~~~~~~ @@ -278,9 +299,13 @@ NA **Example Code** ~~~~~~~~~~~~~~~~ -Example: `LCD_Screen_ILI9341_TFT `_ +Example: `ILI9341_TFT_LCD_PM2.5 `_ + +.. important :: Although "0" for no rotation, "1" for 90 degrees rotation, "2" for 180 degrees rotation, "3" for 270 degrees rotation, if m is more than 3, for example, m = 4 : there will be no rotation, m = 5 : 90 degrees rotation and so on. + +.. note :: "AmebaILI9341.h" must be included to use the class function. -.. note :: Although "0" for no rotation, "1" for 90 degrees rotation, "2" for 180 degrees rotation, "3" for 270 degrees rotation, if m is more than 3, for example, m = 4 : there will be no rotation, m = 5 : 90 degrees rotation and so on. "AmebaILI9341.h" must be included to use the class function. +------------------------------------------------- **AmebaILI9341::fillScreen** ---------------------------- @@ -299,7 +324,8 @@ Fill the entire screen with a single color **Parameters** ~~~~~~~~~~~~~~ -color: a 16-bit color, color definition (RGB565) can be found in AmebaILI9341.h + +``color``: a 16-bit color, color definition (RGB565) can be found in AmebaILI9341.h **Returns** ~~~~~~~~~~~ @@ -311,7 +337,11 @@ NA NA -.. note :: Refer to "AmebaILI9341.h" for available colors. "AmebaILI9341.h" must be included to use the class function. +.. tip ::Refer to "AmebaILI9341.h" for available colors. + +.. note :: "AmebaILI9341.h" must be included to use the class function. + +------------------------------------------------- **AmebaILI9341::clr** --------------------- @@ -341,9 +371,15 @@ NA **Example Code** ~~~~~~~~~~~~~~~~ -Example: `LCD_Screen_ILI9341_TFT `_ +Example: `ILI9341_TFT_LCD_PM2.5 `_ + +.. important :: Background color can be changed by calling setBackground(). + +.. tip :: Refer to "AmebaILI9341.h" for available colors of setBackground() function input parameter. + +.. note :: "AmebaILI9341.h" must be included to use the class function. -.. note :: Background color can be changed by calling setBackground(). Refer to "AmebaILI9341.h" for available colors of setBackground() function input parameter. "AmebaILI9341.h" must be included to use the class function. +------------------------------------------------- **AmebaILI9341::fillRectangle** ------------------------------- @@ -363,15 +399,15 @@ Fill a rectangle shape with color and display on the screen. **Parameters** ~~~~~~~~~~~~~~ -x: leftmost coordinate of the rectangle shape +``x``: leftmost coordinate of the rectangle shape -y: top coordinate of the rectangle shape +``y``: top coordinate of the rectangle shape -w: width of the rectangle shape +``w``: width of the rectangle shape -h: height of the rectangle shape +``h``: height of the rectangle shape -color: the color of the rectangle shape +``color``: the color of the rectangle shape **Returns** ~~~~~~~~~~~ @@ -381,9 +417,13 @@ NA **Example Code** ~~~~~~~~~~~~~~~~ -Example: `LCD_Screen_ILI9341_TFT `_ +Example: `ILI9341_TFT_LCD_PM2.5 `_ -.. note :: Refer to "AmebaILI9341.h" for available colors. "AmebaILI9341.h" must be included to use the class function. +.. tip :: Refer to "AmebaILI9341.h" for available colors. + +.. note :: "AmebaILI9341.h" must be included to use the class function. + +------------------------------------------------- **AmebaILI9341::drawPixel** --------------------------- @@ -403,11 +443,11 @@ Draw a single pixel by coordinates on the screen. **Parameters** ~~~~~~~~~~~~~~ -x: leftmost coordinate of the pixel +``x``: leftmost coordinate of the pixel -y: top coordinate of the pixel +``y``: top coordinate of the pixel -color: the color of the pixel +``color``: the color of the pixel **Returns** ~~~~~~~~~~~ @@ -419,7 +459,11 @@ NA NA -.. note :: Refer to "AmebaILI9341.h" for available colors. "AmebaILI9341.h" must be included to use the class function. +.. tip :: Refer to "AmebaILI9341.h" for available colors. + +.. note :: "AmebaILI9341.h" must be included to use the class function. + +------------------------------------------------- **AmebaILI9341::drawChar** -------------------------- @@ -435,22 +479,25 @@ Draw a character in the frame buffer but does not refresh. .. code-block:: c++ void AmebaILI9341::drawChar(unsigned char c); - void AmebaILI9341::drawChar(int16_t x, int16_t y, unsigned char c, uint16_t _fontcolor, uint16_t _background, uint8_t _fontsize); + +.. code-block:: c++ + + void AmebaILI9341::drawChar(int16_t x, int16_t y, unsigned char c, uint16_t _fontcolor, uint16_t _background, uint8_t _fontsize) **Parameters** ~~~~~~~~~~~~~~ -x: leftmost coordinate of the character +``x``: leftmost coordinate of the character -y: top coordinate of the character +``y``: top coordinate of the character -c: a character +``c``: a character -_fontcolor: character font color +``_fontcolor``: character font color -_background: character background color +``_background``: character background color -_fontsize: character font size +``_fontsize``: character font size **Returns** ~~~~~~~~~~~ @@ -462,7 +509,13 @@ NA NA -.. note :: This method only stores the string of character in a buffer frame. The Print/Println method have to be called in order to display a string of character on the serial monitor. Refer to "AmebaILI9341.h" for available colors. "AmebaILI9341.h" must be included to use the class function. +.. important :: This method only stores the string of character in a buffer frame. The Print/Println method have to be called in order to display a string of character on the serial monitor. + +.. tip :: Refer to "AmebaILI9341.h" for available colors. + +.. note :: "AmebaILI9341.h" must be included to use the class function. + +------------------------------------------------- **AmebaILI9341::drawLine** -------------------------- @@ -478,20 +531,23 @@ Draw a line and display on the screen. .. code-block:: c++ void drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color); + +.. code-block:: c++ + void drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1); **Parameters** ~~~~~~~~~~~~~~ -x0: leftmost coordinate of the line +``x0``: leftmost coordinate of the line -y0: top coordinate of the line +``y0``: top coordinate of the line -x1: leftmost coordinate of the line +``x1``: leftmost coordinate of the line -y1: top coordinate of the line +``y1``: top coordinate of the line -color: the color of the line +``color``: the color of the line **Returns** ~~~~~~~~~~~ @@ -503,7 +559,11 @@ NA NA -.. note :: Refer to "AmebaILI9341.h" for available colors. "AmebaILI9341.h" must be included to use the class function. +.. tip :: Refer to "AmebaILI9341.h" for available colors. + +.. note :: "AmebaILI9341.h" must be included to use the class function. + +------------------------------------------------- **AmebaILI9341::drawRectangle** ------------------------------- @@ -519,20 +579,23 @@ Draw a rectangular shape and display on the screen. .. code-block:: c++ void drawRectangle(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color); + +.. code-block:: c++ + void drawRectangle(int16_t x, int16_t y, int16_t w, int16_t h); **Parameters** ~~~~~~~~~~~~~~ -x: leftmost coordinate of the rectangular shape +``x``: leftmost coordinate of the rectangular shape -y: top coordinate of the rectangular shape +``y``: top coordinate of the rectangular shape -w: width of the rectangular shape +``w``: width of the rectangular shape -h: height of the rectangular shape +``h``: height of the rectangular shape -color: the color of the rectangular shape outline +``color``: the color of the rectangular shape outline **Returns** ~~~~~~~~~~~ @@ -544,7 +607,11 @@ NA NA -.. note :: Refer to AmebaILI9341.h for available colors. "AmebaILI9341.h" must be included to use the class function. +.. tip :: Refer to "AmebaILI9341.h" for available colors. + +.. note :: "AmebaILI9341.h" must be included to use the class function. + +------------------------------------------------- **AmebaILI9341::drawCircle** ---------------------------- @@ -560,18 +627,21 @@ Draw a circle shape and display on the screen. .. code-block:: c++ void drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color); + +.. code-block:: c++ + void drawCircle(int16_t x0, int16_t y0, int16_t r); **Parameters** ~~~~~~~~~~~~~~ -x0: leftmost coordinate of the circle shape +``x0``: leftmost coordinate of the circle shape -y0: top coordinate of the circle shape +``y0``: top coordinate of the circle shape -r: radius of the circle shape +``r``: radius of the circle shape -color: the color of the circle shape outline +``color``: the color of the circle shape outline **Returns** ~~~~~~~~~~~ @@ -583,7 +653,55 @@ NA NA -.. note :: Refer to AmebaILI9341.h for available colors. "AmebaILI9341.h" must be included to use the class function. +.. tip :: Refer to "AmebaILI9341.h" for available colors. + +.. note :: "AmebaILI9341.h" must be included to use the class function. + +------------------------------------------------- + +**AmebaILI9341::drawBitmap** +---------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Draw an image in Bitmap format on the screen. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + void drawBitmap(int16_t x, int16_t y, int16_t w, int16_t h, const unsigned short *color); + +**Parameters** +~~~~~~~~~~~~~~ + +``x``: leftmost coordinate of the Bitmap image + +``y``: top coordinate of the Bitmap image + +``w``: width of the Bitmap image + +``h``: height of the Bitmap image + +``color``: the string name of the Bitmap image + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. important :: Please convert the original image to Bitmap and save as “AmebaLogo.h”. Last input parameter name should be same as the image name used in “AmebaLogo.h”. + +.. note :: "AmebaILI9341.h" must be included to use the class function. + +------------------------------------------------- **AmebaILI9341::write** ----------------------- @@ -603,7 +721,7 @@ Display a character and display on the screen. **Parameters** ~~~~~~~~~~~~~~ -c: a character to be written on the screen +``c``: a character to be written on the screen **Returns** ~~~~~~~~~~~ @@ -615,7 +733,11 @@ This function returns the number of bytes written. NA -.. note :: This an inherited method from Print class and is seldom used. "AmebaILI9341.h" must be included to use the class function. +.. important :: This an inherited method from Print class and is seldom used. + +.. note :: "AmebaILI9341.h" must be included to use the class function. + +------------------------------------------------- **AmebaILI9341::getWidth** -------------------------- @@ -649,6 +771,8 @@ NA .. note :: The width is defined in" AmebaILI9341.h". "AmebaILI9341.h" must be included to use the class function. +------------------------------------------------- + **AmebaILI9341::getHeight** --------------------------- @@ -681,6 +805,8 @@ NA .. note :: The height is defined in" AmebaILI9341.h". "AmebaILI9341.h" must be included to use the class function. +------------------------------------------------- + **AmebaILI9341::setCursor** --------------------------- @@ -699,9 +825,9 @@ Set the cursor to a specific position on the screen. **Parameters** ~~~~~~~~~~~~~~ -x: coordinate on the x-axis +``x``: coordinate on the x-axis -y: coordinate on the y-axis +``y``: coordinate on the y-axis **Returns** ~~~~~~~~~~~ @@ -711,10 +837,12 @@ NA **Example Code** ~~~~~~~~~~~~~~~~ -Example: `LCD_Screen_ILI9341_TFT `_ +Example: `ILI9341_TFT_LCD_PM2.5 `_ .. note :: "AmebaILI9341.h" must be included to use the class function. +------------------------------------------------- + **AmebaILI9341::setForeground** ------------------------------- @@ -733,7 +861,7 @@ Set foreground color. **Parameters** ~~~~~~~~~~~~~~ -color: desired colors for foreground +``color``: desired colors for foreground **Returns** ~~~~~~~~~~~ @@ -743,9 +871,13 @@ NA **Example Code** ~~~~~~~~~~~~~~~~ -Example: `LCD_Screen_ILI9341_TFT `_ +Example: `ILI9341_TFT_LCD_PM2.5 `_ + +.. tip :: testText() function, to set foreground colors for different font sizes. Refer to AmebaILI9341.h for available colors. -.. note :: testText() function, to set foreground colors for different font sizes. Refer to AmebaILI9341.h for available colors. "AmebaILI9341.h" must be included to use the class function. +.. note :: "AmebaILI9341.h" must be included to use the class function. + +------------------------------------------------- **AmebaILI9341::setBackground** ------------------------------- @@ -765,7 +897,7 @@ Set background color. **Parameters** ~~~~~~~~~~~~~~ -_background: desired background color +``_background``: desired background color **Returns** ~~~~~~~~~~~ @@ -775,9 +907,13 @@ NA **Example Code** ~~~~~~~~~~~~~~~~ -Example: `LCD_Screen_ILI9341_TFT `_ +Example: `ILI9341_TFT_LCD_PM2.5 `_ + +.. tip :: Refer to AmebaILI9341.h for available colors. -.. note :: Refer to AmebaILI9341.h for available colors. "AmebaILI9341.h" must be included to use the class function. +.. note :: "AmebaILI9341.h" must be included to use the class function. + +------------------------------------------------- **AmebaILI9341::setFontSize** ----------------------------- @@ -797,7 +933,7 @@ Set the font size of the characters to be printed on the screen. **Parameters** ~~~~~~~~~~~~~~ -size: desired font size. (Default values:1 to 5). Smaller value is indicating smaller font size. +``size``: desired font size. (Default values:1 to 5). Smaller value is indicating smaller font size. **Returns** ~~~~~~~~~~~ @@ -807,10 +943,12 @@ NA **Example Code** ~~~~~~~~~~~~~~~~ -Example: `LCD_Screen_ILI9341_TFT `_ +Example: `ILI9341_TFT_LCD_PM2.5 `_ .. note :: "AmebaILI9341.h" must be included to use the class function. +------------------------------------------------- + **AmebaILI9341::reset** ----------------------- diff --git a/bak/ambd/_common/API_Documents/SPI/Class SPISettings.rst b/source/_common/ameba_d/API_Documents/SPI/Class SPIClass.rst similarity index 64% rename from bak/ambd/_common/API_Documents/SPI/Class SPISettings.rst rename to source/_common/ameba_d/API_Documents/SPI/Class SPIClass.rst index d70bb4b..a23254c 100644 --- a/bak/ambd/_common/API_Documents/SPI/Class SPISettings.rst +++ b/source/_common/ameba_d/API_Documents/SPI/Class SPIClass.rst @@ -1,77 +1,10 @@ -Class SPISettings -================= +Class SPIClass +============== .. contents:: :local: :depth: 2 -**SPISettings Class** ---------------------- - -**Description** -~~~~~~~~~~~~~~~ - -A class to set SPI parameters. - -**Syntax** -~~~~~~~~~~ - -.. code-block:: c++ - - class SPISettings - -**Members** -~~~~~~~~~~~ - -+-------------------------------+--------------------------------------------------+ -| **Public Constructors** | -+===============================+==================================================+ -| SPISettings::SPISettings | Create a SPISettings object and set SPI clock | -| | speed, bit order and data mode | -+-------------------------------+--------------------------------------------------+ - -**SPISettings::SPISettings** ----------------------------- - -**Description** -~~~~~~~~~~~~~~~ - -Construct an object and configure SPI parameters — clock speed, bit order and data mode to the preferred default value. - -**Syntax** -~~~~~~~~~~ - -.. code-block:: c++ - - SPISettings(uint32_t clock, BitOrder bitOrder, uint8_t dataMode) - -**Parameters** -~~~~~~~~~~~~~~ - -clock: SPI clock speed in Hz. Default value is 4000000. - -bitOrder: The bit order of transmitting command/address/data. Default value is MSBFIRST. - -- MSBFIRST (MSB: Most Significant Bit) - -- LSBFIRST (LSB: Least Significant Bit) - -dataMode: SPI has four modes that correspond to the four possible clocking configurations. Default value is SPI_MODE0. - -- SPI_MODE0, SPI_MODE1, SPI_MODE2, SPI_MODE3 - -**Returns** -~~~~~~~~~~~ - -NA - -**Example Code** -~~~~~~~~~~~~~~~~ - -NA - -.. note :: This class seldom used alone, it is always used with beginTransaction() as a parameter in SPIClass. "SPI.h" must be included to use the class function. - **SPIClass Class** ------------------ @@ -121,13 +54,15 @@ A class of SPI implementation for Ameba. | SPIClass::end | Stop SPI master mode | +---------------------------------+------------------------------------------+ +--------------------------------------- + **SPIClass::SPIClass** ---------------------- **Description** ~~~~~~~~~~~~~~~ -Construct an SPI object, create a pointer to the SPI master object, and assign "MOSI, MISO, CLK, and SS" to the corresponding pins on Ameba boards. Default SPI tranmission frequency is set to 20,000,000 Hz. +Construct an SPI object, create a pointer to the SPI master object, and assign "MOSI, MISO, CLK, and SS" to the corresponding pins on Ameba boards. Default SPI transmission frequency is set to 20,000,000 Hz. **Syntax** ~~~~~~~~~~ @@ -139,15 +74,15 @@ Construct an SPI object, create a pointer to the SPI master object, and assign " **Parameters** ~~~~~~~~~~~~~~ -pSpiObj: A pointer to a structure that stores SPI configuration. +``pSpiObj``: A pointer to a structure that stores SPI configuration. -mosi: Master Out, Slave In, a.k.a. Data transmission from a Host to Device. +``mosi``: Master Out, Slave In, a.k.a. Data transmission from a Host to Device. -miso: Master In, Slave Out, a.k.a. Data transmission from a Device to Host. +``miso``: Master In, Slave Out, a.k.a. Data transmission from a Device to Host. -clk: Serial Clock. Oscillating signal generated by a Host that keeps the transmission of data bits in sync. +``clk``: Serial Clock. Oscillating signal generated by a Host that keeps the transmission of data bits in sync. -ss: Slave Select. Allows a Host to select individual Device(s) connected to the bus in order to send or receive data. +``ss``: Slave Select. Allows a Host to select individual Device(s) connected to the bus in order to send or receive data. **Returns** ~~~~~~~~~~~ @@ -157,10 +92,12 @@ NA **Example Code** ~~~~~~~~~~~~~~~~ -Example: `LCD_Screen_ILI9341_TFT `_ +Example: `ILI9341_TFT_LCD_PM2.5 `_ .. note :: Depending on the Ameba hardware, up to 2 SPIClass objects are created in the spi.cpp library, please use "SPI" for first hardware SPI object and "SPI1" for the second. "SPI.h" must be included to use the class function. +--------------------------------------- + **SPIClass::begin** ------------------- @@ -175,12 +112,25 @@ Initialize MOSI, MISO, CLK, and SS pins on Ameba boards, select SPIClass object, .. code-block:: c++ void begin(void); + +.. code-block:: c++ + void begin(int ss); +.. code-block:: c++ + + void begin(char mode); + +.. code-block:: c++ + + void begin(int ss, char mode); + **Parameters** ~~~~~~~~~~~~~~ -ss: Slave Select. Allows a Host to select individual Device(s) connected to the bus in order to send or receive data. +``ss``: Slave Select. Allows a Host to select individual Device(s) connected to the bus in order to send or receive data. + +``mode``: Select SPI mode between “master” or 'slave' mode. The input should be char 'M' / 'S' or SPI_MODE_MASTER / SPI_MODE_SLAVE. **Returns** ~~~~~~~~~~~ @@ -194,6 +144,8 @@ NA .. note :: This is a required method to use SPI on Ameba. "SPI.h" must be included to use the class function. +--------------------------------------- + **SPIClass::transfer** ---------------------- @@ -208,22 +160,31 @@ Transfer data through SPI to the slave. .. code-block:: c++ byte transfer(byte _pin, uint8_t _data, SPITransferMode _mode = SPI_LAST); + +.. code-block:: c++ + byte transfer(uint8_t _data, SPITransferMode _mode = SPI_LAST); + +.. code-block:: c++ + void transfer(byte _pin, void *_buf, size_t _count, SPITransferMode _mode = SPI_LAST); + +.. code-block:: c++ + void transfer(void *_buf, size_t _count, SPITransferMode _mode = SPI_LAST); **Parameters** ~~~~~~~~~~~~~~ -_pin: Slave Select pin +``_pin``: Slave Select pin -_data: Data of 8-bits that transfer from SPI master to the slave +``_data``: Data of 8-bits that transfer from SPI master to the slave -_buf: Data buffer stores data to be written to Tx FIFO +``_buf``: Data buffer stores data to be written to Tx FIFO -_mode: defines SS pin status after data transmission is finished, available values are SPI_CONTINUE and SPI_LAST. SPI_LAST indicates SS pin will be set to 1 upon data transmission ends. +``_mode``: defines SS pin status after data transmission is finished, available values are SPI_CONTINUE and SPI_LAST. SPI_LAST indicates SS pin will be set to 1 upon data transmission ends. -_count: number of data bytes to be send +``_count``: number of data bytes to be send **Returns** ~~~~~~~~~~~ @@ -237,6 +198,8 @@ NA .. note :: "SPI.h" must be included to use the class function. +--------------------------------------- + **SPIClass::transfer16** ------------------------ @@ -251,16 +214,19 @@ Transfer data of 16-bits through SPI master to the slave. .. code-block:: c++ uint16_t transfer16(byte _pin, uint16_t _data, SPITransferMode _mode = SPI_LAST); + +.. code-block:: c++ + uint16_t transfer16(uint16_t _data, SPITransferMode _mode = SPI_LAST); **Parameters** ~~~~~~~~~~~~~~ -_pin: Slave Select pin +``_pin``: Slave Select pin -_data: Data of 16-bits that transfer from SPI master to the slave +``_data``: Data of 16-bits that transfer from SPI master to the slave -_mode: defines SS pin status after data transmission is finished, available values are SPI_CONTINUE and SPI_LAST. SPI_LAST indicates SS pin will be set to 1 upon data transmission ends. +``_mode``: defines SS pin status after data transmission is finished, available values are SPI_CONTINUE and SPI_LAST. SPI_LAST indicates SS pin will be set to 1 upon data transmission ends. **Returns** ~~~~~~~~~~~ @@ -274,6 +240,8 @@ NA .. note :: "SPI.h" must be included to use the class function. +--------------------------------------- + **SPIClass::beginTransaction** ------------------------------ @@ -288,14 +256,17 @@ Set Slave Select pin and initialize SPI with default settings including SPI form .. code-block:: c++ void beginTransaction(uint8_t pin, SPISettings settings); + +.. code-block:: c++ + void beginTransaction(SPISettings settings); **Parameters** ~~~~~~~~~~~~~~ -pin: Slave Select pin +``pin``: Slave Select pin -settings: an object of SPISettings class defined previously +``settings``: an object of SPISettings class defined previously **Returns** ~~~~~~~~~~~ @@ -307,7 +278,11 @@ NA NA -.. note :: Refer to SPISettings class for details of the initial settings. "SPI.h" must be included to use the class function. +.. tip :: Refer to SPISettings class for details of the initial settings. + +.. note :: "SPI.h" must be included to use the class function. + +--------------------------------------- **SPIClass::endTransaction** ---------------------------- @@ -341,6 +316,8 @@ NA .. note :: "SPI.h" must be included to use the class function. +--------------------------------------- + **SPIClass::setBitOrder** ------------------------- @@ -355,20 +332,23 @@ Set bit order to either MSB first or LSB first and set slave select pin. .. code-block:: c++ void setBitOrder(uint8_t _pin, BitOrder _bitOrder); + +.. code-block:: c++ + void setBitOrder(BitOrder _order); **Parameters** ~~~~~~~~~~~~~~ -_pin: slave select +``_pin``: slave select -_bitOrder: The bit order of transmitting command/address/data. Default value is MSBFIRST. +``_bitOrder``: The bit order of transmitting command/address/data. Default value is MSBFIRST. -- MSBFIRST (MSB: Most Significant Bit) +- ``MSBFIRST`` (MSB: Most Significant Bit) -- LSBFIRST (LSB: Least Significant Bit) +- ``LSBFIRST`` (LSB: Least Significant Bit) -_order: same as _bitOrder. Default value is MSBFIRST. +``_order``: same as _bitOrder. Default value is MSBFIRST. **Returns** ~~~~~~~~~~~ @@ -382,6 +362,8 @@ NA .. note :: "SPI.h" must be included to use the class function. +--------------------------------------- + **SPIClass::setDataMode** ------------------------- @@ -396,6 +378,9 @@ Set SPI data mode. A total of 4 modes and set slave select pin. .. code-block:: c++ void SPIClass::setDataMode(uint8_t _pin, uint8_t _mode); + +.. code-block:: c++ + void SPIClass::setDataMode(uint8_t _mode); **Parameters** @@ -419,6 +404,8 @@ NA .. note :: "SPI.h" must be included to use the class function. +--------------------------------------- + **SPIClass::setClockDivider** ----------------------------- @@ -433,16 +420,19 @@ Set clock divider in order to get correct clock speed. .. code-block:: c++ void setClockDivider(uint8_t _pin, uint8_t _divider); + +.. code-block:: c++ + void setClockDivider(uint8_t _div); **Parameters** ~~~~~~~~~~~~~~ -_pin: Slave Select pin +``_pin``: Slave Select pin -_divider: clock divider +``_divider``: clock divider -_div: clock divider +``_div``: clock divider **Returns** ~~~~~~~~~~~ @@ -456,6 +446,8 @@ NA .. note :: This function does not affect the Ameba board. "SPI.h" must be included to use the class function. +--------------------------------------- + **SPIClass::setDefaultFrequency** --------------------------------- @@ -474,7 +466,7 @@ Set default SPI frequency. **Parameters** ~~~~~~~~~~~~~~ -_frequency: the default SPI frequency in Hz. Default value is 20000000. +``_frequency``: the default SPI frequency in Hz. Default value is 20000000. **Returns** ~~~~~~~~~~~ @@ -484,9 +476,13 @@ NA **Example Code** ~~~~~~~~~~~~~~~~ -Example: `LCD_Screen_ILI9341_TFT `_ +Example: `ILI9341_TFT_LCD_PM2.5 `_ + +.. important :: Take note that defaultFrequency = _frequency. -.. note :: Take note that defaultFrequency = _frequency. "SPI.h" must be included to use the class function. +.. note :: "SPI.h" must be included to use the class function. + +--------------------------------------- **SPIClass::end** ----------------- @@ -518,4 +514,6 @@ NA NA -.. note :: After calling end(), you need to use begin() again to enable SPI function. "SPI.h" must be included to use the class function. +.. important :: After calling end(), you need to use begin() again to enable SPI function. + +.. note :: "SPI.h" must be included to use the class function. diff --git a/source/_common/ameba_d/API_Documents/SPI/Class SPISettings.rst b/source/_common/ameba_d/API_Documents/SPI/Class SPISettings.rst new file mode 100644 index 0000000..d688686 --- /dev/null +++ b/source/_common/ameba_d/API_Documents/SPI/Class SPISettings.rst @@ -0,0 +1,77 @@ +Class SPISettings +================= + +.. contents:: + :local: + :depth: 2 + +**SPISettings Class** +--------------------- + +**Description** +~~~~~~~~~~~~~~~ + +A class to set SPI parameters. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + class SPISettings + +**Members** +~~~~~~~~~~~ + ++-------------------------------+--------------------------------------------------+ +| **Public Constructors** | ++===============================+==================================================+ +| SPISettings::SPISettings | Create a SPISettings object and set SPI clock | +| | speed, bit order and data mode | ++-------------------------------+--------------------------------------------------+ + +----------------------------------------------------------- + +**SPISettings::SPISettings** +---------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Construct an object and configure SPI parameters — clock speed, bit order and data mode to the preferred default value. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + SPISettings(uint32_t clock, BitOrder bitOrder, uint8_t dataMode) + +**Parameters** +~~~~~~~~~~~~~~ + +``clock``: SPI clock speed in Hz. Default value is 4000000. + +``bitOrder``: The bit order of transmitting command/address/data. Default value is MSBFIRST. + + - MSBFIRST (MSB: Most Significant Bit) + + - LSBFIRST (LSB: Least Significant Bit) + +``dataMode``: SPI has four modes that correspond to the four possible clocking configurations. Default value is SPI_MODE0. + + - SPI_MODE0, SPI_MODE1, SPI_MODE2, SPI_MODE3 + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. important :: This class seldom used alone, it is always used with beginTransaction() as a parameter in SPIClass. + +.. note :: "SPI.h" must be included to use the class function. diff --git a/bak/ambd/_common/API_Documents/SPI/index.rst b/source/_common/ameba_d/API_Documents/SPI/index.rst similarity index 75% rename from bak/ambd/_common/API_Documents/SPI/index.rst rename to source/_common/ameba_d/API_Documents/SPI/index.rst index 8c87147..954c199 100644 --- a/bak/ambd/_common/API_Documents/SPI/index.rst +++ b/source/_common/ameba_d/API_Documents/SPI/index.rst @@ -5,4 +5,5 @@ SPI :maxdepth: 1 Class AmebaILI9341 + Class SPIClass Class SPISettings diff --git a/source/_common/ameba_d/API_Documents/SoftwareSerial/Class Adafruit_GPS.rst b/source/_common/ameba_d/API_Documents/SoftwareSerial/Class Adafruit_GPS.rst new file mode 100644 index 0000000..12bb3df --- /dev/null +++ b/source/_common/ameba_d/API_Documents/SoftwareSerial/Class Adafruit_GPS.rst @@ -0,0 +1,608 @@ +Class Adafruit_GPS +================== + +.. contents:: + :local: + :depth: 2 + +**Adafruit_GPS Class** +---------------------- + +**Description** +~~~~~~~~~~~~~~~ + +A class used to configure GPS module settings on Ameba. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + class Adafruit_GPS + +**Members** +~~~~~~~~~~~ + ++---------------------------------+-----------------------------------+ +| **Public Constructors** | ++=================================+===================================+ +| Adafruit_GPS::Adafruit_GPS | Constructs an Adafruit_GPS object | ++---------------------------------+-----------------------------------+ +| **Public Methods** | ++---------------------------------+-----------------------------------+ +| Adafruit_GPS::begin | Initialize serial communication | ++---------------------------------+-----------------------------------+ +| \*Adafruit_GPS:: lastNMEA | Get the last National Marine | +| | Electronics Association (NMEA) | +| | line received and set the | +| | received flag to false | ++---------------------------------+-----------------------------------+ +| Adafruit_GPS:: newNMEAreceived | Check to see if a new NMEA line | +| | has been received | ++---------------------------------+-----------------------------------+ +| Adafruit_GPS:: common_init | Initialization code used by all | +| | constructor types | ++---------------------------------+-----------------------------------+ +| Adafruit_GPS:: sendCommand | Send a command to the GPS device | ++---------------------------------+-----------------------------------+ +| Adafruit_GPS:: pause | Pause/resume receiving new data | ++---------------------------------+-----------------------------------+ +| Adafruit_GPS:: parseHex | Read a Hex value and convert into | +| | decimal value | ++---------------------------------+-----------------------------------+ +| Adafruit_GPS:: read | Read one character from the GPS | +| | device | ++---------------------------------+-----------------------------------+ +| Adafruit_GPS:: parse | Parse data such as latitude, | +| | longitude, speed, angle, etc | ++---------------------------------+-----------------------------------+ +| Adafruit_GPS:: wakeup | Wake the sensor up | ++---------------------------------+-----------------------------------+ +| Adafruit_GPS:: standby | Standby Mode Switches | ++---------------------------------+-----------------------------------+ +| Adafruit_GPS::waitForSentence | Wait for a specified sentence | +| | from the device | ++---------------------------------+-----------------------------------+ +| Adafruit_GPS::LOCUS_StartLogger | Start the LOCUS logger | ++---------------------------------+-----------------------------------+ +| Adafruit_GPS::LOCUS_StopLogger | Stop the LOCUS logger | ++---------------------------------+-----------------------------------+ +| Adafruit_GPS::LOCUS_ReadStatus | Read the logger status | ++---------------------------------+-----------------------------------+ + +-------------------------------------------------------------------------------------- + +**Adafruit_GPS::Adafruit_GPS** +------------------------------ + +**Description** +~~~~~~~~~~~~~~~ + +Constructs an Adafruit_GPS object and initialize serial using a SoftSerial object. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + Adafruit_GPS(SoftwareSerial *ser); + +.. code:: c++ + + Adafruit_GPS(HardwareSerial *ser); + +**Parameters** +~~~~~~~~~~~~~~ + +``ser``: a Serial instance + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `Adafruit_GPS_parsing `_ + +.. note :: important: SoftSerial is using hardware serial so pin mapping cannot be altered. + +.. note :: “Adafruit_GPS.h” must be included to use the class function. + +------------------------------------------------------------------------------------------------------------- + +**Adafruit_GPS::begin** +----------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Initialize baud rate for gps serial communication. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + void begin(uint16_t baud); + +**Parameters** + +``baud``: gps serial baud rate + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `Adafruit_GPS_parsing `_ + +.. note :: “Adafruit_GPS.h” must be included to use the class function. + +----------------------------------------------------------------------------------------------------------- + +**Adafruit_GPS::lastNMEA** +-------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Get the last National Marine Electronics Association (NMEA) line received and set the received flag to false. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + char *lastNMEA(void); + +**Parameters** + +NA + +**Returns** +~~~~~~~~~~~ + +This function returns a pointer to the last line of the string. + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `Adafruit_GPS_parsing `_ + +.. note :: “Adafruit_GPS.h” must be included to use the class function. + +------------------------------------------------------------------------------------------------------------ + +**Adafruit_GPS::newNMEAreceived** +--------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Check if a new NMEA line has been received. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + boolean newNMEAreceived(void); + +**Parameters** + +NA + +**Returns** +~~~~~~~~~~~ + +This function returns "true” if a new NMEA line has been received. Otherwise, returns “false”. + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `Adafruit_GPS_parsing `_ + +.. note :: “Adafruit_GPS.h” must be included to use the class function. + +------------------------------------------------------------------------------------------------------------ + +**Adafruit_GPS::common_init** +----------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Initialization code used by all constructor types. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void common_init(void); + +**Parameters** + +NA + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “Adafruit_GPS.h” must be included to use the class function. + +------------------------------------------------------------------------------------------------------------ + +**Adafruit_GPS::sendCommand** +----------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Send a command to the GPS device via GPS serial communication. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void sendCommand(const char *str); + +**Parameters** + +``str``: Pointer to a string holding the command to send + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `Adafruit_GPS_parsing `_ + +.. note :: “Adafruit_GPS.h” must be included to use the class function. + +--------------------------------------------------------------------------------------------------------------- + +**Adafruit_GPS::pause** +----------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Pause/ resume receiving new data. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void pause (boolean p); + +**Parameters** + +``p``: True = pause, false = resume + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “Adafruit_GPS.h” must be included to use the class function. + +--------------------------------------------------------------------------------------------------------------- + +**Adafruit_GPS::parseHex** +-------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Read a Hexadecimal value and convert into a decimal value. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + uint8_t parseHex (char c); + +**Parameters** + +``c``: Hexadecimal value + +**Returns** +~~~~~~~~~~~ + +This function returns the decimal equivalent of the Hexadecimal value. + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “Adafruit_GPS.h” must be included to use the class function. + +-------------------------------------------------------------------------------------------------------------- + +**Adafruit_GPS::read** +---------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Read one character from the GPS device. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + char read(void); + +**Parameters** + +NA + +**Returns** +~~~~~~~~~~~ + +The function returns the character that we received or returns 0 if nothing was received. + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `Adafruit_GPS_parsing `_ + +.. note :: “Adafruit_GPS.h” must be included to use the class function. + +------------------------------------------------------------------------------------------------------------------ + +**Adafruit_GPS::parse** +----------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Parse data such as latitude, longitude, speed, angle, etc. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + boolean parse(char *nmea) + +**Parameters** + +``nmea``: an NMEA string + +**Returns** +~~~~~~~~~~~ + +This function returns “true” if there are valid data to be parsed, “false” if it has invalid data. + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `Adafruit_GPS_parsing `_ + +.. note :: “Adafruit_GPS.h” must be included to use the class function. + +---------------------------------------------------------------------------------------------------------------------- + +**Adafruit_GPS::wakeup** +------------------------ + +**Description** +~~~~~~~~~~~~~~~ + +Wake the sensor by disabling the GPD sensor stand by ode. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + boolean wakeup(void); + +**Parameters** + +NA + +**Returns** +~~~~~~~~~~~ + +This function returns “true” if the sensor is awake, otherwise return “false” if the sensor is not on standby or failed to wake. + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “Adafruit_GPS.h” must be included to use the class function. + +------------------------------------------------------------------------------------------------------------------------ + +**Adafruit_GPS::standby** +------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Standby mode switches. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + boolean standby (void); + +**Parameters** + +NA + +**Returns** +~~~~~~~~~~~ + +This function returns “false” if it is already in standby mode so that no commands need to be sent to the GPS to wake it up. Otherwise, returns “true” if it entered standby mode. + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “Adafruit_GPS.h” must be included to use the class function. + +-------------------------------------------------------------------------------------------------------------------------- + +**Adafruit_GPS::waitForSentence** +--------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Wait for a specified NEMA sentence from the device. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + boolean waitForSentence (const char *wait4me, uint8_t max) + +**Parameters** + +``wait4me``: Pointer to a string holding the desired response + +``max``: maximum duration to wait for the sentence, default value: 5 + +**Returns** +~~~~~~~~~~~ + +This function returns “true” if we the sentence is received, otherwise returns “false”. + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “Adafruit_GPS.h” must be included to use the class function. + +-------------------------------------------------------------------------------------------------------------------------- + +**Adafruit_GPS::LOCUS_StartLogger** +----------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Start the LOCUS logger. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + boolean LOCUS_StartLogger(void); + +**Parameters** + +NA + +**Returns** +~~~~~~~~~~~ + +This function returns “true” if the logger starts successfully. Otherwise, returns “false”. + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “Adafruit_GPS.h” must be included to use the class function. + +-------------------------------------------------------------------------------------------------------------------------- + +**Adafruit_GPS::LOCUS_StopLogger** +---------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Stop the LOCUS logger. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + boolean LOCUS_StopLogger(void); + +**Parameters** + +NA + +**Returns** +~~~~~~~~~~~ + +This function returns “true” if the logger stops successfully. Otherwise, returns “false”. + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “Adafruit_GPS.h” must be included to use the class function. + +-------------------------------------------------------------------------------------------------------------------------- + +**Adafruit_GPS::LOCUS_ReadStatus** +---------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Read the logger status. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + boolean LOCUS_ReadStatus (void); + +**Parameters** + +NA + +**Returns** +~~~~~~~~~~~ + +This function returns “true” if the logger reads the status successfully. Otherwise, returns “false” if there was no response. + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “Adafruit_GPS.h” must be included to use the class function. diff --git a/bak/ambd/_common/API_Documents/SoftwareSerial/Class PMS3003.rst b/source/_common/ameba_d/API_Documents/SoftwareSerial/Class PMS3003.rst similarity index 55% rename from bak/ambd/_common/API_Documents/SoftwareSerial/Class PMS3003.rst rename to source/_common/ameba_d/API_Documents/SoftwareSerial/Class PMS3003.rst index 5987376..9721c06 100644 --- a/bak/ambd/_common/API_Documents/SoftwareSerial/Class PMS3003.rst +++ b/source/_common/ameba_d/API_Documents/SoftwareSerial/Class PMS3003.rst @@ -1,26 +1,34 @@ -#################### Class PMS3003 -#################### +============= +.. contents:: + :local: + :depth: 2 + +**PMS3003 Class** +------------------ **Description** +~~~~~~~~~~~~~~~ Defines a class to work with PMS3003 air quality sensor on Ameba. **Syntax** +~~~~~~~~~~ -.. code:: cpp +.. code:: c++ class PMS3003 **Members** +~~~~~~~~~~~ +-----------------------------------+-----------------------------------------+ -| **Public Constructors** |   | +| **Public Constructors** | +===================================+=========================================+ | PMS3003::PMS3003 | Constructs a PMS3003 object | +-----------------------------------+-----------------------------------------+ -| **Public Methods** |   | +| **Public Methods** | +-----------------------------------+-----------------------------------------+ | PMS3003::begin | Initialize hardware UART | +-----------------------------------+-----------------------------------------+ @@ -45,368 +53,349 @@ Defines a class to work with PMS3003 air quality sensor on Ameba. --------------------------------------------------------------------------------------- -.. method:: PMS3003::PMS3003 - +**PMS3003::PMS3003** +-------------------- **Description** +~~~~~~~~~~~~~~~ Constructs a PMS3003 object and initialize the pin mapping. **Syntax** +~~~~~~~~~~ -.. code:: cpp +.. code:: c++ - PMS3003::PMS3003(int _rx, int _tx, int _set, int _reset) + PMS3003(int _rx, int _tx, int _set, int _reset); **Parameters** +~~~~~~~~~~~~~~ -``_rx`` : RX pin of UART +``_rx``: RX pin of UART -``_tx`` : TX pin of UART +``_tx``: TX pin of UART -``_set`` : Set pin +``_set``: Set pin value (Default: -1) -``_reset`` : Reset pin +``_reset``: Reset pin value (Default: -1) **Returns** +~~~~~~~~~~~ -The function returns nothing. +NA **Example Code** +~~~~~~~~~~~~~~~~ NA -**Notes and Warnings** - -NA +.. note :: “PMS3003.h” must be included to use the class function. ----------------------------------------------------------------------------------- -.. method:: PMS3003::begin - +**PMS3003::begin** +------------------ **Description** +~~~~~~~~~~~~~~~ Initialize hardware UART and allocate space for serial buffer **Syntax** +~~~~~~~~~~ -.. code:: cpp +.. code:: c++ - void PMS3003::begin(void) + void begin(void); **Parameters** +~~~~~~~~~~~~~~ -The function requires no input parameter. +NA **Returns** +~~~~~~~~~~~ -The function returns nothing. +NA **Example Code** +~~~~~~~~~~~~~~~~ NA -**Notes and Warnings** - -NA +.. note :: “PMS3003.h” must be included to use the class function. ----------------------------------------------------------------------------------- -.. method:: PMS3003::end - +**PMS3003::end** +---------------- **Description** +~~~~~~~~~~~~~~~ Free serial buffer space and stop UART **Syntax** +~~~~~~~~~~ -.. code:: cpp +.. code:: c++ - void PMS3003::end(void) + void end(void); **Parameters** +~~~~~~~~~~~~~~ -The function requires no input parameter. +NA **Returns** +~~~~~~~~~~~ -The function returns nothing. +NA **Example Code** +~~~~~~~~~~~~~~~~ NA -**Notes and Warnings** - -NA +.. note :: “PMS3003.h” must be included to use the class function. ---------------------------------------------------------------------------------- -.. method:: PMS3003::get_pm1p0_cf1 +**PMS3003::get_pm1p0_cf1** +-------------------------- **Description** +~~~~~~~~~~~~~~~ -Get PM1.0 under correction factor = 1 +Get value of PM1.0 under correction factor = 1. **Syntax** +~~~~~~~~~~ -.. code:: cpp +.. code:: c++ - int PMS3003::get_pm1p0_cf1(void) + int get_pm1p0_cf1(void); **Parameters** +~~~~~~~~~~~~~~ -The function requires no input parameter. +NA **Returns** +~~~~~~~~~~~ The function returns the value “pm1p0_cf1” as an integer. **Example Code** +~~~~~~~~~~~~~~~~ NA -**Notes and Warnings** - -NA +.. note :: “PMS3003.h” must be included to use the class function. -------------------------------------------------------------------------------- -.. method:: PMS3003::get_pm2p5_cf1 +**PMS3003::get_pm2p5_cf1** +-------------------------- **Description** +~~~~~~~~~~~~~~~ -Get PM2.5 under correction factor = 1 +Get value of PM2.5 under correction factor = 1 **Syntax** +~~~~~~~~~~ -.. code:: cpp +.. code:: c++ - int PMS3003::get_pm2p5_cf1(void) + int get_pm2p5_cf1(void); **Parameters** +~~~~~~~~~~~~~~ -The function requires no input parameter. +NA **Returns** +~~~~~~~~~~~ -The function returns the value of “pm2p5_cf1” as an integer. +This function returns the value of “pm2p5_cf1” as an integer. **Example Code** +~~~~~~~~~~~~~~~~ NA -**Notes and Warnings** - -NA +.. note :: “PMS3003.h” must be included to use the class function. ------------------------------------------------------------------------------ -.. method:: PMS3003::get_pm10_cf1 +**PMS3003::get_pm10_cf1** +------------------------- **Description** +~~~~~~~~~~~~~~~ -Get PM10 under correction factor = 1 +Get the value of PM10 under correction factor = 1. **Syntax** +~~~~~~~~~~ -.. code:: cpp +.. code:: c++ - int PMS3003::get_pm10_cf1(void) + int get_pm10_cf1(void); **Parameters** +~~~~~~~~~~~~~~ -The function requires no input parameter. +NA **Returns** +~~~~~~~~~~~ The function returns the value of “pm10_cf1” as an integer. **Example Code** +~~~~~~~~~~~~~~~~ NA -**Notes and Warnings** - - +.. note :: “PMS3003.h” must be included to use the class function. ------------------------------------------------------------------------------ -.. method:: PMS3003::get_pm1p0_air +**PMS3003::get_pm1p0_air** +-------------------------- **Description** +~~~~~~~~~~~~~~~ Get PM1.0 air quality **Syntax** +~~~~~~~~~~ -.. code:: cpp +.. code:: c++ int PMS3003::get_pm1p0_air(void) **Parameters** +~~~~~~~~~~~~~~ -The function requires no input parameter. +NA **Returns** +~~~~~~~~~~~ The function returns the value of “pm1p0_air” as an integer. **Example Code** +~~~~~~~~~~~~~~~~ NA -**Notes and Warnings** - -NA +.. note :: “PMS3003.h” must be included to use the class function. ----------------------------------------------------------------------------- -.. method:: PMS3003::get_pm2p5_air - +**PMS3003::get_pm2p5_air** +-------------------------- **Description** +~~~~~~~~~~~~~~~ -Get PM2.5 air quality +Get PM2.5 air quality. **Syntax** +~~~~~~~~~~ -.. code:: cpp +.. code:: c++ - int PMS3003::get_pm2p5_air(void) + int get_pm2p5_air(void); **Parameters** +~~~~~~~~~~~~~~ -The function requires no input parameter. +NA **Returns** +~~~~~~~~~~~ The function returns the value of “pm2p5_air” as an integer. **Example Code** +~~~~~~~~~~~~~~~~ NA -**Notes and Warnings** - -NA +.. note :: “PMS3003.h” must be included to use the class function. ------------------------------------------------------------------------------ -.. method:: PMS3003::get_pm10_air +**PMS3003::get_pm10_air** +------------------------- **Description** +~~~~~~~~~~~~~~~ -Get PM10 air quality +Get PM10 air quality. **Syntax** +~~~~~~~~~~ -.. code:: cpp +.. code:: c++ - int PMS3003::get_pm10_air(void) + int get_pm10_air(void); **Parameters** +~~~~~~~~~~~~~~ -The function requires no input parameter. +NA **Returns** +~~~~~~~~~~~ The function returns the value of “pm10_air” as an integer. **Example Code** +~~~~~~~~~~~~~~~~ NA -**Notes and Warnings** - -NA +.. note :: “PMS3003.h” must be included to use the class function. ------------------------------------------------------------------------------ -.. method:: PMS3003::pms3003_handle_interrupt +**PMS3003::pms3003_handle_interrupt** +------------------------------------- **Description** +~~~~~~~~~~~~~~~ Set up the serial event handler **Syntax** +~~~~~~~~~~ -.. code:: cpp +.. code:: c++ - void pms3003_handle_interrupt(uint32_t id, uint32_t event) + void pms3003_handle_interrupt(uint32_t id, uint32_t event); **Parameters** +~~~~~~~~~~~~~~ -``id`` : device identifier +``id``: The device identifier -``event`` : Serial event for handling incoming data +``event``: Serial event for handling incoming data **Returns** - -The function returns nothing. - -**Example Code** +~~~~~~~~~~~ NA -**Notes and Warnings** - -NA - ------------------------------------------------------------------------- - -.. method:: PMS3003::update_cache - - -**Description** - -Serves the function of updating cache memory. One package has 32 -bytes. Illustrate the formate by using below raw data: 42 4d 00 1c 00 -1b 00 21 00 29 00 1a 00 21 00 29 2b fb 04 be 00 6b 00 10 00 04 00 04 -67 00 04 46 -42 4d : header signature -00 1c : frame length, 0x001c = 28 bytes (not include header and this -field) -00 1b : PM1.0 under CF=1 -00 21 : PM2.5 under CF=1 -00 29 : PM10 under CF=1 -00 1a : PM1.0 under air -00 21 : PM2.5 under air -00 29 : PM10 under air -2b fb : number of pariticle, diameter size 0.3 um in 0.1 liter air -04 be : number of pariticle, diameter size 0.5 um in 0.1 liter air -00 6b : number of pariticle, diameter size 1.0 um in 0.1 liter air -00 10 : number of pariticle, diameter size 2.5 um in 0.1 liter air -00 04 : number of pariticle, diameter size 5.0 um in 0.1 liter air -00 04 : number of pariticle, diameter size 10 um in 0.1 liter air -67 : serial number -00 : error code -04 46 : -checksum,0x42+0x4d+0x00+0x1c+0x00+0x1b+0x00+0x21+0x00+0x29+0x00+0x1a+0x00+0x21+0x00+0x29+ -0x2b+0xfb+0x04+0xbe+0x00+0x6b+0x00+0x10+0x00+0x04+0x00+0x04+0x67+0x00 -= 0x0446 - -**Syntax** - -.. code:: cpp - - void PMS3003::update_cache(void) - -**Parameters** - -The function requires no input parameters. - -**Returns** - -The function returns nothing. - **Example Code** +~~~~~~~~~~~~~~~~ NA -**Notes and Warnings** - -NA +.. note :: “PMS3003.h” must be included to use the class function. diff --git a/source/_common/ameba_d/API_Documents/SoftwareSerial/Class SoftwareSerial.rst b/source/_common/ameba_d/API_Documents/SoftwareSerial/Class SoftwareSerial.rst new file mode 100644 index 0000000..96232d2 --- /dev/null +++ b/source/_common/ameba_d/API_Documents/SoftwareSerial/Class SoftwareSerial.rst @@ -0,0 +1,539 @@ +Class SoftwareSerial +==================== + +.. contents:: + :local: + :depth: 2 + +**SoftwareSerial Class** +------------------------ + +**Description** +~~~~~~~~~~~~~~~ + +A class for software serial implementation for Ameba. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + class SoftwareSerial + +**Members** +~~~~~~~~~~~ + ++----------------------------------+----------------------------------+ +| **Public Constructors** | ++==================================+==================================+ +| SoftwareSerial::SoftwareSerial | Constructs a SoftwareSerial | +| | object | ++----------------------------------+----------------------------------+ +| **Public Methods** | ++----------------------------------+----------------------------------+ +| SoftwareSerial::begin | Initialize and Sets the speed | +| | (baud rate) for the | +| | serial communication | ++----------------------------------+----------------------------------+ +| SoftwareSerial::listen | Enables the selected software | +| | serial port to listen | ++----------------------------------+----------------------------------+ +| SoftwareSerial::end | Deinitialize the serial | +| | communication | ++----------------------------------+----------------------------------+ +| SoftwareSerial::stopListening | Check if requested software | +| | serial port is actively listening| ++----------------------------------+----------------------------------+ +| SoftwareSerial::peek | Get a character that was | +| | received on the RX pin of the | +| | software serial port | ++----------------------------------+----------------------------------+ +| SoftwareSerial::write | Send a single byte to the | +| | transmit pin of the software | +| | serial port as raw bytes | ++----------------------------------+----------------------------------+ +| SoftwareSerial::read | Read data that was received | +| | from RX pin of the | +| | software serial port | ++----------------------------------+----------------------------------+ +| SoftwareSerial::available | Get the number of bytes | +| | (characters) available for | +| | reading from a software serial | +| | port | ++----------------------------------+----------------------------------+ +| SoftwareSerial::flush | Clear the received buffer | ++----------------------------------+----------------------------------+ +| SoftwareSerial::setBufferSize | Set receive buffer size | ++----------------------------------+----------------------------------+ +| Soft | Set available callback functions | +| wareSerial::setAvailableCallback | | ++----------------------------------+----------------------------------+ +| SoftwareSerial::handle_interrupt | Private methods handles | +| | interrupt | ++----------------------------------+----------------------------------+ + +-------------------------------------- + +**SoftwareSerial::SoftwareSerial** +---------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Constructs a SoftwareSerial object and sets RX and TX pin, and inverse logic. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + SoftwareSerial(uint8_t receivePin, uint8_t transmitPin, bool inverse_logic); + +**Parameters** +~~~~~~~~~~~~~~ + +``receivePin``: the pin on which to receive serial data + +``transmitPin``: the pin on which to transmit serial data + +``inverse_logic``: used to invert the sense of incoming bits (the default is normal logic). If set, SoftwareSerial treats a LOW (0v on the pin, normally) on the RX pin as a 1-bit (the idle state) and a HIGH (5V on the pin, normally) as a 0-bit. It also affects the way that it writes to the TX pin. (Default: False) + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `SoftwareSerial_Basic `_ + +.. Caution :: Software Serial is using hardware serial thus DO NOT change the default pins. + +.. note :: “SoftwareSerial.h” must be included to use the class function. + +----------------------------- + +**SoftwareSerial::begin** +------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Initialize and set the speed (baud rate) for the serial communication. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void begin (long speed); + +.. code:: c++ + + void begin (long speed, int data_bits, int parity, int stop_bits); + +.. code:: c++ + + void begin (long speed, int data_bits, int parity, int stop_bits, int flowctrl, int rtsPin, int ctsPin); + +**Parameters** +~~~~~~~~~~~~~~ + +``speed``: the desired baud rate (long). Supported baud rates are: 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 28800, 31250, 38400, 57600, and 115200 bauds. + +``data_bits``: number of data bits, 8 bits(default) or 7 bits + +``stop_bits``: number of stop bits, 1 bit(default), 1.5 bits or 2 bits + +``flowctrl``: flow control pin + +``rtsPin``: request to send pin + +``ctsPin``: clear to send pin + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `SoftwareSerial_Basic `_ + +.. note :: “SoftwareSerial.h” must be included to use the class function. + +------------------------------------ + +**SoftwareSerial::listen** +-------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Enables the selected software serial port to listen. Only one SoftwareSerial object can listen at a time; data that arrives for other ports will be discarded. Any data already received is discarded during the call to listen() function (unless the given instance is already listening). + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + bool listen(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +This function returns true if it is listening, otherwise false. + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “SoftwareSerial.h” must be included to use the class function. + +------------------------- + +**SoftwareSerial::end** +----------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Deinitialize the serial communication by deallocate the receiving buffer. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void end(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “SoftwareSerial.h” must be included to use the class function. + +-------------------------------------------- + +**SoftwareSerial::isListening** +------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Check if requested software serial port is actively listening. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + bool isListening(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +This function returns “True” if the port is actively listening, otherwise returns “False”. + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “SoftwareSerial.h” must be included to use the class function. + +---------------------------------------- + +**SoftwareSerial::stopListening** +--------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Selected software serial port stop listening. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + bool stopListening(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +This function returns “True” if the selected software serial port stop listening. + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “SoftwareSerial.h” must be included to use the class function. + +-------------------------- + +**SoftwareSerial::peek** +------------------------ + +**Description** +~~~~~~~~~~~~~~~ + +Get a character that was received on the RX pin of the software serial port. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + int peek(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +This function returns the head data read from the receiving buffer or returns “-1” if none is available. + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “SoftwareSerial.h” must be included to use the class function. + +------------------------------------ + +**SoftwareSerial::write** +------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Send a single byte to the transmit pin of the software serial port as raw bytes with 10ms timeout. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + virtual size_t write(uint8_t byte); + +**Parameters** +~~~~~~~~~~~~~~ + +``byte``: data to be sent in 8-bit + +**Returns** +~~~~~~~~~~~ + +This function returns the number of bytes written. + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `SoftwareSerial_Basic `_ + +.. note :: “SoftwareSerial.h” must be included to use the class function. + +---------------------------- + +**SoftwareSerial::read** +------------------------ + +**Description** +~~~~~~~~~~~~~~~ + +Read data that was received from RX pin of the software serial port. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + virtual int read(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +This function returns the byte read or returns -1 if none is available. + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `SoftwareSerial_Basic `_ + +.. note :: “SoftwareSerial.h” must be included to use the class function. + +---------------------------- + +**SoftwareSerial::available** +----------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Get the number of bytes available for reading from a software serial port. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + virtual int available(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +The function returns the number of bytes available in the receive buffer. + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `SoftwareSerial_Basic `_ + +.. note :: “SoftwareSerial.h” must be included to use the class function. + +------------------------ + +**SoftwareSerial::flush** +------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Clear the received buffer. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + virtual void flush(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “SoftwareSerial.h” must be included to use the class function. + +--------------------------------------- + +**SoftwareSerial::setBufferSize** +--------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Set buffer size. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void setBufferSize(uint32_t buffer_size) + +**Parameters** +~~~~~~~~~~~~~~ + +``buffer_size``: the size of the receive buffer + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “SoftwareSerial.h” must be included to use the class function. + +----------------------------------- + +**SoftwareSerial::setAvailableCallback** +---------------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Set available callback + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void setAvailableCallback(void (*callback)(char c)) + +**Parameters** +~~~~~~~~~~~~~~ + +``*callback``: user-defined serial callback function + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `SoftwareSerialIrqCallback `_ + +.. note :: “SoftwareSerial.h” must be included to use the class function. diff --git a/bak/ambd/_common/API_Documents/SoftwareSerial/index.rst b/source/_common/ameba_d/API_Documents/SoftwareSerial/index.rst similarity index 100% rename from bak/ambd/_common/API_Documents/SoftwareSerial/index.rst rename to source/_common/ameba_d/API_Documents/SoftwareSerial/index.rst diff --git a/source/_common/ameba_d/API_Documents/Sys/Wiring_OS_API.rst b/source/_common/ameba_d/API_Documents/Sys/Wiring_OS_API.rst new file mode 100644 index 0000000..1acec61 --- /dev/null +++ b/source/_common/ameba_d/API_Documents/Sys/Wiring_OS_API.rst @@ -0,0 +1,717 @@ +Class Wiring_OS_API +=================== + +.. contents:: + :local: + :depth: 2 + +**Wiring OS API Class** +----------------------- + +**Description** +~~~~~~~~~~~~~~~ + +A wrapper to CMSIS (Cortex Microcontroller Software Interface Standard) OS API which serve as a RTOS to create multi-threaded application with real-time behaviour. + +**Syntax** +~~~~~~~~~~ + +NA + +**Members** +~~~~~~~~~~~ + ++--------------------------------+------------------------------------+ +| **Public Methods** | ++================================+====================================+ +| os_thread_create_arduino | Create a thread and add it to | +| | Active Threads and set it to state | +| | READY | ++--------------------------------+------------------------------------+ +| os_thread_get_id_arduino | Return the thread ID of the | +| | current running thread | ++--------------------------------+------------------------------------+ +| os_thread_terminate_arduino | Terminate execution of a thread | +| | and remove it from Active Threads | ++--------------------------------+------------------------------------+ +| os_thread_yield_arduino | Pass control to next thread that | +| | is in state READY | ++--------------------------------+------------------------------------+ +| os_thread_set_priority_arduino | Change priority of an active | +| | thread | ++--------------------------------+------------------------------------+ +| os_thread_get_priority_arduino | Get current priority of an active | +| | thread | ++--------------------------------+------------------------------------+ +| os_signal_set_arduino | Set the specified Signal Flags of | +| | an active thread | ++--------------------------------+------------------------------------+ +| os_signal_clear_arduino | Clear the specified Signal Flags | +| | of an active thread | ++--------------------------------+------------------------------------+ +| os_signal_wait_arduino | Wait for one or more Signal Flags | +| | to become signaled for the current | +| | RUNNING thread | ++--------------------------------+------------------------------------+ +| os_timer_create_arduino | Create a timer | ++--------------------------------+------------------------------------+ +| os_timer_start_arduino | Start or restart a timer | ++--------------------------------+------------------------------------+ +| os_timer_stop_arduino | Stop the timer | ++--------------------------------+------------------------------------+ +| os_timer_delete_arduino | Delete a timer that was created by | +| | os_timer_create | ++--------------------------------+------------------------------------+ +| os_semaphore_create_arduino | Create and Initialize a Semaphore | +| | object used for managing resources | ++--------------------------------+------------------------------------+ +| os_semaphore_wait_arduino | Wait until a Semaphore token | +| | becomes available | ++--------------------------------+------------------------------------+ +| os_semaphore_release_arduino | Release a Semaphore token | ++--------------------------------+------------------------------------+ +| os_semaphore_delete_arduino | Delete a Semaphore that was | +| | created by os_semaphore_create | ++--------------------------------+------------------------------------+ +| os_get_free_heap_size_arduino | Return the available heap memory | +| | space when called | ++--------------------------------+------------------------------------+ + +**os_thread_create_arduino** +---------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Create a thread and add it to Active Threads and set it to state READY. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + uint32_t os_thread_create_arduino (void (*task)(const void *argument), void *argument, int priority, uint32_t stack_size); + +**Parameters** +~~~~~~~~~~~~~~ + +``task``: task Function pointer which is the thread body. It should not run into the end of function unless os_thread_terminate is invoked + +``argument``: The pointer that is passed to the thread function as start argument. + +``priority``: The underlying os is FreeRTOS. It executes tasks with highest priority which are not in idle state. + +``stack_size``: The stack_size is used as memory heap only for this task. + +**Returns** +~~~~~~~~~~~ + +This function returns the thread ID in 32-bit which is used in thread operation for reference by other functions or NULL in case of error. + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “wiring_os.h” must be included to use the class function. + +------------------------------------ + +**os_thread_get_id_arduino** +---------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Get the thread ID of the current running thread. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + uint32_t os_thread_get_id_arduino (void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +This function returns current thread id in 32-bit which calls os_thread_get_id_arduino. + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “wiring_os.h” must be included to use the class function. + +--------------------------------------- + +**os_thread_terminate_arduino** +------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Terminate execution of a thread and remove it from Active Threads. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + uint32_t os_thread_terminate_arduino (uint32_t thread_id); + +**Parameters** +~~~~~~~~~~~~~~ + +``thread_id``: Terminate the thread with specific thread_id + +**Returns** +~~~~~~~~~~~ + +This function returns the os_status code. + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. important :: Thread should not end without terminate first. + +.. note :: “wiring_os.h” must be included to use the class function. + +------------------------------------ + +**os_thread_yield_arduino** +--------------------------- + +**Description** +~~~~~~~~~~~~~~~ +Pass control to next thread that is in READY state + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + uint32_t os_thread_yield_arduino (void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +This function returns the os_status code. + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. important :: The smallest execution unit by default is one millisecond. When a thread with a lower priority wants to instantly give execution rights to a thread with a higher priority rather than waiting for the current 1 millisecond to expire, calling os_thread yield can transfer execution rights to the OS's idle task and determine which thread will execute next. + +.. note :: “wiring_os.h” must be included to use the class function. + +----------------------------------------- + +**os_thread_set_priority_arduino** +---------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Change priority of an active thread. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + uint32_t os_thread_set_priority_arduino (uint32_t thread_id, int priority); + +**Parameters** +~~~~~~~~~~~~~~ + +``thread_id``: Thread ID identifies the thread (pointer to a thread control block). + +``priority``: The updated priority + + +**Returns** +~~~~~~~~~~~ + +This function returns os_status code. + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “wiring_os.h” must be included to use the class function. + +-------------------------------------- + +**os_thread_get_priority_arduino** +---------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Get current priority of an active thread. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + uint32_t os_thread_get_priority_arduino (uint32_t thread_id); + +**Parameters** +~~~~~~~~~~~~~~ + +``thread_id``: The target thread with the thread id to be searched + +**Returns** +~~~~~~~~~~~ + +This function returns os_priority. + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “wiring_os.h” must be included to use the class function. + +------------------------------ + +**os_signal_set_arduino** +------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Set the specified Signal Flags of an active thread. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + int32_t os_signal_set_arduino (uint32_t thread_id, int32_t signals); + +**Parameters** +~~~~~~~~~~~~~~ + +``thread_id``: Thread ID obtained by os_thread_create_arduino or + +``os_thread_get_id_arduino.signals``: The signal flags of the thread that should be set. + +**Returns** +~~~~~~~~~~~ + +This function returns previous signal flags of the specified thread or 0x80000000 in case of incorrect parameters. + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “wiring_os.h” must be included to use the class function. + +------------------------------------ + +**os_signal_clear_arduino** +--------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Clear the specified Signal Flags of an active thread. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + int32_t os_signal_clear_arduino (uint32_t thread_id, int32_t signals); + +**Parameters** +~~~~~~~~~~~~~~ + +``thread_id``: Clear signal to a thread with the thread_id + +``signals``: The signal flags of the thread that shall be cleared. + +**Returns** +~~~~~~~~~~~ + +This function returns previous signal flags of the specified thread or 0x80000000 in case of incorrect parameters. + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “wiring_os.h” must be included to use the class function. + +---------------------------------- + +**os_signal_wait_arduino** +-------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Wait for one or more Signal Flags to become signalled for the current RUNNING thread. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + os_event_t os_signal_wait_arduino (int32_t signals, uint32_t millisec); + +**Parameters** +~~~~~~~~~~~~~~ + +``signals``: the signals to be wait + +``millisec``: the timeout value if no signal comes in (in ms). (Acceptable range: 0 - 0xFFFFFFFF, 0 indicates no timeout, 0xFFFFFFFF indicates infinite timeout) + + +**Returns** +~~~~~~~~~~~ + +This function returns event flag information or error code. + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “wiring_os.h” must be included to use the class function. + +--------------------------------- + +**os_timer_create_arduino** +--------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Create a timer. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + uint32_t os_timer_create_arduino (void (*callback)(void const *argument), uint8_t isPeriodic, void *argument); + +**Parameters** +~~~~~~~~~~~~~~ + +``callback``: The function to be invoke when timer timeout + +``isPeriodic``: OS_TIMER_ONCE or OS_TIMER_PERIODIC + +``argument``: The argument that is brought into callback function + +**Returns** +~~~~~~~~~~~ + +This function returns the timer id. + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “wiring_os.h” must be included to use the class function. + +------------------------------- + +**os_timer_start_arduino** +-------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Start or restart a timer. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + uint32_t os_timer_start_arduino (uint32_t timer_id, uint32_t millisec); + +**Parameters** +~~~~~~~~~~~~~~ + +``timer_id``: The timer id obtained from os_timer_create + +``millisec``: The delay after timer starts (in ms) (Acceptable range: 0 - 0xFFFFFFFF, 0 indicates no timeout, 0xFFFFFFFF indicates infinite timeout) + + +**Returns** +~~~~~~~~~~~ + +This function returns os_status code. + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “wiring_os.h” must be included to use the class function. + +----------------------------- + +**os_timer_stop_arduino** +------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Stop the timer. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + uint32_t os_timer_stop_arduino (uint32_t timer_id); + +**Parameters** +~~~~~~~~~~~~~~ + +``timer_id``: The timer id obtained from os_timer_create + +**Returns** +~~~~~~~~~~~ + +This function returns os_status code. + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “wiring_os.h” must be included to use the class function. + +**os_timer_delete_arduino** +--------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Delete a timer that was created by “os_timer_create_arduino”. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + uint32_t os_timer_delete_arduino(uint32_t timer_id); + +**Parameters** +~~~~~~~~~~~~~~ + +``timer_id``: The timer id obtained from os_timer_create + +**Returns** +~~~~~~~~~~~ + +This function returns os_status code. + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “wiring_os.h” must be included to use the class function. + +-------------------------------- + +**os_semaphore_create_arduino** +------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Create and initialize a Semaphore object used for managing resources. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + uint32_t os_semaphore_create_arduino (int32_t count); + +**Parameters** +~~~~~~~~~~~~~~ + +``count``: The number of available resources + +**Returns** +~~~~~~~~~~~ + +This function returns semaphore ID. + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “wiring_os.h” must be included to use the class function. + +------------------------------- + +**os_semaphore_wait_arduino** +----------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Wait until a Semaphore token becomes available. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + int32_t os_semaphore_wait_arduino (uint32_t semaphore_id, uint32_t millisec); + +**Parameters** +~~~~~~~~~~~~~~ + +``semaphore_id``: semaphore id obtained from os_semaphore_create + +``millisec``: timeout value (in ms). (Acceptable range: 0 - 0xFFFFFFFF, 0 indicates no timeout, 0xFFFFFFFF indicates infinite timeout) + + +**Returns** +~~~~~~~~~~~ + +This function returns “1” if “os_semaphoe_wait_arduino” gets the available semaphore token, otherwise returns “0”. + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “wiring_os.h” must be included to use the class function. + +---------------------------------- + +**os_semaphore_release_arduino** +-------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Release a Semaphore token. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + uint32_t os_semaphore_release_arduino (uint32_t semaphore_id); + +**Parameters** +~~~~~~~~~~~~~~ + +``semaphore_id``: semaphore id obtained from os_semaphore_create + +**Returns** +~~~~~~~~~~~ + +This function returns os_status code that indicates the execution status of the function. + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “wiring_os.h” must be included to use the class function. + +-------------------------------- + +**os_semaphore_delete_arduino** +------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Delete a Semaphore that was created by os_semaphore_create + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + uint32_t os_semaphore_delete_arduino (uint32_t semaphore_id); + +**Parameters** +~~~~~~~~~~~~~~ + +``semaphore_id``: semaphore id obtained from os_semaphore_create + +**Returns** +~~~~~~~~~~~ + +This function returns os_status code that indicates the execution status of the function. + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. important :: “os_semaphore_delete_arduino” shall be consistent in every CMSIS_RTOS. + +.. note :: “wiring_os.h” must be included to use the class function. + +----------------------------------- + +**os_get_free_heap_size_arduino** +--------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Get the available heap memory space when called. + +**Syntax** +~~~~~~~~~~ + +.. code-block:: c++ + + size_t os_get_free_heap_size_arduino (void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +This function returns the current free heap size as unsigned integer. + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `MemInfo `_ + +.. note :: “wiring_os.h” must be included to use the class function. diff --git a/bak/ambd/_common/API_Documents/Sys/index.rst b/source/_common/ameba_d/API_Documents/Sys/index.rst similarity index 100% rename from bak/ambd/_common/API_Documents/Sys/index.rst rename to source/_common/ameba_d/API_Documents/Sys/index.rst diff --git a/source/_common/ameba_d/API_Documents/USB/Class USBCDCDevice.rst b/source/_common/ameba_d/API_Documents/USB/Class USBCDCDevice.rst new file mode 100644 index 0000000..fe86a42 --- /dev/null +++ b/source/_common/ameba_d/API_Documents/USB/Class USBCDCDevice.rst @@ -0,0 +1,646 @@ +Class USBCDCDevice +================== + +.. contents:: + :local: + :depth: 2 + +**USBCDCDevice Class** +---------------------- + +**Description** +~~~~~~~~~~~~~~~ + +A class for managing, transmitting, and receiving data using USB CDC ACM +device class. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + class USBCDCDevice + +**Members** +~~~~~~~~~~~ + ++------------------------------------+---------------------------------+ +| **Public Constructors** | ++====================================+=================================+ +| The public constructor should not be used as this class is intended | +| to be a singleton class. Access member functions using the object | +| instance named ``SerialUSB``. | ++------------------------------------+---------------------------------+ +| **Public Methods** | ++------------------------------------+---------------------------------+ +| USBCDCDevice::setVID | Set USB vendor ID value | ++------------------------------------+---------------------------------+ +| USBCDCDevice::setPID | Set USB product ID value | ++------------------------------------+---------------------------------+ +| U | Set USB manufacturer string | +| SBCDCDevice::setManufacturerString | | ++------------------------------------+---------------------------------+ +| USBCDCDevice::setModelString | Set USB product model string | ++------------------------------------+---------------------------------+ +| USBCDCDevice::setSerialString | Set USB product serial number | +| | string | ++------------------------------------+---------------------------------+ +| USBCDCDevice::USBconnected | Check if the USB port is | +| | connected to a host | ++------------------------------------+---------------------------------+ +| USBCDCDevice::connected | Check if the USB CDC serial | +| | terminal is ready on the host | ++------------------------------------+---------------------------------+ +| USBCDCDevice::dtr | Check DTR signal state | ++------------------------------------+---------------------------------+ +| USBCDCDevice::rts | Check RTS signal state | ++------------------------------------+---------------------------------+ +| USBCDCDevice::begin | Start serial communication | +| | using USB CDC | ++------------------------------------+---------------------------------+ +| USBCDCDevice::end | Stop serial communication using | +| | USB CDC | ++------------------------------------+---------------------------------+ +| USBCDCDevice::available | Get the number of bytes | +| | (characters) available for | +| | reading from the USB serial | +| | port | ++------------------------------------+---------------------------------+ +| USBCDCDevice::peek | Returns the next byte | +| | (character) of incoming serial | +| | data without removing it from | +| | the internal buffer | ++------------------------------------+---------------------------------+ +| USBCDCDevice::read | Reads incoming serial data | ++------------------------------------+---------------------------------+ +| USBCDCDevice::flush | Waits for the transmission of | +| | outgoing serial data to | +| | complete | ++------------------------------------+---------------------------------+ +| USBCDCDevice::write | Writes binary data to the | +| | serial port | ++------------------------------------+---------------------------------+ + +----------------------------- + +**USBCDCDevice::setVID** +------------------------ + +**Description** +~~~~~~~~~~~~~~~ + +Set USB vendor ID value. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void setVID (uint16_t VID); + +**Parameters** +~~~~~~~~~~~~~~ + +``VID``: vendor ID + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. important :: The VID should be configured before USBCDCDevice::begin() function is called. + +.. note :: “USBCDCDevice.h” must be included to use the class function. + +------------------------- + +**USBCDCDevice::setPID** +------------------------ + +**Description** +~~~~~~~~~~~~~~~ + +Set USB product ID value. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void setPID (uint16_t PID); + +**Parameters** +~~~~~~~~~~~~~~ + +``PID``: product ID + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. important :: The PID should be configured before USBCDCDevice::begin() function is called. + +.. note :: “USBCDCDevice.h” must be included to use the class function. + +--------------------------------------- + +**USBCDCDevice::setManufacturerString** +--------------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Set USB manufacturer string. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void setManufacturerString (const char* manufacturer); + +**Parameters** +~~~~~~~~~~~~~~ + +``manufacturer``: Character string containing manufacturer name + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. important :: The manufacturer string should be configured before USBCDCDevice::begin() function is called. + +.. note :: “USBCDCDevice.h” must be included to use the class function. + +----------------------------- + +**USBCDCDevice::setModelString** +-------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Set USB product model string. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void setModelString (const char* model); + +**Parameters** +~~~~~~~~~~~~~~ + +``model``: Character string containing model name. Default “Realtek USB VCP”. + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. important :: The model string should be configured before USBCDCDevice::begin() function is called. + +.. note :: “USBCDCDevice.h” must be included to use the class function. + +--------------------------------------------- + +**USBCDCDevice::setSerialString** +--------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Set USB product serial number string. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void setSerialString (const char* serial); + +**Parameters** +~~~~~~~~~~~~~~ + +``serial``: Character string containing serial number. Default “0123456789”. + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. important :: The serial string should be configured before USBCDCDevice::begin() function is called. + +.. note :: “USBCDCDevice.h” must be included to use the class function. + +------------------------------ + +**USBCDCDevice::USBconnected** +------------------------------ + +**Description** +~~~~~~~~~~~~~~~ + +Check if the USB port is connected to a host. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + uint8_t USBconnected(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +The function returns TRUE if the USB port is connected to a host, FALSE if it is not connected. + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “USBCDCDevice.h” must be included to use the class function. + +------------------------------ + +**USBCDCDevice::connected** +--------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Check if the USB CDC serial terminal is ready on the host. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + uint8_t connected(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +This function returns TRUE if the USB port is connected to a host and the DTR and RTS signals are set, else returns FALSE. + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “USBCDCDevice.h” must be included to use the class function. + +------------------------ + +USBCDCDevice::dtr + +**Description** +~~~~~~~~~~~~~~~ + +Check DTR signal state. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + uint8_t dtr(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +The function returns the state of the DTR signal line. + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “USBCDCDevice.h” must be included to use the class function. + +------------------------ + +**USBCDCDevice::rts** +--------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Check RTS signal state. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + uint8_t rts(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +The function returns the state of the RTS signal line. + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “USBCDCDevice.h” must be included to use the class function. + +------------------------ + +**USBCDCDevice::begin** +----------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Start serial communication using USB CDC. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void begin(uint32_t baud); + +**Parameters** +~~~~~~~~~~~~~~ + +``baud``: baud rate + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `USBCDCSerial `_ + +.. important :: The baud rate parameter has no significance in the context of a USB CDC serial port and can be left empty. + +.. note :: “USBCDCDevice.h” must be included to use the class function. + +------------------------ + +**USBCDCDevice::end** +--------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Stop serial communication using USB CDC. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void end(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “USBCDCDevice.h” must be included to use the class function. + +------------------------ + +**USBCDCDevice::available** +--------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Get the number of bytes (characters) available for reading from the USB serial port. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + int available(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +This function returns the number of bytes received in the buffer. + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `USBCDCSerial `_ + +.. note :: “USBCDCDevice.h” must be included to use the class function. + +------------------------ + +**USBCDCDevice::peek** +---------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Get the next byte (character) of incoming serial data without removing it from the internal buffer. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + int peek(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +This function returns the next byte of received serial data without removing it from the internal buffer else returns error(-1). + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “USBCDCDevice.h” must be included to use the class function. + +----------------------- + +**USBCDCDevice::read** +---------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Reads incoming serial data. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + int read(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +This function returns the next byte of received serial data, else returns error(-1). + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `USBCDCSerial `_ + +.. note :: “USBCDCDevice.h” must be included to use the class function. + +----------------------- + +**USBCDCDevice::flush** +----------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Waits for the transmission of outgoing serial data to complete. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void flush(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “USBCDCDevice.h” must be included to use the class function. + +--------------------------- + +**USBCDCDevice::write** +----------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Writes binary data to the serial port. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + size_t write(uint8_t data); + +.. code:: c++ + + size_t write(const uint8_t* buffer, size_t size); + +**Parameters** +~~~~~~~~~~~~~~ + +``data``: 1 byte of data to write to serial port + +``buffer``: pointer to buffer containing data to write to serial port + +``size``: number of bytes of data in buffer to write to serial port + +**Returns** +~~~~~~~~~~~ + +This function returns the number of bytes written to serial port. + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `USBCDCSerial `_ + +.. note :: “USBCDCDevice.h” must be included to use the class function. + \ No newline at end of file diff --git a/source/_common/ameba_d/API_Documents/USB/Class USBHIDDevice.rst b/source/_common/ameba_d/API_Documents/USB/Class USBHIDDevice.rst new file mode 100644 index 0000000..f05cf86 --- /dev/null +++ b/source/_common/ameba_d/API_Documents/USB/Class USBHIDDevice.rst @@ -0,0 +1,496 @@ +Class USBHIDDevice +================== + +.. contents:: + :local: + :depth: 2 + +**USBHIDDevice Class** +---------------------- + +**Description** +~~~~~~~~~~~~~~~ + +A class used for creating and managing USB HID device class + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + class USBHIDDevice + +**Members** +~~~~~~~~~~~ + ++------------------------------------+---------------------------------+ +| **Public Constructors** | ++====================================+=================================+ +| The public constructor should not be used as this class is intended | +| to be a singleton class. Access member functions using the object | +| instance named ``USBHIDDev``. | ++------------------------------------+---------------------------------+ +| **Public Methods** | ++------------------------------------+---------------------------------+ +| USBHIDDevice::setReportDescriptor | Configure the HID report | +| | descriptor | ++------------------------------------+---------------------------------+ +| USBHIDDevice::setUSBEndpointMPS | Configure USB endpoint maximum | +| | packet size | ++------------------------------------+---------------------------------+ +| US | Configure USB endpoint polling | +| BHIDDevice::setUSBEndpointInterval | interval | ++------------------------------------+---------------------------------+ +| USBHIDDevice::setVID | Set USB vendor ID value | ++------------------------------------+---------------------------------+ +| USBHIDDevice::setPID | Set USB product ID value | ++------------------------------------+---------------------------------+ +| U | Set USB manufacturer string | +| SBHIDDevice::setManufacturerString | | ++------------------------------------+---------------------------------+ +| USBHIDDevice::setModelString | Set USB product model string | ++------------------------------------+---------------------------------+ +| USBHIDDevice::setSerialString | Set USB product serial number | +| | string | ++------------------------------------+---------------------------------+ +| USBHIDDevice::USBconnected | Check if the USB port is | +| | connected to a host | ++------------------------------------+---------------------------------+ +| USBHIDDevice::begin | Start USB HID device | ++------------------------------------+---------------------------------+ +| USBHIDDevice::end | Stop USB HID device | ++------------------------------------+---------------------------------+ +| USBHIDDevice::inputReport | Send a HID input report | ++------------------------------------+---------------------------------+ + +------------------------------- + +**USBHIDDevice::setReportDescriptor** +------------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Configure the HID report descriptor. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void setReportDescriptor(uint8_t* report_desc, uint16_t len); + +**Parameters** +~~~~~~~~~~~~~~ + +``report_desc``: pointer to buffer containing HID report descriptor + +``len``: HID report descriptor length in number of bytes + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `USBHIDGamepad `_ + +.. important :: Default HID report descriptor is configured for mouse + keyboard + consumer control. + +.. note :: “USBHIDDevice.h” must be included to use the class function. + +------------------------------- + +**USBHIDDevice::setUSBEndpointMPS** +----------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Configure USB endpoint maximum packet size. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void setUSBEndpointMPS(uint8_t max_packet_size); + +**Parameters** +~~~~~~~~~~~~~~ + +``max_packet_size``: maximum HID report packet size in bytes + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `USBHIDGamepad `_ + +.. important :: The USB endpoint maximum packet size should correspond to the size of the largest HID report defined in the HID report descriptor. + +.. note :: “USBHIDDevice.h” must be included to use the class function. + +------------------------------------ + +**USBHIDDevice::setUSBEndpointInterval** +---------------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Configure USB endpoint polling interval. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void setUSBEndpointInterval(uint8_t poll_interval); + +**Parameters** +~~~~~~~~~~~~~~ + +``poll_interval``: polling interval for USB interrupt endpoint, expressed in milliseconds + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. important :: Default polling interval is set at the minimum of 1 millisecond. + +.. note :: “USBHIDDevice.h” must be included to use the class function. + +-------------------------- + +**USBHIDDevice::setVID** +------------------------ + +**Description** +~~~~~~~~~~~~~~~ + +Set USB vendor ID value. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void setVID(uint16_t VID); + +**Parameters** +~~~~~~~~~~~~~~ + +``VID``: vendor ID + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. important :: The VID should be configured before USBHIDDevice::begin() function is called. + +.. note :: “USBHIDDevice.h” must be included to use the class function. + +------------------------ + +**USBHIDDevice::setPID** +------------------------ + +**Description** +~~~~~~~~~~~~~~~ + +Set USB product ID value. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void setPID(uint16_t PID); + +**Parameters** +~~~~~~~~~~~~~~ + +``PID``: product ID + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. important :: The PID should be configured before USBHIDDevice::begin() function is called. + +.. note :: “USBHIDDevice.h” must be included to use the class function. + +---------------------------------------- + +**USBHIDDevice::setManufacturerString** +--------------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Set USB manufacturer string. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void setManufacturerString(const char* manufacturer); + +**Parameters** +~~~~~~~~~~~~~~ + +``manufacturer``: Character string containing manufacturer name. Default “Realtek”. + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. important :: The manufacturer string should be configured before USBHIDDevice::begin() function is called + +.. note :: “USBHIDDevice.h” must be included to use the class function. + +----------------------------------- + +**USBHIDDevice::setModelString** +------------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Set USB product model string. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void setModelString(const char* model); + +**Parameters** +~~~~~~~~~~~~~~ + +``model``: Character string containing model name. Default “Realtek USB HID”. + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. important :: The model string should be configured before USBHIDDevice::begin() function is called. + +.. note :: “USBHIDDevice.h” must be included to use the class function. + +---------------------------------- + +**USBHIDDevice::setSerialString** +--------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Set USB product serial number string. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void setSerialString(const char* serial); + +**Parameters** +~~~~~~~~~~~~~~ + +``serial``: Character string containing serial number. Default “0123456789”. + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. important :: The serial string should be configured before USBHIDDevice::begin() function is called. + +.. note :: “USBHIDDevice.h” must be included to use the class function. + +---------------------------- + +**USBHIDDevice::USBconnected** +------------------------------ + +**Description** +~~~~~~~~~~~~~~~ + +Check if the USB port is connected to a host. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + uint8_t USBconnected(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +This function returns TRUE as 1 if the USB port is connected to a host, FALSE as 0 if it is not connected. + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `USBHIDGamepad `_ + +.. note :: “USBHIDDevice.h” must be included to use the class function. + +------------------------ + +**USBHIDDevice::begin** +----------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Start USB HID device. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void begin(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `USBHIDGamepad `_ + +.. note :: “USBHIDDevice.h” must be included to use the class function. + +--------------------- + +**USBHIDDevice::end** +--------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Stop USB HID device. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void end(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “USBHIDDevice.h” must be included to use the class function. + +------------------------------- + +**USBHIDDevice::inputReport** +----------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Send a HID input report. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void inputReport(uint8_t reportID, uint8_t* data, uint16_t len); + +**Parameters** +~~~~~~~~~~~~~~ + +``reportID``: HID report ID of input report + +``data``: pointer to HID input report data to send + +``len`` length of HID input report data in bytes + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. important :: A reportID value of 0 is not a valid report ID and will send an input report without the report ID field. + +.. note :: “USBHIDDevice.h” must be included to use the class function. diff --git a/source/_common/ameba_d/API_Documents/USB/Class USBHIDGamepad.rst b/source/_common/ameba_d/API_Documents/USB/Class USBHIDGamepad.rst new file mode 100644 index 0000000..10d6f6d --- /dev/null +++ b/source/_common/ameba_d/API_Documents/USB/Class USBHIDGamepad.rst @@ -0,0 +1,517 @@ +Class USBHIDGamepad +=================== + +.. contents:: + :local: + :depth: 2 + +**USBHIDGamepad Class** +----------------------- + +**Description** +~~~~~~~~~~~~~~~ + +A class used for creating and managing a USB HID Gamepad. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + class USBHIDGamepad + +**Members** +~~~~~~~~~~~ + ++------------------------------------+---------------------------------+ +| **Public Constructors** | ++====================================+=================================+ +| USBHIDGamepad::USBHIDGamepad | Constructs a USBHIDGamepad | +| | object | ++------------------------------------+---------------------------------+ +| **Public Methods** | ++------------------------------------+---------------------------------+ +| USBHIDGamepad::setReportID | Set HID report ID for the HID | +| | Gamepad | ++------------------------------------+---------------------------------+ +| USBHIDGamepad::gamepadReport | Send a HID Gamepad report | ++------------------------------------+---------------------------------+ +| USBHIDGamepad::buttonPress | Send a HID Gamepad report | +| | indicating buttons pressed | ++------------------------------------+---------------------------------+ +| USBHIDGamepad::buttonRelease | Send a HID Gamepad report | +| | indicating buttons released | ++------------------------------------+---------------------------------+ +| USBHIDGamepad::buttonReleaseAll | Send a HID Gamepad report | +| | indicating no buttons pressed | ++------------------------------------+---------------------------------+ +| USBHIDGamepad::setHat | Send a HID Gamepad report | +| | indicating hat switch position | ++------------------------------------+---------------------------------+ +| USBHIDGamepad::setAxes | Send a HID Gamepad report | +| | indicating position of all axes | ++------------------------------------+---------------------------------+ +| USBHIDGamepad::setLeftStick | Send a HID Gamepad report | +| | indicating position of axes | +| | corresponding to left analog | +| | stick | ++------------------------------------+---------------------------------+ +| USBHIDGamepad::setRightStick | Send a HID Gamepad report | +| | indicating position of axes | +| | corresponding to right analog | +| | stick | ++------------------------------------+---------------------------------+ +| USBHIDGamepad::setTriggers | Send a HID Gamepad report | +| | indicating position of axes | +| | corresponding to triggers | ++------------------------------------+---------------------------------+ + +-------------------------------- + +**USBHIDGamepad::USBHIDGamepad** +-------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Constructs a USBHIDGamepad object. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + USBHIDGamepad(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `USBHIDGamepad `_ + +.. important :: By default, the USBHIDGamepad class assumes the HID report descriptor implements a gamepad device with 16 buttons, 6 axes with 16-bit resolution and an 8-direction hat switch. This class will not work if a different gamepad report descriptor is implemented. + +.. note :: “USBHIDGamepad.h” must be included to use the class function. + +-------------------------------- + +**USBHIDGamepad::setReportID** +------------------------------ + +**Description** +~~~~~~~~~~~~~~~ + +Set HID report ID for the HID Gamepad. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void setReportID(uint8_t reportID); + +**Parameters** +~~~~~~~~~~~~~~ + +``reportID``: The report ID for the gamepad device, corresponding to the HID report descriptor. + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. important :: HID report ID should start at 1. Some systems may consider a report ID of 0 as invalid. + +.. note :: “USBHIDGamepad.h” must be included to use the class function. + +----------------------------- + +**USBHIDGamepad::gamepadReport** +-------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Send a HID Gamepad report. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void gamepadReport (hid_gamepad_report_t* report); + +.. code:: c++ + + void gamepadReport (uint16_t buttons, uint8_t hat, int16_t x, int16_t y, int16_t z, int16_t Rz, int16_t Rx, int16_t Ry); + +**Parameters** +~~~~~~~~~~~~~~ + +``report``: pointer to gamepad report structure containing data on all inputs + +``buttons``: bitmap indicating state of each button. 1 = pressed, 0 = released. + +``hat``: position of hat switch. Valid values: + + - GAMEPAD_HAT_CENTERED = 0 + + - GAMEPAD_HAT_UP = 1 + + - GAMEPAD_HAT_UP_RIGHT = 2 + + - GAMEPAD_HAT_RIGHT = 3 + + - GAMEPAD_HAT_DOWN_RIGHT = 4 + + - GAMEPAD_HAT_DOWN = 5 + + - GAMEPAD_HAT_DOWN_LEFT = 6 + + - GAMEPAD_HAT_LEFT = 7 + + - GAMEPAD_HAT_UP_LEFT = 8 + +``x``: position of x axis. Integer value from -32767 to 32767. + +``y``: position of y axis. Integer value from -32767 to 32767. + +``z``: position of z axis. Integer value from -32767 to 32767. + +``Rz``: position of Rz axis. Integer value from -32767 to 32767. + +``Rx``: position of Rx axis. Integer value from -32767 to 32767. + +``Ry``: position of Ry axis. Integer value from -32767 to 32767. + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `USBHIDGamepad `_ + +.. note :: “USBHIDGamepad.h” must be included to use the class function. + +------------------------------ + +**USBHIDGamepad::buttonPress** +------------------------------ + +**Description** +~~~~~~~~~~~~~~~ + +Send a HID Gamepad report indicating buttons pressed. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void buttonPress(uint16_t buttons); + +**Parameters** +~~~~~~~~~~~~~~ + +``buttons``: bitmap indicating buttons pressed. 1 = pressed. + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “USBHIDGamepad.h” must be included to use the class function. + +--------------------------------- + +**USBHIDGamepad::buttonRelease** +-------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Send a HID Gamepad report indicating buttons released. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void buttonRelease(uint16_t buttons); + +**Parameters** +~~~~~~~~~~~~~~ + +``buttons``: bitmap indicating buttons released. 1 = released. + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “USBHIDGamepad.h” must be included to use the class function. + +------------------------------------ + +**USBHIDGamepad::buttonReleaseAll** +----------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Send a HID Gamepad report indicating no buttons pressed. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void buttonReleaseAll(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `USBHIDGamepad `_ + +.. note :: “USBHIDGamepad.h” must be included to use the class function. + +-------------------------- + +**USBHIDGamepad::setHat** +------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Send a HID Gamepad report indicating hat switch position. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void setHat(uint8_t hat); + +**Parameters** +~~~~~~~~~~~~~~ + +``hat``: position of hat switch. Valid values: + + - GAMEPAD_HAT_CENTERED = 0 + + - GAMEPAD_HAT_UP = 1 + + - GAMEPAD_HAT_UP_RIGHT = 2 + + - GAMEPAD_HAT_RIGHT = 3 + + - GAMEPAD_HAT_DOWN_RIGHT = 4 + + - GAMEPAD_HAT_DOWN = 5 + + - GAMEPAD_HAT_DOWN_LEFT = 6 + + - GAMEPAD_HAT_LEFT = 7 + + - GAMEPAD_HAT_UP_LEFT = 8 + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “USBHIDGamepad.h” must be included to use the class function. + +----------------------------- + +**USBHIDGamepad::setAxes** +-------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Send a HID Gamepad report indicating position of all axes. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void setAxes(int16_t x, int16_t y, int16_t z, int16_t Rz, int16_t Rx, int16_t Ry); + +**Parameters** +~~~~~~~~~~~~~~ + +``x``: position of x axis. Integer value from -32767 to 32767. + +``y``: position of y axis. Integer value from -32767 to 32767. + +``z``: position of z axis. Integer value from -32767 to 32767. + +``Rz``: position of Rz axis. Integer value from -32767 to 32767. + +``Rx``: position of Rx axis. Integer value from -32767 to 32767. + +``Ry``: position of Ry axis. Integer value from -32767 to 32767. + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `USBHIDGamepad `_ + +.. note :: “USBHIDGamepad.h” must be included to use the class function. + +------------------------------- + +**USBHIDGamepad::setLeftStick** +------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Send a HID Gamepad report indicating position of axes corresponding to left analog stick. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void setLeftStick(int16_t x, int16_t y); + +**Parameters** +~~~~~~~~~~~~~~ + +``x``: position of x axis. Integer value from -32767 to 32767. + +``y``: position of y axis. Integer value from -32767 to 32767. + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “USBHIDGamepad.h” must be included to use the class function. + +------------------------------- + +**USBHIDGamepad::setRightStick** +-------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Send a HID Gamepad report indicating position of axes corresponding to right analog stick. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void setLeftStick(int16_t z, int16_t Rz); + +**Parameters** +~~~~~~~~~~~~~~ + +``z``: position of z axis. Integer value from -32767 to 32767. + +``Rz``: position of Rz axis. Integer value from -32767 to 32767. + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “USBHIDGamepad.h” must be included to use the class function. + +-------------------------------- + +**USBHIDGamepad::setTrigger** +----------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Send a HID Gamepad report indicating position of axes corresponding to triggers. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void setTriggers(int16_t Rx, int16_t Ry); + +**Parameters** +~~~~~~~~~~~~~~ + +``Rx``: position of Rx axis. Integer value from -32767 to 32767. + +``Ry``: position of Ry axis. Integer value from -32767 to 32767. + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “USBHIDGamepad.h” must be included to use the class function. diff --git a/source/_common/ameba_d/API_Documents/USB/Class USBHIDKeyboard.rst b/source/_common/ameba_d/API_Documents/USB/Class USBHIDKeyboard.rst new file mode 100644 index 0000000..54fc113 --- /dev/null +++ b/source/_common/ameba_d/API_Documents/USB/Class USBHIDKeyboard.rst @@ -0,0 +1,452 @@ +Class USBHIDKeyboard +==================== + +.. contents:: + :local: + :depth: 2 + +**USBHIDKeyboard Class** +------------------------ + +**Description** +~~~~~~~~~~~~~~~ + +A class used for creating and managing a USB HID Keyboard. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + class USBHIDKeyboard + +**Members** +~~~~~~~~~~~ + ++------------------------------------+---------------------------------+ +| **Public Constructors** | ++====================================+=================================+ +| USBHIDKeyboard::USBHIDKeyboard | Constructs a USBHIDKeyboard | +| | object | ++------------------------------------+---------------------------------+ +| **Public Methods** | ++------------------------------------+---------------------------------+ +| USBHIDKeyboard::setReportID | Set HID report ID for the HID | +| | Keyboard and HID consumer | +| | control | ++------------------------------------+---------------------------------+ +| USBHIDKeyboard::consumerReport | Send a HID Consumer report | ++------------------------------------+---------------------------------+ +| USBHIDKeyboard::keyboardReport | Send a HID Keyboard report | ++------------------------------------+---------------------------------+ +| USBHIDKeyboard::consumerPress | Send a HID Consumer report | +| | indicating button pressed | ++------------------------------------+---------------------------------+ +| USBHIDKeyboard::consumerRelease | Send a HID Consumer report | +| | indicating button released | ++------------------------------------+---------------------------------+ +| USBHIDKeyboard::keyPress | Send a HID Keyboard report | +| | indicating keys pressed | ++------------------------------------+---------------------------------+ +| USBHIDKeyboard::keyRelease | Send a HID Keyboard report | +| | indicating keys released | ++------------------------------------+---------------------------------+ +| USBHIDKeyboard::keyReleaseAll | Send a HID Keyboard report | +| | indicating no keys pressed | ++------------------------------------+---------------------------------+ +| USBHIDKeyboard::keyCharPress | Send a HID Keyboard report | +| | indicating keys pressed to | +| | output an ASCII character | ++------------------------------------+---------------------------------+ +| USBHIDKeyboard::keySequence | Send a HID Keyboard report | +| | indicating keys pressed to | +| | output an ASCII string | ++------------------------------------+---------------------------------+ + +--------------------------------- + +**USBHIDKeyboard::USBHIDKeyboard** +---------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Constructs a USBHIDKeyboard object. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + USBHIDKeyboard(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `USBHIDKeyboard `_ + +.. note :: “USBHIDKeyboard.h” must be included to use the class function. + +----------------------------- + +**USBHIDKeyboard::setReportID** +------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Set HID report ID for the HID Keyboard and HID consumer control. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void setReportID(uint8_t reportIDKeyboard, uint8_t reportIDConsumer); + +**Parameters** +~~~~~~~~~~~~~~ + +``reportIDKeyboard``: The report ID for the HID keyboard device, corresponding to the HID report descriptor. + +``reportIDConsumer``: The report ID for the HID consumer control device, corresponding to the HID report descriptor. + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “USBHIDKeyboard.h” must be included to use the class function. + +-------------------------------- + +**USBHIDKeyboard::consumerReport** +---------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Send a HID Consumer report. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void consumerReport(uint16_t usage_code); + +**Parameters** +~~~~~~~~~~~~~~ + +``usage_code``: HID consumer control usage code for the button pressed. + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “USBHIDKeyboard.h” must be included to use the class function. + +------------------------------------- + +**USBHIDKeyboard::keyboardReport** +---------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Send a HID Keyboard report. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void keyboardReport(void); + +.. code:: c++ + + void keyboardReport(uint8_t modifiers, uint8_t keycode[6]); + +**Parameters** +~~~~~~~~~~~~~~ + +``modifiers``: bitmap indicating key modifiers pressed (CTRL, ALT, SHIFT). + +``keycode``: byte array indicating keys pressed. + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “USBHIDKeyboard.h” must be included to use the class function. + +------------------------------ + +**USBHIDKeyboard::consumerPress** +--------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Send a HID Consumer report indicating button pressed. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void consumerPress(uint16_t usage_code); + +**Parameters** +~~~~~~~~~~~~~~ + +``usage_code``: HID consumer control usage code for the button pressed. + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “USBHIDKeyboard.h” must be included to use the class function. + +---------------------------------------- + +**USBHIDKeyboard::consumerRelease** +----------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Send a HID Consumer report indicating button released. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void consumerRelease(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `USBHIDKeyboard `_ + +.. note :: “USBHIDKeyboard.h” must be included to use the class function. + +------------------------------------------ + +**USBHIDKeyboard::keyPress** +---------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Send a HID Keyboard report indicating keys pressed. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void keyPress(uint16_t key); + +**Parameters** +~~~~~~~~~~~~~~ + +``key``: HID keycode for key pressed, value ranges from 0x00 to 0xE7. + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `USBHIDKeyboard `_ + +.. note :: “USBHIDKeyboard.h” must be included to use the class function. + +------------------------------ + +**USBHIDKeyboard::keyRelease** +------------------------------ + +**Description** +~~~~~~~~~~~~~~~ + +Send a HID Keyboard report indicating keys released. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void keyRelease(uint16_t key); + +**Parameters** +~~~~~~~~~~~~~~ + +``key``: HID keycode for key pressed, value ranges from 0x00 to 0xE7. + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “USBHIDKeyboard.h” must be included to use the class function. + +----------------------------------- + +**USBHIDKeyboard::keyReleaseAll** +--------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Send a HID Keyboard report indicating no keys pressed. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void keyReleaseAll(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `USBHIDKeyboard `_ + +.. note :: “USBHIDKeyboard.h” must be included to use the class function. + +--------------------------------------- + +**USBHIDKeyboard::keyCharPress** +-------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Send a HID Keyboard report indicating keys pressed to output an ASCII character. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void keyCharPress(char ch); + +**Parameters** +~~~~~~~~~~~~~~ + +``ch``: ASCII character to output. + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “USBHIDKeyboard.h” must be included to use the class function. + +----------------------------------- + +**USBHIDKeyboard::keySequence** +-------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Send a HID Keyboard report indicating keys pressed to output an ASCII string. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void keySequence (const char* str, uint16_t delayTime); + +.. code:: c++ + + void keySequence (String str, uint16_t delayTime); + +**Parameters** +~~~~~~~~~~~~~~ + +``str``: character string to output, expressed as a char array or a String class object + +``delayTime``: time delay between key press and release, in milliseconds. Default value of 5. + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `USBHIDKeyboard `_ + +.. note :: “USBHIDKeyboard.h” must be included to use the class function. diff --git a/source/_common/ameba_d/API_Documents/USB/Class USBHIDMouse.rst b/source/_common/ameba_d/API_Documents/USB/Class USBHIDMouse.rst new file mode 100644 index 0000000..ee5fcb1 --- /dev/null +++ b/source/_common/ameba_d/API_Documents/USB/Class USBHIDMouse.rst @@ -0,0 +1,341 @@ +Class USBHIDMouse +================= + +.. contents:: + :local: + :depth: 2 + +**USBHIDMouse Class** +--------------------- + +**Description** +~~~~~~~~~~~~~~~ + +A class used for creating and managing a USB HID Mouse. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + class USBHIDMouse + +**Members** +~~~~~~~~~~~ + +**Public Constructors** + ++--------------------------------+-------------------------------------+ +| USBHIDMouse::USBHIDMouse | Constructs a USBHIDMouse object | ++--------------------------------+-------------------------------------+ + +**Public Methods** + ++------------------------------------+---------------------------------+ +| USBHIDMouse::setReportID | Set HID report ID for the HID | +| | Mouse | ++------------------------------------+---------------------------------+ +| USBHIDMouse::mouseReport | Send a HID Mouse report | ++------------------------------------+---------------------------------+ +| USBHIDMouse::mousePress | Send a HID Mouse report | +| | indicating buttons pressed | ++------------------------------------+---------------------------------+ +| USBHIDMouse::mouseRelease | Send a HID Mouse report | +| | indicating buttons released | ++------------------------------------+---------------------------------+ +| USBHIDMouse::mouseReleaseAll | Send a HID Mouse report | +| | indicating no buttons pressed | ++------------------------------------+---------------------------------+ +| USBHIDMouse::mouseMove | Send a HID Mouse report | +| | indicating mouse movement | ++------------------------------------+---------------------------------+ +| USBHIDMouse::mouseScroll | Send a HID Mouse report | +| | indicating mouse scroll wheel | +| | movement | ++------------------------------------+---------------------------------+ + +------------------------------- + +**USBHIDMouse::USBHIDMouse** +---------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Constructs a USBHIDMouse object. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + USBHIDMouse(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `USBHIDMouse `_ + +.. note :: “USBHIDMouse.h” must be included to use the class function. + +-------------------------- + +**USBHIDMouse::setReportID** +---------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Set HID report ID for the HID Mouse. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void setReportID(uint8_t reportID); + +**Parameters** +~~~~~~~~~~~~~~ + +``reportID``: The report ID for the HID mouse device, corresponding to the HID report descriptor. + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “USBHIDMouse.h” must be included to use the class function. + +----------------------------- + +**USBHIDMouse::mouseReport** +---------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Send a HID Mouse report. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void mouseReport (hid_mouse_report_t* report); + +.. code:: c++ + + void mouseReport (uint8_t buttons, int8_t x, int8_t y, int8_t scroll); + +**Parameters** +~~~~~~~~~~~~~~ + +``report``: pointer to mouse report structure containing data on mouse inputs + +``buttons``: bitmap indicating state of each button. 1 = pressed, 0 = released. + +``x``: mouse x-axis movement. Integer value from -127 to 127. + +``y``: mouse y-axis movement. Integer value from -127 to 127. + +``scroll``: mouse scroll wheel movement. Integer value from -127 to 127. + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “USBHIDMouse.h” must be included to use the class function. + +--------------------------- + +**USBHIDMouse::mousePress** +--------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Send a HID Mouse report indicating buttons pressed. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void mousePress(uint8_t buttons); + +**Parameters** +~~~~~~~~~~~~~~ + +``buttons``: bitmap indicating buttons pressed. 1 = pressed. + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `USBHIDMouse `_ + +.. note :: “USBHIDMouse.h” must be included to use the class function. + +--------------------------- + +**USBHIDMouse::mouseRelease** +----------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Send a HID Mouse report indicating buttons released. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void mouseRelease(uint8_t buttons); + +**Parameters** +~~~~~~~~~~~~~~ + +``buttons``: bitmap indicating buttons released. 1 = released. + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `USBHIDMouse `_ + +.. note :: “USBHIDMouse.h” must be included to use the class function. + +------------------------------ + +**USBHIDMouse::mouseReleaseAll** +-------------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Send a HID Mouse report indicating no buttons pressed. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void mouseReleaseAll(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “USBHIDMouse.h” must be included to use the class function. + +----------------------------- + +**USBHIDMouse::mouseMove** +-------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Send a HID Mouse report indicating mouse movement. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void mouseMove (int8_t x, int8_t y); + +**Parameters** +~~~~~~~~~~~~~~ + +``x``: mouse x-axis movement. Integer value from -127 to 127. + +``y``: mouse y-axis movement. Integer value from -127 to 127. + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `USBHIDMouse `_ + +.. note :: “USBHIDMouse.h” must be included to use the class function. + +---------------------------- + +**USBHIDMouse::mouseScroll** +---------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Send a HID Mouse report indicating mouse scroll wheel movement. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void mouseScroll(int8_t scroll); + +**Parameters** +~~~~~~~~~~~~~~ + +``scroll``: mouse scroll wheel movement. Integer value from -127 to 127. + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `USBHIDMouse `_ + +.. note :: “USBHIDMouse.h” must be included to use the class function. diff --git a/bak/ambd/_common/API_Documents/USB/index.rst b/source/_common/ameba_d/API_Documents/USB/index.rst similarity index 100% rename from bak/ambd/_common/API_Documents/USB/index.rst rename to source/_common/ameba_d/API_Documents/USB/index.rst diff --git a/bak/ambd/_common/API_Documents/WDT/Class WDT.rst b/source/_common/ameba_d/API_Documents/WDT/Class WDT.rst similarity index 57% rename from bak/ambd/_common/API_Documents/WDT/Class WDT.rst rename to source/_common/ameba_d/API_Documents/WDT/Class WDT.rst index f8f7c21..f505713 100644 --- a/bak/ambd/_common/API_Documents/WDT/Class WDT.rst +++ b/source/_common/ameba_d/API_Documents/WDT/Class WDT.rst @@ -26,30 +26,32 @@ A class used for initializing, starting, stopping watchdog timer. +-----------------------------------+-----------------------------------+ | **Public Constructors** | +===================================+===================================+ -| WDT::WDT | Constructs an WDT object. | +| A public constructor should not be used as this class is intended to | +| be a singleton class. Access member functions using the object | +| instance named WDT. | +-----------------------------------+-----------------------------------+ | **Public Methods** | +-----------------------------------+-----------------------------------+ -| WDT::init | Initialize the watchdog, | +| WDT::InitWatchdog | Initialize the watchdog, | | | including time setting, and mode | | | register. | +-----------------------------------+-----------------------------------+ -| WDT::start | Enable and start the watchdog | +| WDT::StartWatchdog | Enable and start the watchdog | | | timer | +-----------------------------------+-----------------------------------+ -| WDT::stop | Stop the watchdog timer. | +| WDT::StopWatchdog | Stop the watchdog timer. | +-----------------------------------+-----------------------------------+ -| WDT::refresh | Refresh the watchdog timer to | +| WDT::RefreshWatchdog | Refresh the watchdog timer to | | | prevent WDT timeout. | +-----------------------------------+-----------------------------------+ -| WDT::init_irq | Switch the watchdog timer to | +| WDT::InitWatchdogIRQ | Switch the watchdog timer to | | | interrupt mode and register a | | | watchdog timer timeout interrupt | | | handler. | +-----------------------------------+-----------------------------------+ -**WDT::init** -------------- +**WDT::InitWatchdog** +---------------------- **Description** ~~~~~~~~~~~~~~~ @@ -61,12 +63,12 @@ Initialize the watchdog, including time setting, and mode register. .. code-block:: c++ - void init(uint32_t timeout_ms); + void InitWatchdog(uint32_t timeout_ms); **Parameters** ~~~~~~~~~~~~~~ -timeout_ms: the watch-dog timer timeout value in millisecond (ms). The default action after watchdog timer timeout is to reset the whole system. +``timeout_ms``: the watch-dog timer timeout value in millisecond (ms). The default action after watchdog timer timeout is to reset the whole system. **Returns** ~~~~~~~~~~~ @@ -76,12 +78,12 @@ NA **Example Code** ~~~~~~~~~~~~~~~~ -Example: `SimpleWDT `_ +Example: `WatchdogTimer `_ .. note :: "WDT.h" must be included to use the class function. -**WDT::start** --------------- +**WDT::StartWatchdog** +---------------------- **Description** ~~~~~~~~~~~~~~~ @@ -93,7 +95,7 @@ Start the watchdog timer by enabling the WDG state. .. code-block:: c++ - void start(void); + void StartWatchdog(void); **Parameters** ~~~~~~~~~~~~~~ @@ -108,12 +110,12 @@ NA **Example Code** ~~~~~~~~~~~~~~~~ -Example: `SimpleWDT `_ +Example: `WatchdogTimer `_ .. note :: "WDT.h" must be included to use the class function. -**WDT::stop** -------------- +**WDT::StopWatchdog** +--------------------- **Description** ~~~~~~~~~~~~~~~ @@ -125,7 +127,7 @@ Stop the watchdog timer by disabling the WDG state. .. code-block:: c++ - void stop(void); + void StopWatchdog(void); **Parameters** ~~~~~~~~~~~~~~ @@ -140,12 +142,12 @@ NA **Example Code** ~~~~~~~~~~~~~~~~ -Example: `SimpleWDT `_ +Example: `WatchdogTimer `_ .. note :: "WDT.h" must be included to use the class function. -**WDT::refresh** ----------------- +**WDT::RefreshWatchdog** +------------------------ **Description** ~~~~~~~~~~~~~~~ @@ -157,7 +159,7 @@ Clear watchdog timer and refresh to prevent timeout. .. code-block:: c++ - void refresh(void); + void RefreshWatchdog(void); **Parameters** ~~~~~~~~~~~~~~ @@ -172,31 +174,31 @@ NA **Example Code** ~~~~~~~~~~~~~~~~ -Example: `SimpleWDT `_ +Example: `WatchdogTimer `_ .. note :: "WDT.h" must be included to use the class function. -**WDT::init_irq** ------------------ +**WDT::InitWatchdogIRQ** +------------------------ **Description** ~~~~~~~~~~~~~~~ -Switch the watchdog timer to interrupt mode and register a watchdog timer timeout interrupt handler. The interrupt handler will be called when the watchdog timer is timeout. +Switch the watchdog timer to interrupt mode and register a watchdog timer timeout interrupt handler. The interrupt handler will be called when the watchdog timer is timeout. **Syntax** ~~~~~~~~~~ .. code-block:: c++ - void init_irq(wdt_irq_handler handler, uint32_t id); + void InitWatchdogIRQ(wdt_irq_handler handler, uint32_t id); **Parameters** ~~~~~~~~~~~~~~ -handler: the callback function for WDT timeout interrupt. +``handler``: the callback function for WDT timeout interrupt. -id: the parameter for the callback function. +``id``: the parameter for the callback function **Returns** ~~~~~~~~~~~ @@ -206,6 +208,6 @@ NA **Example Code** ~~~~~~~~~~~~~~~~ -Example: `SimpleWDT `_ +Example: `WatchdogTimer `_ .. note :: "WDT.h" must be included to use the class function. diff --git a/bak/ambd/_common/API_Documents/WDT/index.rst b/source/_common/ameba_d/API_Documents/WDT/index.rst similarity index 100% rename from bak/ambd/_common/API_Documents/WDT/index.rst rename to source/_common/ameba_d/API_Documents/WDT/index.rst diff --git a/source/_common/ameba_d/API_Documents/WS2812B/Class WS2812B.rst b/source/_common/ameba_d/API_Documents/WS2812B/Class WS2812B.rst new file mode 100644 index 0000000..7b1a675 --- /dev/null +++ b/source/_common/ameba_d/API_Documents/WS2812B/Class WS2812B.rst @@ -0,0 +1,401 @@ +Class WS2812B +============= + +.. contents:: + :local: + :depth: 2 + +**WS2812B Class** +----------------- + +**Description** +~~~~~~~~~~~~~~~ + +A class for using WS2812B LED with AmebaD. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + class WS2812B + +**Members** +~~~~~~~~~~~ + ++-------------------------------------------+--------------------------+ +| **Public Methods** | ++===========================================+==========================+ +| WS2812B::WS2812B | Constructs a WS2812B | +| | object | ++-------------------------------------------+--------------------------+ +| **Public Methods** | ++-------------------------------------------+--------------------------+ +| WS2812B::begin | Check for correct pin | +| | settings and prepare to | +| | drive the WS2812B | ++-------------------------------------------+--------------------------+ +| WS2812B::show | Pushes the color data | +| | out to the LEDs | ++-------------------------------------------+--------------------------+ +| WS2812B::clear | Clear the memory | ++-------------------------------------------+--------------------------+ +| WS2812B::setLEDCount | Set total number of LED | +| | that will be used and | +| | allocate memory for | +| | all the LEDs | ++-------------------------------------------+--------------------------+ +| WS2812B::setPixelColor | Set the color of a LED | ++-------------------------------------------+--------------------------+ +| WS2812B::fill | Set multiple LEDs with | +| | the same color | ++-------------------------------------------+--------------------------+ +| WS2812B::colorHSV | Convert to RGB values | +| | from HSV | ++-------------------------------------------+--------------------------+ +| WS2812B::rainbow | Fill all the LEDs with | +| | one or more cycle of | +| | hues | ++-------------------------------------------+--------------------------+ + +---------------------- + +**WS2812B::WS2812B** +-------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Constructs a WS2812B object + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + WS2812B(uint8_t input_pin, uint16_t num_leds); + +**Parameters** +~~~~~~~~~~~~~~ + +``input_pin`` : The MOSI pin that is connected to the WS2812B LED. + +``num_leds`` : The number of LEDs that needs to be light up + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `WS2812B_Basics `_ + +.. important :: Only SPI MOSI pin is valid for driving WS2812B LEDs. + +.. note :: “WS2812B.h” must be included to use the class function. + +------------------------ + +**WS2812B::begin** +------------------ + +**Description** +~~~~~~~~~~~~~~~ + +Check for correct pin settings and prepare to drive the WS2812B + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void begin(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `WS2812B_Basics `_ + +.. important :: Only SPI MOSI pin is valid for driving WS2812B LEDs. + +.. note :: “WS2812B.h” must be included to use the class function. + +-------------------- + +**WS2812B::show** +----------------- + +**Description** +~~~~~~~~~~~~~~~ + +Pushes the color data out to the LEDs by initialising SPI pins and revert all the unnecessary SPI pins (MISO, DC and SS) to GPIO function first. Then allocate the RGB data to each LED. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void show(void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `WS2812B_Basics `_ + +.. important :: The amount of time needed to push the color data will increase with more LEDs. + +.. note :: “WS2812B.h” must be included to use the class function. + +---------------------- + +**WS2812B::clear** +------------------ + +**Description** +~~~~~~~~~~~~~~~ + +Clear the memory + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void clear (void); + +**Parameters** +~~~~~~~~~~~~~~ + +NA + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `WS2812B_Patterns `_ + +.. important :: This function only clears the color data from memory. To turn off the LED, please use WS2812B::show(). + +.. note :: “WS2812B.h” must be included to use the class function. + +------------------------------ + +**WS2812B::setLEDCount** +------------------------ + +**Description** +~~~~~~~~~~~~~~~ + +Set the total number of LEDs to be used and allocate memory for all the LEDs. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void setLEDCount(uint16_t num_leds); + +**Parameters** +~~~~~~~~~~~~~~ + +``num_leds``: total number of LEDs to be used + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +NA + +.. note :: “WS2812B.h” must be included to use the class function. + +----------------------------- + +**WS2812B::setPixelColor** +-------------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Verify that memory has been successfully allocated to the LED and set the color. + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void setPixelColor(uint16_t led_Number, uint8_t rColor, uint8_t gColor, uint8_t bColor); + +**Parameters** +~~~~~~~~~~~~~~ + +``led_Number``: The LED number, with 0 being the LED closest to the data input pin + +``rColor``: Red brightness level (Value available from 0-255, 0 indicates LED is off and 255 indicates LED is in the maximum brightness) + +``gColor``: Green brightness level (Value available from 0-255) + +``bColor``: Blue brightness level (Value available from 0-255) + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `WS2812B_Patterns `_ + +.. note :: “WS2812B.h” must be included to use the class function. + +--------------------------- + +**WS2812B::fill** +----------------- + +**Description** +~~~~~~~~~~~~~~~ + +Set multiple LEDs with the same colors + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void fill(uint8_t rColor, uint8_t gColor, uint8_t bColor, uint16_t first, uint16_t count); + +**Parameters** +~~~~~~~~~~~~~~ + +``rColor``: Red brightness level (Value available from 0-255) + +``gColor``: Green brightness level (Value available from 0-255) + +``bColor``: Blue brightness level (Value available from 0-255) + +``first``: The index of the first LED to start filling with color (Default: 0) + +``count``: Total number of LEDs to be set with the color (Default: 0) + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `WS2812B_Basics `_ + +.. important :: If the input parameters “first” and “count” are not provided, the default behaviour would be to fill all the LEDs. + +.. note :: “WS2812B.h” must be included to use the class function. + +--------------------------- + +**WS2812B::colorHSV** +--------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Convert to RGB values from HSV (Hue Saturation Value). + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + uint32_t colorHSV(uint16_t hue, uint8_t sat, uint8_t val); + +**Parameters** +~~~~~~~~~~~~~~ + +``hue``: hue value in 16-bit. (Default: 0, acceptable range from: 0 - 65535, representing one full cycle of the color wheel. Starting from 0 for red, it increments first towards yellow, and on through green, cyan, blue, magenta, and black to red.) + +``sat``: Intensity or purity of the color in 8-bit. (Acceptable range from: 0 - 255, you will get pastel color when value setting is adjusted to the middle) + +``val``: Brightness of a color in 8-bit. (Value available from 0-255) + +**Returns** +~~~~~~~~~~~ + +The function returns the RGB values converted from HSV. + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `WS2812B_Patterns `_ + +.. note :: “WS2812B.h” must be included to use the class function. + +---------------------- + +**WS2812B::rainbow** +-------------------- + +**Description** +~~~~~~~~~~~~~~~ + +Fill all the LEDs with one or more cycle of hues + +**Syntax** +~~~~~~~~~~ + +.. code:: c++ + + void rainbow(uint16_t first_hue, int8_t reps, uint8_t saturation, uint8_t brightness); + +**Parameters** +~~~~~~~~~~~~~~ + +``first_hue``: hue of first LED (Default: 0, acceptable range from: 0 - 65535, representing one full cycle of the color wheel) + +``reps``: number of cycles of the color wheel over the length of the strip. (Default: 1. Negative values can be used to reverse the hue order) + +``saturation``: Intensity or purity of the color in 8-bit. (Default: 255. Acceptable range from: 0 - 255, you will get pastel color when value setting is adjusted to the middle) + +``brightness``: Brightness of a color in 8-bit. (Default: 60. Acceptable range from 0-255) + +**Returns** +~~~~~~~~~~~ + +NA + +**Example Code** +~~~~~~~~~~~~~~~~ + +Example: `WS2812B_Patterns `_ + +.. note :: “WS2812B.h” must be included to use the class function. diff --git a/bak/ambd/_common/API_Documents/WS2812B/index.rst b/source/_common/ameba_d/API_Documents/WS2812B/index.rst similarity index 100% rename from bak/ambd/_common/API_Documents/WS2812B/index.rst rename to source/_common/ameba_d/API_Documents/WS2812B/index.rst diff --git a/bak/ambd/_common/API_Documents/Wire/Class TwoWire.rst b/source/_common/ameba_d/API_Documents/Wire/Class TwoWire.rst similarity index 61% rename from bak/ambd/_common/API_Documents/Wire/Class TwoWire.rst rename to source/_common/ameba_d/API_Documents/Wire/Class TwoWire.rst index 929cc51..b9d1d99 100644 --- a/bak/ambd/_common/API_Documents/Wire/Class TwoWire.rst +++ b/source/_common/ameba_d/API_Documents/Wire/Class TwoWire.rst @@ -60,6 +60,8 @@ A class of I2C API. | TwoWire::slaveWrite | Send data as a slave device | +----------------------------+----------------------------------------+ +--------------------------------- + **TwoWire::TwoWire** -------------------- @@ -73,16 +75,14 @@ Constructs a TwoWire object. .. code-block:: c++ - TwoWire(void *pWireObj, uint32_t dwSDAPin, uint32_t dwSCLPin); + TwoWire(uint32_t dwSDAPin, uint32_t dwSCLPin); **Parameters** ~~~~~~~~~~~~~~ -pWireObj: Pointer to the Wire object. - -dwSDAPin: Pin name (from pinmap) to be set as SDA pin. +``dwSDAPin``: Pin name (from pinmap) to be set as SDA pin. -dwSCLPin: Pin name (from pinmap) to be set as SCL pin. +``dwSCLPin``: Pin name (from pinmap) to be set as SCL pin. **Returns** ~~~~~~~~~~~ @@ -92,10 +92,12 @@ NA **Example Code** ~~~~~~~~~~~~~~~~ -Example: `MasterSendData `_ +Example: `MasterWriter `_ .. note :: "Wire.h" must be included to use the class function. +--------------------------------- + **TwoWire::begin** ------------------ @@ -110,15 +112,19 @@ Initialize I2C master/slave. To use in I2C master, no argument should be passed .. code-block:: c++ void begin (void); + +.. code-block:: c++ + void begin (uint8_t address = 0); + +.. code-block:: c++ + void begin (int address); **Parameters** ~~~~~~~~~~~~~~ -address: Set the I2C slave address value. - -- 0 - 127 +``address``: Set the I2C slave address value. Value should be between 0-127. **Returns** ~~~~~~~~~~~ @@ -128,9 +134,13 @@ NA **Example Code** ~~~~~~~~~~~~~~~~ -Example: `MasterSendData `_ +Example: `MasterWriter `_ + +.. important :: When configured as I2C slave, begin() will also configure and enable I2C interrupt and attach user callback to be used in the I2C interrupt service routine. -.. note :: "Wire.h" must be included to use the class function. When configured as I2C slave, begin() will also configure and enable I2C interrupt and attach user callback to be used in the I2C interrupt service routine. +.. note :: "Wire.h" must be included to use the class function. + +------------------------------ **TwoWire::end** ---------------- @@ -160,10 +170,12 @@ NA **Example Code** ~~~~~~~~~~~~~~~~ -Example: `MasterSendData `_ +Example: `MasterWriter `_ .. note :: "Wire.h" must be included to use the class function. +---------------------------------- + **TwoWire::setClock** --------------------- @@ -182,7 +194,7 @@ Set I2C clock frequency. **Parameters** ~~~~~~~~~~~~~~ -frequency: Set user defined I2C clock frequency (Hz). Default value is 100000. +``frequency``: Set user defined I2C clock frequency. (Default: 100,000 Hz) **Returns** ~~~~~~~~~~~ @@ -192,10 +204,12 @@ NA **Example Code** ~~~~~~~~~~~~~~~~ -Example: `MasterSendData `_ +Example: `MasterWriter `_ .. note :: "Wire.h" must be included to use the class function. +---------------------------------------- + **TwoWire::beginTransmission** ------------------------------ @@ -210,12 +224,15 @@ Begin I2C transmission to device. .. code-block:: c++ void beginTransmission (uint8_t address); + +.. code-block:: c++ + void beginTransmission (int address); **Parameters** ~~~~~~~~~~~~~~ -address: The transmission address. +``address``: The transmission address. **Returns** ~~~~~~~~~~~ @@ -225,7 +242,7 @@ NA **Example Code** ~~~~~~~~~~~~~~~~ -Example: `MasterSendData `_ +Example: `MasterWriter `_ .. note :: "Wire.h" must be included to use the class function. @@ -243,16 +260,15 @@ This function ends a transmission to a peripheral device that was begun by begin .. code-block:: c++ uint8_t endTransmission (uint8_t sendStop); + +.. code-block:: c++ + uint8_t endTransmission (void); **Parameters** ~~~~~~~~~~~~~~ -sendStop: Set to True to end transmission after data is transferred from master to slave, and releasing the I2C bus. Set to False will send a restart keeping the connection active. - -- true (Default value) - -- false +``sendStop``: true or false, set to True to end transmission after data is transferred from master to slave, and releasing the I2C bus. Set to False will send a restart keeping the connection active. (Default: True) **Returns** ~~~~~~~~~~~ @@ -262,11 +278,15 @@ This function returns 0 if successful, else returns 1 indicating error. **Example Code** ~~~~~~~~~~~~~~~~ -Example: `MasterSendData `_ +Example: `MasterWriter `_ + +.. important :: Originally, ‘endTransmission’ was an f(void) function. It has been modified to take one parameter indicating whether a STOP should be performed on the bus. Calling endTransmission(false) allows a sketch to perform a repeated start. -.. note :: Originally, 'endTransmission' was an f(void) function. It has been modified to take one parameter indicating whether a STOP should be performed on the bus. Calling endTransmission(false) allows a sketch to perform a repeated start. If the input parameter is void, this provides backward compatibility with the original definition, and expected behavior, of endTransmission. "Wire.h" must be included to use the class function. +.. caution :: WARNING: Nothing in the library keeps track of whether the bus tenure has been properly ended with a STOP. It is very possible to leave the bus in a hung state if no call to endTransmission(true) is made. Some I2C devices will behave oddly if they do not see a STOP. -.. warning:: Nothing in the library keeps track of whether the bus tenure has been properly ended with a STOP. It is very possible to leave the bus in a hung state if no call to endTransmission(true) is made. Some I2C devices will behave oddly if they do not see a STOP. +.. note :: If the input parameter is void, this provides backward compatibility with the original definition, and expected behavior, of endTransmission. "Wire.h" must be included to use the class function. + +------------------------------- **TwoWire::requestFrom** ------------------------ @@ -282,22 +302,27 @@ I2C master request data sending from I2C slave device. .. code-block:: c++ uint8_t requestFrom (uint8_t address, uint8_t quantity, uint8_t sendStop); + +.. code-block:: c++ + uint8_t requestFrom (uint8_t address, uint8_t quantity); + +.. code-block:: c++ + uint8_t requestFrom(int address, int quantity); + +.. code-block:: c++ + uint8_t requestFrom (int address, int quantity, int sendStop); **Parameters** ~~~~~~~~~~~~~~ -address: The I2C slave address of the device to request bytes from. - -quantity: The number of data (in byte) that to be received from I2C slave device. +``address``: the I2C slave address of the device to request bytes from. -sendStop: Set to True to end transmission after data is transferred from master to slave, and releasing the I2C bus. Set to False will send a restart keeping the connection active. +``quantity``: the number of data (in byte) that to be received from I2C slave device. -- true (Default value) - -- false +``sendStop``: true or false, set to True to end transmission after data is transferred from master to slave, and releasing the I2C bus. Set to False will send a restart keeping the connection active. (Default: True) **Returns** ~~~~~~~~~~~ @@ -307,10 +332,12 @@ This function returns the length of data received as an int if successful, else **Example Code** ~~~~~~~~~~~~~~~~ -Example: `MasterReceiveData `_ +Example: `MasterReader `_ .. note :: "Wire.h" must be included to use the class function. +--------------------------- + **TwoWire::write** ------------------ @@ -325,14 +352,17 @@ Write data to I2C master transmission buffer. .. code-block:: c++ size_t write (uint8_t data); + +.. code-block:: c++ + size_t write (const uint8_t *data, size_t quantity); **Parameters** ~~~~~~~~~~~~~~ -data: The data in 8-bit is to be transmitted from I2C master to slave. +``data``: The data in 8-bit is to be transmitted from I2C master to slave. -quantity: The number of data in 8-bit to be transmitted. +``quantity``: The number of data in 8-bit to be transmitted. **Returns** ~~~~~~~~~~~ @@ -352,10 +382,12 @@ Returns the number of bytes to be transmitted. (Reading this number is optional) **Example Code** ~~~~~~~~~~~~~~~~ -Example: `MasterSendData `_ +Example: `MasterWriter `_ .. note :: "Wire.h" must be included to use the class function. +-------------------------------- + **TwoWire::available** ---------------------- @@ -384,9 +416,13 @@ This function returns the number of bytes available for reading. **Example Code** ~~~~~~~~~~~~~~~~ -Example: `MasterReceiveData `_ +Example: `MasterReader `_ -.. note :: This function should be called on a controller device after a call to requestFrom() or on a peripheral inside the onReceive() handler. available() inherits from the Stream utility class. "Wire.h" must be included to use the class function. +.. important :: This function should be called on a controller device after a call to requestFrom() or on a peripheral inside the onReceive() handler. available() inherits from the Stream utility class. + +.. note :: "Wire.h" must be included to use the class function. + +--------------------------- **TwoWire::read** ----------------- @@ -416,10 +452,12 @@ This function returns the next data in byte read from receiver buffer. **Example Code** ~~~~~~~~~~~~~~~~ -Example: `MasterReceiveData `_ +Example: `MasterReader `_ .. note :: "Wire.h" must be included to use the class function. +---------------------------- + **TwoWire::peek** ----------------- @@ -448,10 +486,12 @@ This function returns the current data read from receiver buffer. Otherwise, "-1 **Example Code** ~~~~~~~~~~~~~~~~ -Example: `MasterReceiveData `_ +Example: `MasterReader `_ .. note :: "Wire.h" must be included to use the class function. +------------------------------ + **TwoWire::flush** ------------------ @@ -484,6 +524,8 @@ NA .. note :: "Wire.h" must be included to use the class function. +------------------------------- + **TwoWire::onReceive** ---------------------- @@ -502,7 +544,7 @@ This function registers a function to be called when a peripheral device receive **Parameters** ~~~~~~~~~~~~~~ -function: The callback function to be called when the peripheral device receives data; this should take a single int parameter (the number of bytes read from the controller device) and return nothing. +``function``: The callback function to be called when the peripheral device receives data; this should take a single int parameter (the number of bytes read from the controller device) and return nothing. **Returns** ~~~~~~~~~~~ @@ -512,10 +554,12 @@ NA **Example Code** ~~~~~~~~~~~~~~~~ -NA +Example: `SlaveReader `_ .. note :: "Wire.h" must be included to use the class function. +------------------------------------ + **TwoWire::onRequest** ---------------------- @@ -534,7 +578,7 @@ This function registers a function to be called when a controller device request **Parameters** ~~~~~~~~~~~~~~ -function: the function to be called, takes no parameters and returns nothing. +``function``: the function to be called, takes no parameters and returns nothing. **Returns** ~~~~~~~~~~~ @@ -544,10 +588,12 @@ NA **Example Code** ~~~~~~~~~~~~~~~~ -NA +Example: `SlaveReader `_ .. note :: "Wire.h" must be included to use the class function. +----------------------------------- + **TwoWire::slaveWrite** ----------------------- @@ -562,15 +608,21 @@ Send data as a slave device, note that this API only work when device is configu .. code-block:: c++ size_t slaveWrite(int buffer); + +.. code-block:: c++ + size_t slaveWrite(char *buffer); + +.. code-block:: c++ + size_t slaveWrite(uint8_t *buffer, size_t len); **Parameters** ~~~~~~~~~~~~~~ -buffer: Data container that can be an integer or a character pointer. +``buffer``: Data container that can be an integer or a character pointer. -Len: The length of the data buffer. +``Len``: The length of the data buffer. **Returns** ~~~~~~~~~~~ @@ -582,4 +634,6 @@ This function returns true if successful, else returns false. NA -.. note :: "Wire.h" must be included to use the class function. This function can only be called if the device is in slave mode and after user has registered a requestEvent using onRequest(). +.. important :: This function can only be called if the device is in slave mode and after user has registered a requestEvent using onRequest(). + +.. note :: "Wire.h" must be included to use the class function. diff --git a/bak/ambd/_common/API_Documents/Wire/index.rst b/source/_common/ameba_d/API_Documents/Wire/index.rst similarity index 100% rename from bak/ambd/_common/API_Documents/Wire/index.rst rename to source/_common/ameba_d/API_Documents/Wire/index.rst diff --git a/source/_common/ameba_d/Example_Guides/BLE/BLE - Battery Client.rst b/source/_common/ameba_d/Example_Guides/BLE/BLE - Battery Client.rst new file mode 100644 index 0000000..b78e606 --- /dev/null +++ b/source/_common/ameba_d/Example_Guides/BLE/BLE - Battery Client.rst @@ -0,0 +1,67 @@ +BLE - Battery Client +==================== + +.. contents:: + :local: + :depth: 2 + +Materials +--------- + +- AmebaD [AMB21 / AMB22 / AMB23 / AMB25 / AMB26 / BW16 / AW-CU488 Thing Plus] x 1 + +Example +------- + +Introduction +~~~~~~~~~~~~ + +BLE connections use a server client model. The server contains the data +of interest, while the client connects to the server to read the data. +Commonly, a Bluetooth peripheral device acts as a server, while a +Bluetooth central device acts as a client. Servers can contain many +services, with each service containing a some set of data. Clients can +send requests to read or write some data and can also subscribe to +notifications so that the server can send data updates to a client. + +In this example, a basic battery client is set up on the Ameba Bluetooth +stack. The client connects to another Ameba board running the +corresponding BLE battery service to read the battery level data. + +Procedure +~~~~~~~~~ + +On the first Ameba board, upload the BLEBatteryService example code and +let it run. + +For the second Ameba board, open the example ``“Files” → “Examples” → “AmebaBLE” → “BLEBatteryClient”``. + +|image01| + +Upload the code and press the reset button on Ameba once the upload is finished. + +Open the serial monitor and observe the log messages as the Ameba board with the battery client scans, connects, and reads data from the Ameba board with the battery service. + +|image02| + +Highlighted in yellow, the Ameba board with the battery client first scans for advertising BLE devices with the advertised device name “AMEBA_BLE_DEV” and the advertised service UUID of 0x180F representing the battery service. +After finding the target device, the Ameba board with the battery client forms a BLE connection and searches for a battery service on the connected device, highlighted in blue. +With the client connected to the service, the battery client begins to read data using both regular data reads and notifications, highlighted in green. + +Code Reference +-------------- + +BLEClient is used to create a client object to discover services and characteristics on the connected device. + + ``setNotifyCallback()`` is used to register a function that will be called when a battery level notification is received. + + ``BLE.configClient()`` is used to configure the Bluetooth stack for client peration. + + ``addClient(connID)`` creates a new BLEClient object that corresponds to the connected device. + +.. |image01| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_Battery_Client/image01.png + :width: 832 px + :height: 1006 px +.. |image02| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_Battery_Client/image02.png + :width: 741 px + :height: 588 px diff --git a/source/_common/ameba_d/Example_Guides/BLE/BLE - Battery Service.rst b/source/_common/ameba_d/Example_Guides/BLE/BLE - Battery Service.rst new file mode 100644 index 0000000..9babb0a --- /dev/null +++ b/source/_common/ameba_d/Example_Guides/BLE/BLE - Battery Service.rst @@ -0,0 +1,94 @@ +BLE - BLE Battery Service +========================= + +.. contents:: + :local: + :depth: 2 + +Materials +--------- + +- AmebaD [AMB21 / AMB22 / AMB23 / AMB25 / AMB26 / BW16 / AW-CU488 Thing Plus] x 1 + +- Android / iOS mobile phone + +Example +------- + +Introduction +~~~~~~~~~~~~ + +BLE connections use a server client model. The server contains the data of interest, while the client connects to the server to read the data. Commonly, a Bluetooth peripheral device acts as a server, while a Bluetooth central device acts as a client. Servers can contain many services, with each service containing a some set of data. Clients can send requests to read or write some data and can also subscribe to notifications so that the server can send data updates to a client. + +In this example, a basic battery service is set up on the Ameba Bluetooth stack. A mobile phone is used to connect to the Ameba peripheral device and read the battery data. + +Procedure +~~~~~~~~~ + + +Ensure that the following Bluetooth apps are installed on your mobile phone. These apps will show you the raw data sent by Ameba and allow you to interact with the data. +The recommended application is nRF connect, and is available at the links below: + +- Android: https://play.google.com/store/apps/details?id=no.nordicsemi.android.mcp + +- iOS: https://apps.apple.com/us/app/nrf-connect/id1054362403 + +LightBlue is an alternative application that can also be used, but has less features: + +- Android: https://play.google.com/store/apps/details?id=com.punchthrough.lightblueexplorer + +- iOS: https://apps.apple.com/us/app/lightblue/id557428110 + +Open the example, ``“Files” → “Examples” → “AmebaBLE” → “BLEBatteryService”`` + +|image01| + +Upload the code and press the reset button on Ameba once the upload is finished. +On your mobile phone, open the Bluetooth app and scan for the Bluetooth signal broadcast by Ameba, it should appear as a device named “AMEBA_BLE_DEV”. + +|image02| + +Connect to the Ameba Bluetooth device, and a list of available services should appear. Click on the battery service to expand it, and you can see the battery level data value. The arrows highlighted in the box on the right are used to read data and subscribe to notifications. Click on the single arrow to read the battery level value, and a 90% value will appear. + +|image03| + +Click on the triple arrow to subscribe to updates on the battery level value, and the battery value will start updating by itself. + +|image04| + +The serial monitor will show the sketch increasing the battery level every second. When you click on either of the arrows, the sketch running on the Ameba will be notified, and will print out the action taken. + +|image05| + +Code Reference +-------------- + +BLEService and BLECharacteristic classes are used to create and define the battery service to run on the Bluetooth device. + +``BLE.configAdvert()->setAdvType(GAP_ADTYPE_ADV_IND)`` is used to set the advertisement type to a general undirected advertisement that allows for connections. + +``setReadCallback() and setCCCDCallback()`` is used to register functions that will be called when the battery level data is read, or notification is enabled by the user. + +``BLE.configServer(1)`` is used to tell the Bluetooth stack that there will be one service running. + +``addService()`` registers the battery service to the Bluetooth stack. + +.. |image01| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_Battery_Service/image01.png + :width: 1058 px + :height: 972 px + :scale: 80% +.. |image02| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_Battery_Service/image02.png + :width: 1440 px + :height: 2880 px + :scale: 30% +.. |image03| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_Battery_Service/image03.png + :width: 1440 px + :height: 2880 px + :scale: 30% +.. |image04| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_Battery_Service/image04.png + :width: 1440 px + :height: 2880 px + :scale: 30% +.. |image05| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_Battery_Service/image05.png + :width: 749 px + :height: 509 px diff --git a/source/_common/ameba_d/Example_Guides/BLE/BLE - Beacon.rst b/source/_common/ameba_d/Example_Guides/BLE/BLE - Beacon.rst new file mode 100644 index 0000000..177e75f --- /dev/null +++ b/source/_common/ameba_d/Example_Guides/BLE/BLE - Beacon.rst @@ -0,0 +1,78 @@ +BLE - BLE Beacon +================ + +.. contents:: + :local: + :depth: 2 + +Materials +--------- + +- AmebaD [AMB21 / AMB22 / AMB23 / AMB25 / AMB26 / BW16 / AW-CU488 Thing Plus] x 1 + +- Android / iOS mobile phone + +Example +------- + +Introduction +~~~~~~~~~~~~ + +A BLE beacon broadcasts its identity to nearby Bluetooth devices, to enable the other devices to determine their location relative to the beacon, and to perform actions based on information broadcasted by the beacon. +Example applications of beacons include indoor positioning system, location-based advertising and more. +From the definition of its purpose as a broadcast device, a BLE beacon thus cannot be connected to, and can only send information in its Bluetooth advertisement packets. +There are several BLE beacon protocols. The Ameba BLEBeacon library supports the iBeacon and AltBeacon protocols. + +Procedure +~~~~~~~~~ + +Ensure that the following Bluetooth apps are installed on your mobile phone. These apps will show you the raw data sent by Ameba and allow you to interact with the data. +The recommended application is nRF connect, and is available at the links below: + + +- Android: https://play.google.com/store/apps/details?id=no.nordicsemi.android.mcp + +- iOS: https://apps.apple.com/us/app/nrf-connect/id1054362403 + +LightBlue is an alternative application that can also be used, but has less features: + +- Android https://play.google.com/store/apps/details?id=com.punchthrough.lightblueexplorer + +- iOS: https://apps.apple.com/us/app/lightblue/id557428110 + +Open the example, ``“Files” → “Examples” → “AmebaBLE” → “BLEBeacon”`` + +|image01| + +Upload the code and press the reset button on Ameba once the upload is finished. + +On your mobile phone, open the Bluetooth app and scan for the beacon signal broadcast by Ameba. + +|image02| + +If you happen to be in an environment with multiple BLE beacons, you can tap the entries to expand them, and verify that the beacon data is identical to the data in the sketch. + +Code Reference +-------------- + +``setRssi()`` is used to set the received signal strength indicator (rssi) data field for a beacon. The specification states that this should be the received signal strength from the beacon at a 1 meter distance. With no method to measure this, it is set to -65dBm as an estimate. + +``setMajor()`` and ``setMinor()`` are used to set the two data fields. The purpose of these data are left for the manufacturer of the beacon to define, and can be used in any way. + +``setUUID()`` is used to give the beacon a universally unique identifier (UUID). This is a 128-bit number usually expressed as a hexadecimal string. It is used to identify each unique beacon, and can be randomly generated for free online. + +The BLEBeacon library includes both iBeacon and AltBeacon classes, replace line 6 iBeacon with altBeacon to create an AltBeacon instead. The data fields are mostly the same, with only minor changes, please look at the header files for more details. + +``BLE.init()`` is used to allocate memory and prepare Ameba for starting the Bluetooth stack. + +``BLE.configAdvert()`` is used to configure the Bluetooth advertisement settings, to which we pass the beacon data and set the device as non-connectable. + +``BLE.beginPeripheral()`` starts Ameba in Bluetooth peripheral mode, after which it will begin to advertise with the beacon data provided. + +.. |image01| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_Beacon/image01.png + :width: 722 px + :height: 1006 px +.. |image02| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_Beacon/image02.png + :width: 1440 px + :height: 2880 px + :scale: 60% diff --git a/source/_common/ameba_d/Example_Guides/BLE/BLE - DHT over BLE UART.rst b/source/_common/ameba_d/Example_Guides/BLE/BLE - DHT over BLE UART.rst new file mode 100644 index 0000000..cbd73c1 --- /dev/null +++ b/source/_common/ameba_d/Example_Guides/BLE/BLE - DHT over BLE UART.rst @@ -0,0 +1,147 @@ +BLE - DHT over BLE UART +======================= + +.. contents:: + :local: + :depth: 2 + +Materials +--------- + +- AmebaD [AMB21 / AMB22 / AMB23 / AMB25 / AMB26 / BW16 / AW-CU488 Thing Plus] x 1 + +- Android / iOS mobile phone + +Example +------- + +Introduction +~~~~~~~~~~~~ + +In this example, the data obtained from a DHT temperature and humidity sensor are transmitted over a BLE UART service to a smartphone. Refer to the other examples for detailed explanations of using the DHT sensor and the BLE UART service. + +Procedure +~~~~~~~~~ + +Take note that if you are using a DHT sensor that is not mounted on a PCB, you will have to add in a 10K Ohm pull up resistor. + +Connect the DHT sensor to the Ameba board following the diagram. + +.. only:: amb21 + +**AMB21 / AMB22:** + +|image01| + +.. only:: end amb21 + +.. only:: amb23 + +**AMB23:** + +|image02| + +.. only:: end amb23 + +.. only:: bw16-typeb + +**BW16:** + +|image03| + +.. only:: end bw16-typeb + +.. only:: bw16-typec + +**BW16-TypeC:** + +|image04| + +.. only:: end bw16-typec + +.. only:: aw-cu488 + +**AW-CU488 Thing Plus:** + +|image05| + +.. only:: end aw-cu488 + +.. only:: amb25 + +**AMB25:** + +|image06| + +.. only:: end amb25 + +.. only:: amb26 + +**AMB26:** + +|image06| + +.. only:: end amb26 + +Ensure that a compatible BLE UART app is installed on your smartphone, +it is available at: + +- Google Play Store: + +https://play.google.com/store/apps/details?id=com.adafruit.bluefruit.le.connect + +https://play.google.com/store/apps/details?id=de.kai_morich.serial_bluetooth_terminal + +- Apple App Store: + +https://apps.apple.com/us/app/bluefruit-connect/id830125974 + + +Open the example, ``“Files” → “Examples” → “AmebaBLE” → “DHT_over_BLEUart”``. + +|image07| + +Upload the code and press the reset button on Ameba once the upload is finished. +Open the app on your smartphone, scan and connect to the Ameba board shown as “AMEBA_BLE_DEV” and choose the UART function in the app. + +|image08| + +|image09| + +After starting the UART function, notifications should be received every 5 seconds containing the measured temperature and humidity. + +|image10| + +.. |image01| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_DHT_over_BLE_UART/image01.png + :width: 943 px + :height: 762 px +.. |image02| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_DHT_over_BLE_UART/image02.png + :width: 797 px + :height: 756 px +.. |image03| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_DHT_over_BLE_UART/image03.png + :width: 935 px + :height: 692 px +.. |image04| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_DHT_over_BLE_UART/image04.png + :width: 863 px + :height: 731 px +.. |image05| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_DHT_over_BLE_UART/image05.png + :width: 591 px + :height: 792 px +.. |image06| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_DHT_over_BLE_UART/image06.png + :width: 492 px + :height: 469 px +.. |image07| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_DHT_over_BLE_UART/image07.png + :width: 602 px + :height: 558 px +.. |image08| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_DHT_over_BLE_UART/image08.png + :width: 1440 px + :height: 2880 px + :scale: 30% +.. |image09| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_DHT_over_BLE_UART/image09.png + :width: 1440 px + :height: 2880 px + :scale: 30% +.. |image10| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_DHT_over_BLE_UART/image10.png + :width: 1440 px + :height: 2880 px + :scale: 30% diff --git a/source/_common/ameba_d/Example_Guides/BLE/BLE - HID Gamepad.rst b/source/_common/ameba_d/Example_Guides/BLE/BLE - HID Gamepad.rst new file mode 100644 index 0000000..da2faae --- /dev/null +++ b/source/_common/ameba_d/Example_Guides/BLE/BLE - HID Gamepad.rst @@ -0,0 +1,93 @@ +BLE - HID Gamepad +================= + +.. contents:: + :local: + :depth: 2 + +Materials +--------- + +- AmebaD [AMB21 / AMB22 / AMB23 / AMB25 / AMB26 / BW16 / AW-CU488 Thing Plus] x 1 + +- BLE capable host device [Windows / Linux / MacOS / Android] + +Example +------- + +Introduction +~~~~~~~~~~~~ + +In this example, the AmebaD board emulates a HID gamepad connected using BLE. + +Procedure +~~~~~~~~~ + +Open the example, ``“Files” → “Examples” → “AmebaBLE” → BLEHIDGamepad``. + +|image01| + +Upload the code and press the reset button once the upload is finished. + +Immediately after reset, the board will begin BLE advertising as “AMEBA_BLE_HID”. On your host device, go to the Bluetooth settings menu, scan, and connect to the board. + +You should ensure that the connection process is completed before proceeding. + +On Windows, ensure that any driver installation is finished, and the board shows up in the Bluetooth menu under the “Mouse, keyboard & pen” category. + +|image02| + +On Android, ensure that “Input device” is enabled for the board. + +|image03| + +After the Bluetooth connection process is completed, the board is ready to send gamepad input to the host device. Connect digital pin 8 to 3.3V to start sending input, and connect to GND to stop. + +On Windows, gamepad input can also be viewed by going to “Control Panel” -> “Devices and Printers” -> “AMEBA_BLE_HID” -> “Game Controller Settings” -> “Properties”. The buttons and axes should also show changing values here. + +|image04| + +|image05| + +To view the input, open a browser window and go to https://gamepad-tester.com/. The connected gamepad device should show up here, and some of the buttons and axes should show changing values. + +On Android, gamepad testing apps such as `Android Gamepad Tester `_ +can also be used to view the gamepad input. + +|image06| + +On Android, gamepad testing apps such as https://play.google.com/store/apps/details?id=com.chimera.saturday.evogamepadtester can also be used to view the gamepad input. + +|image07| + +Code Reference +-------------- + +By default, the board emulates a gamepad with an 8-direction hat switch (d-pad), 6 analog axes and 16 buttons. How the inputs are interpreted is dependent on the host device, and the button ordering may differ between devices. Also, some axes or buttons may be disabled or missing on certain host devices. + +.. |image01| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_HID_Gamepad/image01.png + :width: 637 px + :height: 1202 px +.. |image02| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_HID_Gamepad/image02.png + :width: 2560 px + :height: 1395 px + :scale: 30% +.. |image03| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_HID_Gamepad/image03.png + :width: 1440 px + :height: 2880 px + :scale: 30% +.. |image04| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_HID_Gamepad/image04.png + :width: 1006 px + :height: 585 px + :scale: 80% +.. |image05| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_HID_Gamepad/image05.png + :width: 952 px + :height: 658 px +.. |image06| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_HID_Gamepad/image06.png + :width: 952 px + :height: 658 px +.. |image07| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_HID_Gamepad/image07.png + :width: 2880 px + :height: 1440 px + :scale: 30% + \ No newline at end of file diff --git a/source/_common/ameba_d/Example_Guides/BLE/BLE - HID Keyboard.rst b/source/_common/ameba_d/Example_Guides/BLE/BLE - HID Keyboard.rst new file mode 100644 index 0000000..124c3d9 --- /dev/null +++ b/source/_common/ameba_d/Example_Guides/BLE/BLE - HID Keyboard.rst @@ -0,0 +1,63 @@ +BLE - HID Keyboard +================== + +.. contents:: + :local: + :depth: 2 + +Materials +--------- + +- AmebaD [AMB21 / AMB22 / AMB23 / AMB25 / AMB26 / BW16 / AW-CU488 Thing Plus] x 1 + +- BLE capable host device [Windows / Linux / MacOS / Android] + +Example +------- + +Introduction +~~~~~~~~~~~~ + +In this example, the RTL8722 board emulates a HID keyboard connected using BLE. + +Procedure +~~~~~~~~~ + +Open the example, ``“Files” -> “Examples” -> “AmebaBLE” -> BLEHIDKeyboard``. + +|image01| + +Upload the code and press the reset button once the upload is finished. + +Immediately after reset, the board will begin BLE advertising as “AMEBA_BLE_HID”. On your host device, go to the Bluetooth settings menu, scan, and connect to the board. + +You should ensure that the connection process is completed before proceeding. + +On Windows, ensure that any driver installation is finished, and the board shows up in the Bluetooth menu under the “Mouse, keyboard & pen” category. + +|image02| + +On Android, ensure that “Input device” is enabled for the board. + +|image03| + +After the Bluetooth connection process is completed, the board is ready to send keyboard input to the host device. Select a text input field, such as in the Serial Monitor or a text document. Connect digital pin 8 to 3.3V to start sending keystrokes, connect to GND to stop. + +You should see the text “Hello World !” typed out and deleted repeatedly. + +|image04| + +.. |image01| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_HID_Keyboard/image01.png + :width: 637 px + :height: 1202 px +.. |image02| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_HID_Keyboard/image02.png + :width: 2560 px + :height: 1395 px + :scale: 30% +.. |image03| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_HID_Keyboard/image03.png + :width: 1440 px + :height: 2880 px + :scale: 30% +.. |image04| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_HID_Keyboard/image04.png + :width: 753 px + :height: 596 px diff --git a/source/_common/ameba_d/Example_Guides/BLE/BLE - HID Mouse.rst b/source/_common/ameba_d/Example_Guides/BLE/BLE - HID Mouse.rst new file mode 100644 index 0000000..515157a --- /dev/null +++ b/source/_common/ameba_d/Example_Guides/BLE/BLE - HID Mouse.rst @@ -0,0 +1,65 @@ +BLE - HID Mouse +=============== + +.. contents:: + :local: + :depth: 2 + +Materials +--------- + +- AmebaD [AMB21 / AMB22 / AMB23 / AMB25 / AMB26 / BW16 / AW-CU488 Thing Plus] x 1 + +- BLE capable host device [Windows / Linux / MacOS / Android] + +Example +------- + +Introduction +~~~~~~~~~~~~ + +In this example, the RTL8722 board emulates a HID mouse connected using BLE. + +Procedure +~~~~~~~~~ + +Open the example, ``“Files” → “Examples” → “AmebaBLE” → “BLEHIDMouse”``. + +|image01| + +Upload the code and press the reset button once the upload is finished. + +Immediately after reset, the board will begin BLE advertising as “AMEBA_BLE_HID”. On your host device, go to the Bluetooth settings menu, scan, and connect to the board. + +You should ensure that the connection process is completed before proceeding. + +On Windows, ensure that any driver installation is finished, and the board shows up in the Bluetooth menu under the “Mouse, keyboard & pen” category. + +|image02| + +On Android, ensure that “Input device” is enabled for the board. + +|image03| + +After the Bluetooth connection process is completed, the board is ready to send mouse input to the host device. Connect digital pin 8 to 3.3V to start sending input, connect to GND to stop. + +You should see the mouse cursor move around four points in a square, performing right and left clicks, and scrolling up and down + +Code Reference +-------------- + +How the mouse input is interpreted is dependent on the host system. + +Some systems, such as mobile operating systems, may not support all mouse button input functions. + +.. |image01| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_HID_Mouse/image01.png + :width: 637 px + :height: 1202 px +.. |image02| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_HID_Mouse/image02.png + :width: 2560 px + :height: 1395 px + :scale: 30% +.. |image03| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_HID_Mouse/image03.png + :width: 1440 px + :height: 2880 px + :scale: 30% diff --git a/source/_common/ameba_d/Example_Guides/BLE/BLE - PWM over BLE UART.rst b/source/_common/ameba_d/Example_Guides/BLE/BLE - PWM over BLE UART.rst new file mode 100644 index 0000000..3299de0 --- /dev/null +++ b/source/_common/ameba_d/Example_Guides/BLE/BLE - PWM over BLE UART.rst @@ -0,0 +1,159 @@ +BLE - PWM over BLE UART +======================= + +.. contents:: + :local: + :depth: 2 + +Materials +--------- + +- AmebaD [AMB21 / AMB22 / AMB23 / AMB25 / AMB26 / BW16 / AW-CU488 Thing Plus] x 1 + +- RGB LED + +- Android / iOS smartphone + +Example +------- + +Introduction +~~~~~~~~~~~~ + +In this example, a smartphone app is used to transmit commands over BLE UART to control the PWM outputs and change the color of a RGB LED. Refer to the other example guides for detailed explanations of the BLE UART service. + +Procedure +~~~~~~~~~ + +Connect the RGB LED to the AmebaD board following the diagram, the common LED pin may need to connect to 3.3V or GND depending on the type of LED (common anode / common cathode). + +.. only:: amb21 + +**AMB21 / AMB22:** + +|image01| + +.. only:: end amb21 + +.. only:: amb23 + +**AMB23:** + +|image02| + +.. only:: end amb23 + +.. only:: bw16-typeb + +**BW16:** + +|image03| + +.. only:: end bw16-typeb + +.. only:: bw16-typec + +**BW16-TypeC:** + +|image04| + +.. only:: end bw16-typec + +.. only:: aw-cu488 + +**AW-CU488 Thing Plus:** + +|image05| + +.. only:: end aw-cu488 + +.. only:: amb25 + +**AMB25:** + +|image06| + +.. only:: end amb25 + +.. only:: amb26 + +**AMB26:** + +|image06| + +.. only:: end amb26 + +Ensure that the required app is installed on your smartphone, it is available at: + +- Google Play Store: + +https://play.google.com/store/apps/details?id=com.adafruit.bluefruit.le.connect + +- Apple App Store: + +https://apps.apple.com/us/app/bluefruit-connect/id830125974 + +Open the example, "Files" -> "Examples" -> “AmebaBLE” -> “PWM_over_BLEUart”. + +Upload the code and press the reset button on Ameba once the upload is finished. + +|image07| + +Open the app on your smartphone, scan and connect to the board shown as “AMEBA_BLE_DEV” and choose the controller -> color picker function in the app. + +|image08| + +|image09| + +|image10| + +Using the color selection wheel, saturation, and brightness sliders, choose a desired color and click select to send the RGB values to the board. You should see the RGB LED change to the matching color. + +|image11| + +Code Reference +-------------- + +The RGB values are sent as three consecutive bytes prefixed by “!C” characters. The “!” exclamation mark is used to indicate that the following data is a command, and the “C” character is used to indicate that the data is RGB values. The received UART message is checked in the callback function for “!C” first, otherwise it is treated as a regular message and printed to the serial terminal. + +.. |image01| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_PWM_over_BLE_UART/image01.png + :width: 1383 px + :height: 1048 px + :scale: 60% +.. |image02| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_PWM_over_BLE_UART/image02.png + :width: 1012 px + :height: 699 px + :scale: 80% +.. |image03| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_PWM_over_BLE_UART/image03.png + :width: 1564 px + :height: 1079 px + :scale: 50% +.. |image04| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_PWM_over_BLE_UART/image04.png + :width: 1058 px + :height: 715 px + :scale: 80% +.. |image05| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_PWM_over_BLE_UART/image05.png + :width: 591 px + :height: 792 px +.. |image06| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_PWM_over_BLE_UART/image06.png + :width: 377 px + :height: 299 px +.. |image07| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_PWM_over_BLE_UART/image07.png + :width: 682 px + :height: 1202 px +.. |image08| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_PWM_over_BLE_UART/image08.png + :width: 1440 px + :height: 2880 px + :scale: 30% +.. |image09| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_PWM_over_BLE_UART/image09.png + :width: 1440 px + :height: 2880 px + :scale: 30% +.. |image10| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_PWM_over_BLE_UART/image10.png + :width: 1440 px + :height: 2880 px + :scale: 30% +.. |image11| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_PWM_over_BLE_UART/image11.png + :width: 1440 px + :height: 2880 px + :scale: 30% diff --git a/source/_common/ameba_d/Example_Guides/BLE/BLE - Scan.rst b/source/_common/ameba_d/Example_Guides/BLE/BLE - Scan.rst new file mode 100644 index 0000000..151b08c --- /dev/null +++ b/source/_common/ameba_d/Example_Guides/BLE/BLE - Scan.rst @@ -0,0 +1,56 @@ +BLE - BLE Scan +============== + +.. contents:: + :local: + :depth: 2 + +Materials +--------- + +- AmebaD [AMB21 / AMB22 / AMB23 / AMB25 / AMB26 / BW16 / AW-CU488 Thing Plus] x 1 + +- Android / iOS mobile phone + +Example +------- + +Introduction +~~~~~~~~~~~~ + +This example configures the Ameba as a Bluetooth central device, uses the scan functionality to scan for other Bluetooth devices, and prints out the results to the serial monitor. + +Procedure +~~~~~~~~~ + +Open the example, ``“Files” → “Examples” → “AmebaBLE” → “BLEScan”`` + +|image01| + +Upload the code and press the reset button on Ameba once the upload is finished. +Open the Arduino serial monitor, and you should see the scan results of nearby Bluetooth devices formatted and printed out. + +|image02| + +If you have the Bluetooth app nRF Connect installed, you can also use it to send out Bluetooth advertisements for the Ameba to pick up. + +Code Reference +-------------- + +``setScanMode(GAP_SCAN_MODE_ACTIVE)`` is used to set the scan mode. Active scanning will request for an additional scan response data packet from a device when it is found. Passive scanning will only look at the advertisement data, and not request for additional data. + +``setScanInterval()`` and ``setScanWindow()`` are used to set the frequency and duration of scans in milliseconds. A scan will start every interval duration, and each scan will last for the scan window duration. The scan window duration should be lesser or equal to the scan interval. Set a short interval to discover devices rapidly, set a long interval to conserve power. + +``setScanCallback(scanFunction)`` is used to register a function to be called when scan results are received. This can be used to set a user function for additional processing of scan data, such as looking for a specific device. If no function is registered, the scan results are formatted and printed to the serial monitor by default. + +``beginCentral(0)`` is used to start the Bluetooth stack in Central mode. The argument 0 is used to indicate that no clients will be operating in central mode. + +``startScan(5000)`` is used to start the scanning process for a specified duration of 5000 milliseconds. The scan will repeat according to the set scan interval and scan window values. After 5000 milliseconds, the scan process will stop, and will be ready to be started again. + + +.. |image01| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_Scan/image01.png + :width: 711 px + :height: 1006 px +.. |image02| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_Scan/image02.png + :width: 757 px + :height: 907 px diff --git a/source/_common/ameba_d/Example_Guides/BLE/BLE - UART Client.rst b/source/_common/ameba_d/Example_Guides/BLE/BLE - UART Client.rst new file mode 100644 index 0000000..ab69895 --- /dev/null +++ b/source/_common/ameba_d/Example_Guides/BLE/BLE - UART Client.rst @@ -0,0 +1,44 @@ +BLE - BLE UART Client +===================== + +.. contents:: + :local: + :depth: 2 + +Materials +--------- + +- AmebaD [AMB21 / AMB22 / AMB23 / AMB25 / AMB26 / BW16 / AW-CU488 Thing Plus] x 2 + +Example +------- + +Introduction +~~~~~~~~~~~~ + +In this example, two AmebaD boards are connected using BLE. One board runs a BLE UART service, while the other connects to the service using a client and both boards are able to communicate with text messages over the UART service. + +Procedure +~~~~~~~~~ + +On the first board, upload the BLE UART service example code. Refer to the example guide for detailed instructions. +For the second board, open the example, ``“Files” → “Examples” → “AmebaBLE” → “BLEUartClient”``. + +|image01| + +Upload the code and press the reset button on Ameba once the upload is finished. +Reset the UART service board first, wait for the BLE advertisement process to begin, and reset the UART client board. The client board should scan, discover, and connect to the service board. After connecting, the client board will verify that the correct UART service exists on the service board, before enabling notifications on the TX characteristic. Any message typed in the serial terminal will be sent to the other board using the UART service. + +|image02| + +Code Reference +-------------- + +The BLEClient class is used to discover the services that exist on a connected BLE device. The discovery process will create BLERemoteService, BLERemoteCharacteristic and BLERemoteDescriptor objects corresponding to the services, characteristics and descriptors that exist on the connected device. These objects can then be used to read and write data to the connected device. + +.. |image01| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_UART_Client/image01.png + :width: 682 px + :height: 1202 px +.. |image02| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_UART_Client/image02.png + :width: 779 px + :height: 619 px diff --git a/source/_common/ameba_d/Example_Guides/BLE/BLE - UART Service.rst b/source/_common/ameba_d/Example_Guides/BLE/BLE - UART Service.rst new file mode 100644 index 0000000..a1afcfe --- /dev/null +++ b/source/_common/ameba_d/Example_Guides/BLE/BLE - UART Service.rst @@ -0,0 +1,85 @@ +BLE - BLE UART Service +====================== + +.. contents:: + :local: + :depth: 2 + +Materials +--------- + +- AmebaD [AMB21 / AMB22 / AMB23 / AMB25 / AMB26 / BW16 / AW-CU488 Thing Plus] x 1 + +- Android / iOS mobile phone + +Example +------- + +Introduction +~~~~~~~~~~~~ + +With BLE, application data is sent and received using the GATT system. GATT uses services, characteristics, and attributes to organise data and control how the data can be read from and written to. The Bluetooth SIG specification for BLE includes several predefined services for common applications, but users are free to implement custom services and characteristics to best fit their data structure and application needs + +In this example, the BLEService and BLECharacteristic classes are used to implement a custom service for transmitting ASCII characters similar to regular UART. This custom service is the Nordic UART Service, which is supported in several smartphone apps. + +Procedure +~~~~~~~~~ + +Ensure that a compatible BLE UART app is installed on your smartphone, it is available at: + +- Google Play Store: + +https://play.google.com/store/apps/details?id=com.adafruit.bluefruit.le.connect + +https://play.google.com/store/apps/details?id=de.kai_morich.serial_bluetooth_terminal + +- Apple App Store: + +https://apps.apple.com/us/app/bluefruit-connect/id830125974 + +Open the example, ``“Files” → “Examples” → “AmebaBLE” → “BLEUartService”``. + +|image01| + +Upload the code and press the reset button on Ameba once the upload is finished. + +Open the app on your smartphone, scan and connect to the Ameba board shown as “AMEBA_BLE_DEV” and choose the UART function in the app. Note that the BLE UART service on the Ameba board will only work with the UART and Plotter functions in the Bluefruit Connect app, other functions (Pin I/O, Image Transfer) require other BLE services that are not included in this example. + +|image02| + +|image03| + +In the UART terminal section of the app, enter a message and click send. You should see the message appear in the Arduino serial monitor. + +In the Arduino serial monitor, enter a message and click send. The message will appear in the smartphone app. + +|image04| + +|image05| + +Code Reference +-------------- + +The BLECharacteristic class is used to create two characteristics, one for receive (Rx) and one for transmit (Tx), and added to a service created with the BLEService class. +The required read/write/notify properties are set for each characteristic using the ``set__Property()`` methods, and callback functions are registered using the ``set__Callback()`` methods. The required buffer size is also set for each characteristic so that it has enough memory to store a complete string. +When data is written to the receive characteristic, the registered callback function is called, which prints out the received data as a string to the serial monitor. +When data is received on the serial port, it is copied into the transmit characteristic buffer, and the ``notify()`` method is used to inform the connected device of the new data. + +.. |image01| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_UART_Service/image01.png + :width: 696 px + :height: 1126 px +.. |image02| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_UART_Service/image02.png + :width: 1440 px + :height: 2880 px + :scale: 30% +.. |image03| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_UART_Service/image03.png + :width: 1440 px + :height: 2880 px + :scale: 30% +.. |image04| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_UART_Service/image04.png + :width: 1440 px + :height: 2880 px + :scale: 30% +.. |image05| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_UART_Service/image05.png + :width: 779 px + :height: 619 px diff --git a/source/_common/ameba_d/Example_Guides/BLE/BLE - V7RC Car.rst b/source/_common/ameba_d/Example_Guides/BLE/BLE - V7RC Car.rst new file mode 100644 index 0000000..945e088 --- /dev/null +++ b/source/_common/ameba_d/Example_Guides/BLE/BLE - V7RC Car.rst @@ -0,0 +1,106 @@ +BLE - V7RC Car +============== + +.. contents:: + :local: + :depth: 2 + +Materials +--------- + +- AmebaD [AMB21 / AMB22 / AMB23 / AMB25 / AMB26 / BW16 / AW-CU488 Thing Plus] x 1 + +- Android / iOS smartphone + +- L9110S Servo Motor Controller x1 + +- TT Motor x2 + +Example +------- + +Introduction +~~~~~~~~~~~~ + +In this example, we will use AmebaD as the BLE Peripheral device and the servo motor controller to communicate with the V7RC mobile app. V7RC is a remote controller APP that provides two kinds of control UI: one is 2 channels for RC cars, and the other is 4 channels for tanks and bulldozers. + +Procedure +~~~~~~~~~ + +1. Establish BLE Connection + +Open the example, “Files” -> “Examples” -> “AmebaBLE” -> “BLEV7RC_CAR”: + +|image01| + +Upload the code and press the reset button on Ameba once the upload is finished. + +Open V7RC APP and select “Control Centre”: + +|image02| + +Under NETWORK section, select “BLE”: + +|image03| + +Click DEVICE, and select AMEBA_BLE_DEV and click “LINK” button to connect to your Ameba board: + +|image04| + +Open the Arduino serial monitor, and you should see log of AmebaD is successfully connected to mobile phone: + +|image05| + +Back to the V7RC home page, you can monitor the log printed data received when moving the two controller buttons indicated in the image below. Successfully data receiving indicating the BLE connection has been established: + +|image06| + +2. Setup Servo Motors + +We will use two sets of servo motor to control the movement of the car upon the BLE connection has been established. The two servo motors will be connected to L9110S servo controller first using predefined MotoA_1A, MotoA_1B, MotoA_1B, and MotoA_1B pins. + + - 1A pins are connected to GPIO pins, used for controlling the motor directions. + + - 1B pins are connected to PWM pins, used for controlling the motor speed. + +.. code:: c++ + + #define MotoA_1A 6 // Control MotorA moving Forward(HIGH)/Backward(LOW) + #define MotoA_1B 12 // Control MotorA’s from speed 0~255, or stop (LOW) + #define MotoB_1A 2 // Control MotorB moving Forward(HIGH)/Backward(LOW) + #define MotoB_1B 3 // Control MotorB’s speed from 0~255, or stop (LOW) + +In this example, we will use BW16 as a demonstration. A detailed connection pin map can be found below. Upon the connection being established, the user can remotely control the servo motors via the V7RC App BLE. + +|image07| + +Code Reference +-------------- + +``ParseCMDString(String cmd)`` is a customized function will take a string “cmd” as input and process it. Currently, there are 6 available commands from V7RC App, which are: "SS2","SS4","SRT","SR2", and "SRV". + +.. |image01| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_V7RC_Car/image01.png + :width: 450 px + :height: 491 px +.. |image02| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_V7RC_Car/image02.png + :width: 1218 px + :height: 563 px + :scale: 80% +.. |image03| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_V7RC_Car/image03.png + :width: 1219 px + :height: 563 px + :scale: 80% +.. |image04| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_V7RC_Car/image04.png + :width: 1218 px + :height: 563 px + :scale: 80% +.. |image05| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_V7RC_Car/image05.png + :width: 903 px + :height: 478 px +.. |image06| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_V7RC_Car/image06.png + :width: 1379 px + :height: 637 px + :scale: 70% +.. |image07| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_V7RC_Car/image07.png + :width: 602 px + :height: 501 px diff --git a/source/_common/ameba_d/Example_Guides/BLE/BLE - WiFi Configuration Service.rst b/source/_common/ameba_d/Example_Guides/BLE/BLE - WiFi Configuration Service.rst new file mode 100644 index 0000000..2eba21d --- /dev/null +++ b/source/_common/ameba_d/Example_Guides/BLE/BLE - WiFi Configuration Service.rst @@ -0,0 +1,92 @@ +BLE - WiFi Configuration Service +================================ + +.. contents:: + :local: + :depth: 2 + +Materials +--------- + +- AmebaD [AMB21 / AMB22 / AMB23 / AMB25 / AMB26 / BW16 / AW-CU488 Thing Plus] x 1 + +- Android / iOS smartphone + +Example +------- + +Introduction +~~~~~~~~~~~~ + +In this example, a WiFi configuration service is set up on the Ameba Bluetooth stack. A mobile phone with the configuration app connects to the Ameba device using BLE and configures the Ameba to connect to the correct WiFi access point. + +Procedure +~~~~~~~~~ + +Ensure that the Realtek WiFi configuration app is installed on your mobile phone, it is available at: + +- Google Play Store: https://play.google.com/store/apps/details?id=com.rtk.btconfig + +- Apple App Store: https://apps.apple.com/sg/app/easy-wifi-config/id1194919510 + +Open the example, ``“Files” -> “Examples” -> “AmebaBLE” -> “BLEWifiConfigService”``. + +|image01| + + +Upload the code and press the reset button on Ameba once the upload is finished. + +On your mobile phone, open the Realtek WiFiConfig app and tap the round button to scan for Ameba boards. + +|image02| + +Select the correct Ameba board from the scan results. The app will connect to the Ameba board and ask the board to scan for WiFi networks and send the scan results back to the app using BLE. + +|image03| + +|image04| + +|image05| + +If your phone is currently connected to a WiFi network, the app will ask for the WiFi password to connect the Ameba board to the same WiFi network. Tap “Select AP” to choose another WiFi network, or enter the password and tap continue to connect Ameba to the selected WiFi network. + +|image06| + +After the Ameba board connects to the WiFi network, the following message will be shown. Tap “Try another AP” to connect to another WiFi network or tap “Confirm” to keep the current WiFi network and disconnect BLE from the Ameba board. + +|image07| + +Code Reference +-------------- + +BLEWifiConfigService is used to create an instance of the WiFi configuration service to run on the Bluetooth device. + +``BLE.configAdvert()->setAdvType(configService.advData())`` is used to set the correct advertisement data necessary for the phone app to find the Ameba Bluetooth device. + +.. |image01| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_WiFi_Configuration_Service/image01.png + :width: 832 px + :height: 1006 px +.. |image02| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_WiFi_Configuration_Service/image02.png + :width: 1440 px + :height: 2880 px + :scale: 30% +.. |image03| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_WiFi_Configuration_Service/image03.png + :width: 1440 px + :height: 2880 px + :scale: 30% +.. |image04| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_WiFi_Configuration_Service/image04.png + :width: 1440 px + :height: 2880 px + :scale: 30% +.. |image05| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_WiFi_Configuration_Service/image05.png + :width: 1440 px + :height: 2880 px + :scale: 30% +.. |image06| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_WiFi_Configuration_Service/image06.png + :width: 1440 px + :height: 2880 px + :scale: 30% +.. |image07| image:: ../../../../_static/amebad/Example_Guides/BLE/BLE_WiFi_Configuration_Service/image07.png + :width: 1440 px + :height: 2880 px + :scale: 30% diff --git a/bak/ambd/_common/Example_Guides/BLE/index.rst b/source/_common/ameba_d/Example_Guides/BLE/index.rst similarity index 100% rename from bak/ambd/_common/Example_Guides/BLE/index.rst rename to source/_common/ameba_d/Example_Guides/BLE/index.rst diff --git a/source/_common/ameba_d/Example_Guides/Debugging/Debugging - Using the Debug Interface.rst b/source/_common/ameba_d/Example_Guides/Debugging/Debugging - Using the Debug Interface.rst new file mode 100644 index 0000000..01fa15c --- /dev/null +++ b/source/_common/ameba_d/Example_Guides/Debugging/Debugging - Using the Debug Interface.rst @@ -0,0 +1,105 @@ +Debugging - Using the Debug Interface +===================================== + +.. contents:: + :local: + :depth: 2 + +Materials +--------- + +- AmebaD [AMB21 / AMB22 / AMB23 / AMB25 / AMB26 / BW16 / AW-CU488 Thing Plus] x 1 + +- SEGGER debug probe x 1 + +Example +------- + +Using the debugging feature available in the Arduino 2.0 IDE to debug your board. In this example, we will use SEGGER's debug probe with Arduino IDE's debug interface. Begin by installing the SEGGER debugging software. This can be found on SEGGER's official website: https://www.segger.com/downloads/jlink/ + +Before debugging, ensure that the code is optimized for debugging. Enable it by navigating to Sketch -> Optimize for Debugging. + +|image01| + +Open the Debug example, “File” -> “Examples” -> “Debugging” -> “ExampleDebug” + +|image02| + +Two files will open in the IDE; ExampleDebug.ino and debug_custom.json. Click on debug_custom.json. Under “serverArgs”, insert the directory path to Arduino15 folder, as well as the current version number of the tools folder. + +|image03| + +Connect the JLink Debug Probe and AmebaD board to the computer. Refer to the table below for the wiring connection between JLink Debug Probe and AmebaD board. For more information, please refer to: https://www.segger.com/products/debug-probes/j-link/technology/interface-description/ + ++---------------------------+-----------------------+ +| **JLink Debug Probe** | **AmebaD Boards** | ++===========================+=======================+ +| VTref | 3.3V | ++---------------------------+-----------------------+ +| GND | GND | ++---------------------------+-----------------------+ +| SWDIO | SWDIO | ++---------------------------+-----------------------+ +| SWCLK | SWCLK | ++---------------------------+-----------------------+ + +|image04| + +|image05| + +AmebaD boards only have 2 hardware breakpoints. Setting more than that will cause debugging to fail. Hardware breakpoints can be set at the left of the code and are indicated by a red dot shown in line 42. You will need to stop debugging and reset if this happens. + +If 2 hardware breakpoint is not enough, software breakpoint can be used. Either of the instructions ``(__BKPT() or __asm__("BKPT"))`` can be used to add a software breakpoint in the program execution. + +|image06| + +Upload the code and press the reset button on Ameba once the upload is finished. + +Once uploading is completed, reset the board. Start debugging by selecting the Debug button. This is located to the right of the upload button. Arduino will proceed with opening a gdb-server tab in the same window as the output window if all connections were connected correctly between JLink and board. This can sometimes take up to 10 seconds to set up. + +|image07| + +The line highlighted in yellow indicates which line of code the program is currently halted at. Debug console will appear to show the debugging information. + +|image08| + +To continue running the code after the breakpoint, use any of the single-stepping functions highlighted in the red box above (continue, step over, step into, step out, restart, stop) + +.. note :: For AmebaD boards, using any of the single-stepping functionality requires both hardware breakpoint resources to be free. You should remove or disable all existing breakpoints before using them. + +|image09| + +.. |image01| image:: ../../../../_static/amebad/Example_Guides/Debugging/Debugging_Using_the_Debug_Interface/image01.png + :width: 1265 px + :height: 542 px + :scale: 70% +.. |image02| image:: ../../../../_static/amebad/Example_Guides/Debugging/Debugging_Using_the_Debug_Interface/image02.png + :width: 1266 px + :height: 1040 px + :scale: 70% +.. |image03| image:: ../../../../_static/amebad/Example_Guides/Debugging/Debugging_Using_the_Debug_Interface/image03.png + :width: 1813 px + :height: 457 px + :scale: 40% +.. |image04| image:: ../../../../_static/amebad/Example_Guides/Debugging/Debugging_Using_the_Debug_Interface/image04.png + :width: 500 px + :height: 500 px +.. |image05| image:: ../../../../_static/amebad/Example_Guides/Debugging/Debugging_Using_the_Debug_Interface/image05.png + :width: 3264 px + :height: 2448 px + :scale: 20% +.. |image06| image:: ../../../../_static/amebad/Example_Guides/Debugging/Debugging_Using_the_Debug_Interface/image06.png + :width: 1266 px + :height: 831 px + :scale: 70% +.. |image07| image:: ../../../../_static/amebad/Example_Guides/Debugging/Debugging_Using_the_Debug_Interface/image07.png + :width: 1256 px + :height: 711 px + :scale: 70% +.. |image08| image:: ../../../../_static/amebad/Example_Guides/Debugging/Debugging_Using_the_Debug_Interface/image08.png + :width: 1365 px + :height: 728 px + :scale: 70% +.. |image09| image:: ../../../../_static/amebad/Example_Guides/Debugging/Debugging_Using_the_Debug_Interface/image09.png + :width: 618 px + :height: 459 px diff --git a/bak/ambd/_common/Example_Guides/Debugging/index.rst b/source/_common/ameba_d/Example_Guides/Debugging/index.rst similarity index 100% rename from bak/ambd/_common/Example_Guides/Debugging/index.rst rename to source/_common/ameba_d/Example_Guides/Debugging/index.rst diff --git a/source/_common/ameba_d/Example_Guides/Flash Memory/Flash Memory - Store data in FlashEEProm.rst b/source/_common/ameba_d/Example_Guides/Flash Memory/Flash Memory - Store data in FlashEEProm.rst new file mode 100644 index 0000000..00750b1 --- /dev/null +++ b/source/_common/ameba_d/Example_Guides/Flash Memory/Flash Memory - Store data in FlashEEProm.rst @@ -0,0 +1,48 @@ +Flash Memory - Store data in FlashEEProm +======================================== + +.. contents:: + :local: + :depth: 2 + +Materials +--------- + +- AmebaD [AMB21 / AMB22 / AMB23 / AMB25 / AMB26 / BW16 / AW-CU488 Thing Plus] x 1 + +Example +------- + +Ameba provides Flash Memory component for data storage and the data can be preserved when the power is off if necessary, e.g., compiled program. To avoid the memory space overlapped with the program on Ameba, the Flash API uses the tail part of the address space, with sector size 4K. +In this example, we store the value of boot times in flash memory. Every time Ameba reboots, it reads the boot times from flash, increases the value by 1, and writes it back to flash memory. + + +First open the example, “File” -> “Examples” -> “AmebaFlashMemory” -> “FlashMemoryBasic” + +|image01| + +Compile and upload to Ameba, then press the reset button. + +Open the Serial Monitor, press the reset button for a few times. Then you can see the boot times value increases. + +|image02| + +Code Reference +-------------- + +By default, the Flash Memory API uses address 0xFF000~0xFFFFF to store data. + +There is limitation when writing to flash memory. That is, you can not directly write data to the same address you used in last write. To do that correctly, you need erase the sector first. The Flash API of Ameba uses a 4K SRAM to record the user modification and do the erase/write task together. + +Use ``FlashMemory.read()`` to read from Flash memory. +Use ``FlashMemory.buf[0]`` = 0x00; to manipulate the 4K buf. +Use ``FlashMemory.update();`` to update the data in buf to Flash Memory. + +.. |image01| image:: ../../../../_static/amebad/Example_Guides/FlashMemory/Flash_Memory_Store_data_in_Flash_EEPROM/image01.png + :width: 1224 + :height: 2393 + :scale: 40 % +.. |image02| image:: ../../../../_static/amebad/Example_Guides/FlashMemory/Flash_Memory_Store_data_in_Flash_EEPROM/image02.png + :width: 1800 + :height: 1641 + :scale: 40 % \ No newline at end of file diff --git a/source/_common/ameba_d/Example_Guides/Flash Memory/Flash Memory - Use Flash Memory Larger Than 4K.rst b/source/_common/ameba_d/Example_Guides/Flash Memory/Flash Memory - Use Flash Memory Larger Than 4K.rst new file mode 100644 index 0000000..c6c6fb2 --- /dev/null +++ b/source/_common/ameba_d/Example_Guides/Flash Memory/Flash Memory - Use Flash Memory Larger Than 4K.rst @@ -0,0 +1,50 @@ +Flash Memory - Use Flash Memory Larger Than 4K +============================================== + +.. contents:: + :local: + :depth: 2 + +Materials +--------- + +- AmebaD [AMB21 / AMB22 / AMB23 / AMB25 / AMB26 / BW16 / AW-CU488 Thing Plus] x 1 + +Example +------- + +Flash Memory API uses memory of 4K bytes, which is normally sufficient for most application. However, larger memory can be provided by specifying a specific memory address and required size. + +First, open the sample code in ``“File” → “Examples” → “AmebaFlashMemory” → “ReadWriteOneWord”`` + +In this example, we specify the starting address of flash memory is 0xFC000 and size is 0x4000 (The default starting address is 0xFF000 and size is 0x1000). +Then calculate correct address according to the specified offset and perform read/write operation. In the sample code we use offset 0x3F00, that is, 0xFC000 + 0x3F00 = 0xFFF00 in flash. We set the value to 0 at first, then increase by 1 every time Ameba reboots. + + +|image01| + +Code Reference +-------------- + +We can use the flash api we used in previous flash memory example, but we need to use begin() function to specify the desired starting address and memory size. + +.. code:: c++ + + FlashMemory.begin(0xFC000, 0x4000); + +Use ``readWord()`` to read the value stored in a memory address. In the example, we read the value stored in memory offset 0x3F00, that is 0xFC000 + 0x3F00 = 0xFFF00. ``readWord()`` function + +.. code:: c++ + + value = FlashMemory.readWord(0x3F00); + +Use ``writeWord()`` to write to a memory address. The first argument is the memory offset, the second argument is the value to write to memory. + +.. code-block:: C + + FlashMemory.writeWord(0x3F0C, value); + +.. |image01| image:: ../../../../_static/amebad/Example_Guides/FlashMemory/Flash_Memory_Use_Flash_Memory_Larger_Than_4K/image01.png + :width: 1384 + :height: 1208 + :scale: 60 % \ No newline at end of file diff --git a/bak/ambd/_common/Example_Guides/Flash Memory/index.rst b/source/_common/ameba_d/Example_Guides/Flash Memory/index.rst similarity index 100% rename from bak/ambd/_common/Example_Guides/Flash Memory/index.rst rename to source/_common/ameba_d/Example_Guides/Flash Memory/index.rst diff --git a/source/_common/ameba_d/Example_Guides/GPIO/GPIO - Measure Distance By Ultrasound Module.rst b/source/_common/ameba_d/Example_Guides/GPIO/GPIO - Measure Distance By Ultrasound Module.rst new file mode 100644 index 0000000..f321ac5 --- /dev/null +++ b/source/_common/ameba_d/Example_Guides/GPIO/GPIO - Measure Distance By Ultrasound Module.rst @@ -0,0 +1,234 @@ +GPIO - Measure Distance By Ultrasound Module +============================================ + +.. contents:: + :local: + :depth: 2 + +Materials +--------- + +- AmebaD [AMB21 / AMB22 / AMB23 / AMB25 / AMB26 / BW16 / AW-CU488 Thing Plus] x 1 + +- HC-SR04 Ultrasonic x 1 + +- Dropping resistor or Level converter + +Example +------- + +Introduction +~~~~~~~~~~~~ + +HC-SR04 is a module that uses ultrasound to measure the distance. It looks like a pair of eyes in its appearance; therefore, it’s often installed onto robot-vehicle or mechanical bugs to be their eyes. +The way it works is that first we “toggle high” the TRIG pin (that is to pull high then pull low). The HC-SR04 would send eight 40kHz sound wave signal and pull high the ECHO pin. When the sound wave returns, it pulls low the ECHO pin. + + +|image01| + +Assume the velocity of sound is 340 m/s, the time it takes for the sound to advance 1 cm in the air is 340*100*10^-6 = 29 us。 +The sound wave actually travels twice the distance between HC-SR04 and the object, therefore the distance can be calculated by (time/29) / 2 = time / 58。 +The working voltage of HC-SR04 is 5V. When we pull high the ECHO pin to 5V, the voltage might cause damage to the GPIO pin of Ameba. To avoid this situation, we need to drop the voltage as follows: + +Procedure +~~~~~~~~~ + +.. only:: amb21 + +**AMB21 / AMB22** Wiring Diagram: + +|image02| + +.. only:: end amb21 + +.. only:: amb23 + +**AMB23** Wiring Diagram: + +|image03| + +.. only:: end amb23 + +.. only:: bw16-typeb + +**BW16** Wiring Diagram: + +|image04| + +.. only:: end bw16-typeb + +.. only:: bw16-typec + +**BW16-TypeC** Wiring Diagram: + +|image05| + +.. only:: end bw16-typec + +.. only:: aw-cu488 + +**AW-CU488 Thing Plus** Wiring Diagram: + +|image06| + +.. only:: end aw-cu488 + +.. only:: amb25 + +**AMB25** Wiring Diagram: + +|image07| + +.. only:: end amb25 + +.. only:: amb26 + +**AMB26** Wiring Diagram: + +|image07| + +.. only:: end amb26 + +We pick the resistors with resistance 1:2, any value of resistance is fine but too high values is not recommended. +If you do not have resistors in hand, you can use a level converter instead. The TXB0108 8 channel level converter is a suitable example: + +.. only:: amb21 + +**AMB21 / AMB22** Wiring Diagram: + +|image08| + +.. only:: end amb21 + +.. only:: amb23 + +**AMB23** Wiring Diagram: + +|image09| + +.. only:: end amb23 + +.. only:: bw16-typeb + +**BW16** Wiring Diagram: + +|image10| + +.. only:: end bw16-typeb + +.. only:: bw16-typec + +**BW16-TypeC** Wiring Diagram: + +|image11| + +.. only:: end bw16-typec + +.. only:: aw-cu488 + +**AW-CU488 Thing Plus** Wiring Diagram: + +|image12| + +.. only:: end aw-cu488 + +.. only:: amb25 + +**AMB25** Wiring Diagram: + +|image13| + +.. only:: end amb25 + +.. only:: amb26 + +**AMB26** Wiring Diagram: + +|image13| + +.. only:: end amb26 + +Next, open the sample code in “File” -> “Examples” -> “AmebaGPIO” -> “HCSR04_Ultrasonic” + +|image14| + +Compile and upload to Ameba, then press the reset button. Open the Serial Monitor, the calculated result is output to serial monitor every 2 seconds. + +|image15| + +Note that the HCSR04 module uses the reflection of sound wave to calculate the distance, thus the result can be affected by the surface material of the object (e.g., harsh surface tends to cause scattering of sound wave, and soft surface may cause the sound wave to be absorbed). + +Code Reference +-------------- + +Before the measurement starts, we need to pull high the TRIG pin for 10us and then pull low. By doing this, we are telling the HC-SR04 that we are about to start the measurement: + +.. code:: c++ + + digitalWrite(trigger_pin, HIGH); + delayMicroseconds(10); + digitalWrite(trigger_pin, LOW); + +Next, use pulseIn to measure the time when the ECHO pin is pulled high. + +.. code:: c++ + + duration = pulseIn(echo_pin, HIGH); + +Finally, use the formula to calculate the distance. + +.. code:: c++ + + distance = duration / 58; + +.. |image01| image:: ../../../../_static/amebad/Example_Guides/GPIO/GPIO_Measure_the_Distance_by_Ultrasound_Module/image01.png + :width: 1103 px + :height: 679 px + :scale: 70% +.. |image02| image:: ../../../../_static/amebad/Example_Guides/GPIO/GPIO_Measure_the_Distance_by_Ultrasound_Module/image02.png + :width: 1256 px + :height: 784 px + :scale: 70% +.. |image03| image:: ../../../../_static/amebad/Example_Guides/GPIO/GPIO_Measure_the_Distance_by_Ultrasound_Module/image03.png + :width: 1022 px + :height: 776 px +.. |image04| image:: ../../../../_static/amebad/Example_Guides/GPIO/GPIO_Measure_the_Distance_by_Ultrasound_Module/image04.png + :width: 938 px + :height: 747 px +.. |image05| image:: ../../../../_static/amebad/Example_Guides/GPIO/GPIO_Measure_the_Distance_by_Ultrasound_Module/image05.png + :width: 995 px + :height: 762 px +.. |image06| image:: ../../../../_static/amebad/Example_Guides/GPIO/GPIO_Measure_the_Distance_by_Ultrasound_Module/image06.png + :width: 827 px + :height: 672 px +.. |image07| image:: ../../../../_static/amebad/Example_Guides/GPIO/GPIO_Measure_the_Distance_by_Ultrasound_Module/image07.png + :width: 636 px + :height: 508 px +.. |image08| image:: ../../../../_static/amebad/Example_Guides/GPIO/GPIO_Measure_the_Distance_by_Ultrasound_Module/image08.png + :width: 1070 px + :height: 735 px + :scale: 80% +.. |image09| image:: ../../../../_static/amebad/Example_Guides/GPIO/GPIO_Measure_the_Distance_by_Ultrasound_Module/image09.png + :width: 1049 px + :height: 710 px + :scale: 80% +.. |image10| image:: ../../../../_static/amebad/Example_Guides/GPIO/GPIO_Measure_the_Distance_by_Ultrasound_Module/image10.png + :width: 1140 px + :height: 757 px + :scale: 80% +.. |image11| image:: ../../../../_static/amebad/Example_Guides/GPIO/GPIO_Measure_the_Distance_by_Ultrasound_Module/image11.png + :width: 1137 px + :height: 696 px + :scale: 80% +.. |image12| image:: ../../../../_static/amebad/Example_Guides/GPIO/GPIO_Measure_the_Distance_by_Ultrasound_Module/image12.png + :width: 798 px + :height: 737 px +.. |image13| image:: ../../../../_static/amebad/Example_Guides/GPIO/GPIO_Measure_the_Distance_by_Ultrasound_Module/image13.png + :width: 626 px + :height: 467 px +.. |image14| image:: ../../../../_static/amebad/Example_Guides/GPIO/GPIO_Measure_the_Distance_by_Ultrasound_Module/image14.png + :width: 602 px + :height: 619 px +.. |image15| image:: ../../../../_static/amebad/Example_Guides/GPIO/GPIO_Measure_the_Distance_by_Ultrasound_Module/image15.png + :width: 649 px + :height: 372 px diff --git a/source/_common/ameba_d/Example_Guides/GPIO/GPIO - Measure Temperature and Humidity.rst b/source/_common/ameba_d/Example_Guides/GPIO/GPIO - Measure Temperature and Humidity.rst new file mode 100644 index 0000000..ef38b17 --- /dev/null +++ b/source/_common/ameba_d/Example_Guides/GPIO/GPIO - Measure Temperature and Humidity.rst @@ -0,0 +1,154 @@ +GPIO - Measure Temperature and Humidity +======================================= + +.. contents:: + :local: + :depth: 2 + +Materials +--------- + +- AmebaD [AMB21 / AMB22 / AMB23 / AMB25 / AMB26 / BW16 / AW-CU488 Thing Plus] x 1 + +- DHT11 or DHT22 or DHT21 + +Example +------- + +Introduction +~~~~~~~~~~~~ + +DHT11 is a temperature and humidity sensor which operates at voltage 3.3V~5V. At room temperature, the measurable range of the humidity is 20% ~ 90%RH with ±5%RH precision, the measurable range of the temperature is 0 ~ 50℃ with ±2℃ precision. +Another choice of temperature and humidity sensor is DHT22 sensor, which has better precision. Its measurable range of the humidity is 0%~100%RH with ±5%RH precision, the measurable range of the temperature is -40~125 ℃ with ±0.2℃ precision. +There are 4 pins on the sensor: + + +|image01| + +Since one of the 4 pins has no function, there are temperature/humidity sensors with only 3 pins on the market: + +|image02| + +DHT is normally in the sleeping mode. To get the temperature/humidity data, please follow the steps: + + 1. Awake DHT: Ameba toggles low its DATA pin of GPIO. Now the DATA pin of GPIO serves as digital out to Ameba. + + 2. DHT response: DHT also toggle low its DATA pin of GPIO. Now the DATA pin of GPIO serves as digital in for Ameba. + + 3. DHT sends data: DHT sends out the temperature/humidity data (which has size 5 bytes) in a bit by bit manner. To represent each bit, DHT first pull low the DATA GPIO pin for a while and then pull high. If the duration of high is smaller than low, it stands for bit 0. Otherwise it stands for bit 1. + +|image03| + +Procedure +~~~~~~~~~ + +Take note that if you are using a DHT sensor that is not mounted on a PCB, you will have to add in a 10K Ohm pull up resistor. You may refer to the wiring diagrams. + +.. only:: amb21 + +**AMB21 / AMB22** Wiring Diagram: + +|image04| + +**DHT sensor mounted on a PCB board** + +|image05| + +.. only:: end amb21 + +.. only:: amb23 + +**AMB23** Wiring Diagram: + +|image06| + +.. only:: end amb23 + +.. only:: bw16-typeb + +**BW16** Wiring Diagram: + +|image07| + +.. only:: end bw16-typeb + +.. only:: bw16-typec + +**BW16-TypeC** Wiring Diagram: + +|image08| + +.. only:: end bw16-typec + +.. only:: aw-cu488 + +**AW-CU488 Thing Plus** Wiring Diagram: + +|image09| + +.. only:: end aw-cu488 + +.. only:: amb25 + +**AMB25** Wiring Diagram: + +|image10| + +.. only:: end amb25 + +.. only:: amb26 + +**AMB26** Wiring Diagram: + +|image10| + +.. only:: end amb26 + + +Open the sample code in ``“Files” → “Examples” → “AmebaGPIO” → “DHT_Tester”``. Compile and upload to Ameba, then press the reset button. The result would be shown on the Serial Monitor. + +|image11| + +Code Reference +-------------- + +Use ``dht.readHumidity()`` read the humidity value, and +use ``dht.readTemperature()`` to read the temperature value. + +Every time we read the temperature/humidity data, Ameba uses the buffered temperature/humidity data unless it found the data has expired (i.e., has not been updated for over 2 seconds). If the data is expired, Ameba issues a request to DHT to read the latest data. + +.. |image01| image:: ../../../../_static/amebad/Example_Guides/GPIO/GPIO_Measure_Temperature_And_Humidity/image01.png + :width: 405 px + :height: 519 px +.. |image02| image:: ../../../../_static/amebad/Example_Guides/GPIO/GPIO_Measure_Temperature_And_Humidity/image02.png + :width: 178 px + :height: 432 px +.. |image03| image:: ../../../../_static/amebad/Example_Guides/GPIO/GPIO_Measure_Temperature_And_Humidity/image03.png + :width: 1379 px + :height: 400 px + :scale: 60% +.. |image04| image:: ../../../../_static/amebad/Example_Guides/GPIO/GPIO_Measure_Temperature_And_Humidity/image04.png + :width: 1430 px + :height: 715 px + :scale: 60% +.. |image05| image:: ../../../../_static/amebad/Example_Guides/GPIO/GPIO_Measure_Temperature_And_Humidity/image05.png + :width: 943 px + :height: 762 px +.. |image06| image:: ../../../../_static/amebad/Example_Guides/GPIO/GPIO_Measure_Temperature_And_Humidity/image06.png + :width: 797 px + :height: 756 px +.. |image07| image:: ../../../../_static/amebad/Example_Guides/GPIO/GPIO_Measure_Temperature_And_Humidity/image07.png + :width: 935 px + :height: 692 px +.. |image08| image:: ../../../../_static/amebad/Example_Guides/GPIO/GPIO_Measure_Temperature_And_Humidity/image08.png + :width: 863 px + :height: 731 px +.. |image09| image:: ../../../../_static/amebad/Example_Guides/GPIO/GPIO_Measure_Temperature_And_Humidity/image09.png + :width: 591 px + :height: 752 px +.. |image10| image:: ../../../../_static/amebad/Example_Guides/GPIO/GPIO_Measure_Temperature_And_Humidity/image10.png + :width: 492 px + :height: 469 px +.. |image11| image:: ../../../../_static/amebad/Example_Guides/GPIO/GPIO_Measure_Temperature_And_Humidity/image11.png + :width: 704 px + :height: 591 px diff --git a/source/_common/ameba_d/Example_Guides/GPIO/GPIO - Use GPIO Interrupt To Control LED.rst b/source/_common/ameba_d/Example_Guides/GPIO/GPIO - Use GPIO Interrupt To Control LED.rst new file mode 100644 index 0000000..3f2e014 --- /dev/null +++ b/source/_common/ameba_d/Example_Guides/GPIO/GPIO - Use GPIO Interrupt To Control LED.rst @@ -0,0 +1,149 @@ +GPIO - Use GPIO Interrupt To Control LED +======================================== + +.. contents:: + :local: + :depth: 2 + +Materials +--------- + +- AmebaD [AMB21 / AMB22 / AMB23 / AMB25 / AMB26 / BW16 / AW-CU488 Thing Plus] x 1 + +- LED x 1 + +- Button x 1 + + +Example +------- + +Introduction +~~~~~~~~~~~~ + +In this example, we use a button to trigger interrupt and control the LED. When we press and release the button, the LED dims, press and release the button again, and the LED lights up. Note that in the Arduino example “Button and LED”, LED only lights up when the button is pressed and hold, when we release the button, the LED dims. + +Procedure +~~~~~~~~~ + +Open the example, ``“Files” → “Examples” → “AmebaGPIO” → “LED_InterruptCtrl”`` + +.. only:: amb21 + +**AMB21 / AMB22** Wiring Diagram: + +|image01| + +.. only:: end amb21 + +.. only:: amb23 + +**AMB23** Wiring Diagram: + +|image02| + +.. only:: end amb23 + +.. only:: bw16-typeb + +**BW16** Wiring Diagram: + +|image03| + +.. only:: end bw16-typeb + +.. only:: bw16-typec + +**BW16-TypeC** Wiring Diagram: + +|image04| + +.. only:: end bw16-typec + +.. only:: aw-cu488 + +**AW-CU488 Thing Plus** Wiring Diagram: + +|image05| + +.. only:: end aw-cu488 + +.. only:: amb25 + +**AMB25** Wiring Diagram: + +|image06| + +.. only:: end amb25 + +.. only:: amb26 + +**AMB26** Wiring Diagram: + +|image06| + +.. only:: end amb26 + +Compile and upload the program, press the reset button on the Ameba. +The LED will light up at first. Press and release the button, then the LED should dim. Pressing the button again should light up the LED. + +Code Reference +-------------- + +In + +.. code:: c++ + + setup() + +we set Pin 12 to: + +.. code:: c++ + + INPUT_IRQ_RISE + +This means that an interrupt occurs when the voltage of this pin changes from GND to 3V3. Therefore, we connect the other side of the button to 3V3, so as to trigger interrupt event when the button is pressed. + +.. code:: c++ + + pinMode(button, INPUT_IRQ_RISE); + +On the other hand, we can set pin 12 to: + +.. code:: c++ + + INPUT_IRQ_FALL + +This means that an interrupt occurs when the voltage of this pin changes from 3V3 to GND. In this case, the other side of the button is connected to GND. Next, we need to specify the function to be executed to handle the interrupt: + +.. code:: c++ + + digitalSetIrqHandler(button, button_handler); + +The second parameter is a function pointer, with prototype: + +.. code:: c++ + + void button_handler(uint32_t id, uint32_t event) + +In this handler, every time we press and release the button, we trigger an interrupt, and change the status of the LED. + +.. |image01| image:: ../../../../_static/amebad/Example_Guides/GPIO/GPIO_Use_GPIO_Interrupt_to_Control_LED/image01.png + :width: 1180 px + :height: 821 px + :scale: 80% +.. |image02| image:: ../../../../_static/amebad/Example_Guides/GPIO/GPIO_Use_GPIO_Interrupt_to_Control_LED/image02.png + :width: 831 px + :height: 797 px +.. |image03| image:: ../../../../_static/amebad/Example_Guides/GPIO/GPIO_Use_GPIO_Interrupt_to_Control_LED/image03.png + :width: 763 px + :height: 777 px +.. |image04| image:: ../../../../_static/amebad/Example_Guides/GPIO/GPIO_Use_GPIO_Interrupt_to_Control_LED/image04.png + :width: 668 px + :height: 665 px +.. |image05| image:: ../../../../_static/amebad/Example_Guides/GPIO/GPIO_Use_GPIO_Interrupt_to_Control_LED/image05.png + :width: 967 px + :height: 819 px +.. |image06| image:: ../../../../_static/amebad/Example_Guides/GPIO/GPIO_Use_GPIO_Interrupt_to_Control_LED/image06.png + :width: 594 px + :height: 630 px diff --git a/bak/ambd/_common/Example_Guides/GPIO/index.rst b/source/_common/ameba_d/Example_Guides/GPIO/index.rst similarity index 100% rename from bak/ambd/_common/Example_Guides/GPIO/index.rst rename to source/_common/ameba_d/Example_Guides/GPIO/index.rst diff --git a/source/_static/amebad/Example_Guides/BLE/BLE_DHT_over_BLE_UART/image01.png b/source/_static/amebad/Example_Guides/BLE/BLE_DHT_over_BLE_UART/image01.png index 511e89b..126bd3c 100644 Binary files a/source/_static/amebad/Example_Guides/BLE/BLE_DHT_over_BLE_UART/image01.png and b/source/_static/amebad/Example_Guides/BLE/BLE_DHT_over_BLE_UART/image01.png differ diff --git a/source/_static/amebad/Example_Guides/BLE/BLE_DHT_over_BLE_UART/image02.png b/source/_static/amebad/Example_Guides/BLE/BLE_DHT_over_BLE_UART/image02.png index 3385ded..cb06afd 100644 Binary files a/source/_static/amebad/Example_Guides/BLE/BLE_DHT_over_BLE_UART/image02.png and b/source/_static/amebad/Example_Guides/BLE/BLE_DHT_over_BLE_UART/image02.png differ diff --git a/source/_static/amebad/Example_Guides/BLE/BLE_DHT_over_BLE_UART/image03.png b/source/_static/amebad/Example_Guides/BLE/BLE_DHT_over_BLE_UART/image03.png index d92420b..5d0001d 100644 Binary files a/source/_static/amebad/Example_Guides/BLE/BLE_DHT_over_BLE_UART/image03.png and b/source/_static/amebad/Example_Guides/BLE/BLE_DHT_over_BLE_UART/image03.png differ diff --git a/source/_static/amebad/Example_Guides/BLE/BLE_DHT_over_BLE_UART/image04.png b/source/_static/amebad/Example_Guides/BLE/BLE_DHT_over_BLE_UART/image04.png index c259fc7..2877854 100644 Binary files a/source/_static/amebad/Example_Guides/BLE/BLE_DHT_over_BLE_UART/image04.png and b/source/_static/amebad/Example_Guides/BLE/BLE_DHT_over_BLE_UART/image04.png differ diff --git a/source/_static/amebad/Example_Guides/BLE/BLE_DHT_over_BLE_UART/image05.png b/source/_static/amebad/Example_Guides/BLE/BLE_DHT_over_BLE_UART/image05.png index 1b0c1cf..71785cf 100644 Binary files a/source/_static/amebad/Example_Guides/BLE/BLE_DHT_over_BLE_UART/image05.png and b/source/_static/amebad/Example_Guides/BLE/BLE_DHT_over_BLE_UART/image05.png differ diff --git a/source/_static/amebad/Example_Guides/GPIO/GPIO_Measure Temperature And Humidity/image10.png b/source/_static/amebad/Example_Guides/BLE/BLE_DHT_over_BLE_UART/image06.png similarity index 100% rename from source/_static/amebad/Example_Guides/GPIO/GPIO_Measure Temperature And Humidity/image10.png rename to source/_static/amebad/Example_Guides/BLE/BLE_DHT_over_BLE_UART/image06.png diff --git a/source/_static/amebad/Example_Guides/BLE/BLE_DHT_over_BLE_UART/image07.png b/source/_static/amebad/Example_Guides/BLE/BLE_DHT_over_BLE_UART/image07.png new file mode 100644 index 0000000..e524a12 Binary files /dev/null and b/source/_static/amebad/Example_Guides/BLE/BLE_DHT_over_BLE_UART/image07.png differ diff --git a/source/_static/amebad/Example_Guides/BLE/BLE_DHT_over_BLE_UART/image08.png b/source/_static/amebad/Example_Guides/BLE/BLE_DHT_over_BLE_UART/image08.png new file mode 100644 index 0000000..d92420b Binary files /dev/null and b/source/_static/amebad/Example_Guides/BLE/BLE_DHT_over_BLE_UART/image08.png differ diff --git a/source/_static/amebad/Example_Guides/BLE/BLE_DHT_over_BLE_UART/image09.png b/source/_static/amebad/Example_Guides/BLE/BLE_DHT_over_BLE_UART/image09.png new file mode 100644 index 0000000..c259fc7 Binary files /dev/null and b/source/_static/amebad/Example_Guides/BLE/BLE_DHT_over_BLE_UART/image09.png differ diff --git a/source/_static/amebad/Example_Guides/BLE/BLE_DHT_over_BLE_UART/image1-1.png b/source/_static/amebad/Example_Guides/BLE/BLE_DHT_over_BLE_UART/image1-1.png deleted file mode 100644 index d6423f8..0000000 Binary files a/source/_static/amebad/Example_Guides/BLE/BLE_DHT_over_BLE_UART/image1-1.png and /dev/null differ diff --git a/source/_static/amebad/Example_Guides/BLE/BLE_DHT_over_BLE_UART/image1-2.png b/source/_static/amebad/Example_Guides/BLE/BLE_DHT_over_BLE_UART/image1-2.png deleted file mode 100644 index 2f50452..0000000 Binary files a/source/_static/amebad/Example_Guides/BLE/BLE_DHT_over_BLE_UART/image1-2.png and /dev/null differ diff --git a/source/_static/amebad/Example_Guides/BLE/BLE_DHT_over_BLE_UART/image1-3.png b/source/_static/amebad/Example_Guides/BLE/BLE_DHT_over_BLE_UART/image1-3.png deleted file mode 100644 index f5d7397..0000000 Binary files a/source/_static/amebad/Example_Guides/BLE/BLE_DHT_over_BLE_UART/image1-3.png and /dev/null differ diff --git a/source/_static/amebad/Example_Guides/BLE/BLE_DHT_over_BLE_UART/image10.png b/source/_static/amebad/Example_Guides/BLE/BLE_DHT_over_BLE_UART/image10.png new file mode 100644 index 0000000..1b0c1cf Binary files /dev/null and b/source/_static/amebad/Example_Guides/BLE/BLE_DHT_over_BLE_UART/image10.png differ diff --git a/source/_static/amebad/Example_Guides/BLE/BLE_PWM_over_BLE_UART/image02.png b/source/_static/amebad/Example_Guides/BLE/BLE_PWM_over_BLE_UART/image02.png index 967f5f4..26a38ae 100644 Binary files a/source/_static/amebad/Example_Guides/BLE/BLE_PWM_over_BLE_UART/image02.png and b/source/_static/amebad/Example_Guides/BLE/BLE_PWM_over_BLE_UART/image02.png differ diff --git a/source/_static/amebad/Example_Guides/BLE/BLE_PWM_over_BLE_UART/image03.png b/source/_static/amebad/Example_Guides/BLE/BLE_PWM_over_BLE_UART/image03.png index d92420b..5902e90 100644 Binary files a/source/_static/amebad/Example_Guides/BLE/BLE_PWM_over_BLE_UART/image03.png and b/source/_static/amebad/Example_Guides/BLE/BLE_PWM_over_BLE_UART/image03.png differ diff --git a/source/_static/amebad/Example_Guides/BLE/BLE_PWM_over_BLE_UART/image04.png b/source/_static/amebad/Example_Guides/BLE/BLE_PWM_over_BLE_UART/image04.png index f7c01d5..c7b0bca 100644 Binary files a/source/_static/amebad/Example_Guides/BLE/BLE_PWM_over_BLE_UART/image04.png and b/source/_static/amebad/Example_Guides/BLE/BLE_PWM_over_BLE_UART/image04.png differ diff --git a/source/_static/amebad/Example_Guides/BLE/BLE_PWM_over_BLE_UART/image05.png b/source/_static/amebad/Example_Guides/BLE/BLE_PWM_over_BLE_UART/image05.png index 6740ca0..47a8afc 100644 Binary files a/source/_static/amebad/Example_Guides/BLE/BLE_PWM_over_BLE_UART/image05.png and b/source/_static/amebad/Example_Guides/BLE/BLE_PWM_over_BLE_UART/image05.png differ diff --git a/source/_static/amebad/Example_Guides/BLE/BLE_PWM_over_BLE_UART/image06.png b/source/_static/amebad/Example_Guides/BLE/BLE_PWM_over_BLE_UART/image06.png index 552e6ea..632ce9c 100644 Binary files a/source/_static/amebad/Example_Guides/BLE/BLE_PWM_over_BLE_UART/image06.png and b/source/_static/amebad/Example_Guides/BLE/BLE_PWM_over_BLE_UART/image06.png differ diff --git a/source/_static/amebad/Example_Guides/BLE/BLE_PWM_over_BLE_UART/image07.png b/source/_static/amebad/Example_Guides/BLE/BLE_PWM_over_BLE_UART/image07.png new file mode 100644 index 0000000..967f5f4 Binary files /dev/null and b/source/_static/amebad/Example_Guides/BLE/BLE_PWM_over_BLE_UART/image07.png differ diff --git a/source/_static/amebad/Example_Guides/BLE/BLE_PWM_over_BLE_UART/image08.png b/source/_static/amebad/Example_Guides/BLE/BLE_PWM_over_BLE_UART/image08.png new file mode 100644 index 0000000..d92420b Binary files /dev/null and b/source/_static/amebad/Example_Guides/BLE/BLE_PWM_over_BLE_UART/image08.png differ diff --git a/source/_static/amebad/Example_Guides/BLE/BLE_PWM_over_BLE_UART/image09.png b/source/_static/amebad/Example_Guides/BLE/BLE_PWM_over_BLE_UART/image09.png new file mode 100644 index 0000000..f7c01d5 Binary files /dev/null and b/source/_static/amebad/Example_Guides/BLE/BLE_PWM_over_BLE_UART/image09.png differ diff --git a/source/_static/amebad/Example_Guides/BLE/BLE_PWM_over_BLE_UART/image1-1.png b/source/_static/amebad/Example_Guides/BLE/BLE_PWM_over_BLE_UART/image1-1.png deleted file mode 100644 index 26a38ae..0000000 Binary files a/source/_static/amebad/Example_Guides/BLE/BLE_PWM_over_BLE_UART/image1-1.png and /dev/null differ diff --git a/source/_static/amebad/Example_Guides/BLE/BLE_PWM_over_BLE_UART/image1-2.png b/source/_static/amebad/Example_Guides/BLE/BLE_PWM_over_BLE_UART/image1-2.png deleted file mode 100644 index 5902e90..0000000 Binary files a/source/_static/amebad/Example_Guides/BLE/BLE_PWM_over_BLE_UART/image1-2.png and /dev/null differ diff --git a/source/_static/amebad/Example_Guides/BLE/BLE_PWM_over_BLE_UART/image1-3.png b/source/_static/amebad/Example_Guides/BLE/BLE_PWM_over_BLE_UART/image1-3.png deleted file mode 100644 index c7b0bca..0000000 Binary files a/source/_static/amebad/Example_Guides/BLE/BLE_PWM_over_BLE_UART/image1-3.png and /dev/null differ diff --git a/source/_static/amebad/Example_Guides/BLE/BLE_PWM_over_BLE_UART/image10.png b/source/_static/amebad/Example_Guides/BLE/BLE_PWM_over_BLE_UART/image10.png new file mode 100644 index 0000000..6740ca0 Binary files /dev/null and b/source/_static/amebad/Example_Guides/BLE/BLE_PWM_over_BLE_UART/image10.png differ diff --git a/source/_static/amebad/Example_Guides/BLE/BLE_PWM_over_BLE_UART/image11.png b/source/_static/amebad/Example_Guides/BLE/BLE_PWM_over_BLE_UART/image11.png new file mode 100644 index 0000000..552e6ea Binary files /dev/null and b/source/_static/amebad/Example_Guides/BLE/BLE_PWM_over_BLE_UART/image11.png differ diff --git a/source/_static/amebad/Example_Guides/BLE/BLE_V7RC_Car/image01.png b/source/_static/amebad/Example_Guides/BLE/BLE_V7RC_Car/image01.png new file mode 100644 index 0000000..472e80f Binary files /dev/null and b/source/_static/amebad/Example_Guides/BLE/BLE_V7RC_Car/image01.png differ diff --git a/source/_static/amebad/Example_Guides/BLE/BLE_V7RC Car/image01.png b/source/_static/amebad/Example_Guides/BLE/BLE_V7RC_Car/image02.png similarity index 100% rename from source/_static/amebad/Example_Guides/BLE/BLE_V7RC Car/image01.png rename to source/_static/amebad/Example_Guides/BLE/BLE_V7RC_Car/image02.png diff --git a/source/_static/amebad/Example_Guides/BLE/BLE_V7RC Car/image02.png b/source/_static/amebad/Example_Guides/BLE/BLE_V7RC_Car/image03.png similarity index 100% rename from source/_static/amebad/Example_Guides/BLE/BLE_V7RC Car/image02.png rename to source/_static/amebad/Example_Guides/BLE/BLE_V7RC_Car/image03.png diff --git a/source/_static/amebad/Example_Guides/BLE/BLE_V7RC Car/image03.png b/source/_static/amebad/Example_Guides/BLE/BLE_V7RC_Car/image04.png similarity index 100% rename from source/_static/amebad/Example_Guides/BLE/BLE_V7RC Car/image03.png rename to source/_static/amebad/Example_Guides/BLE/BLE_V7RC_Car/image04.png diff --git a/source/_static/amebad/Example_Guides/BLE/BLE_V7RC_Car/image05.png b/source/_static/amebad/Example_Guides/BLE/BLE_V7RC_Car/image05.png new file mode 100644 index 0000000..7522d09 Binary files /dev/null and b/source/_static/amebad/Example_Guides/BLE/BLE_V7RC_Car/image05.png differ diff --git a/source/_static/amebad/Example_Guides/BLE/BLE_V7RC Car/image04.png b/source/_static/amebad/Example_Guides/BLE/BLE_V7RC_Car/image06.png similarity index 100% rename from source/_static/amebad/Example_Guides/BLE/BLE_V7RC Car/image04.png rename to source/_static/amebad/Example_Guides/BLE/BLE_V7RC_Car/image06.png diff --git a/source/_static/amebad/Example_Guides/BLE/BLE_V7RC Car/image05.png b/source/_static/amebad/Example_Guides/BLE/BLE_V7RC_Car/image07.png similarity index 100% rename from source/_static/amebad/Example_Guides/BLE/BLE_V7RC Car/image05.png rename to source/_static/amebad/Example_Guides/BLE/BLE_V7RC_Car/image07.png diff --git a/source/_static/amebad/Example_Guides/Debugging/Debugging_Using the Debug Interface/image01.png b/source/_static/amebad/Example_Guides/Debugging/Debugging_Using_the_Debug_Interface/image01.png similarity index 100% rename from source/_static/amebad/Example_Guides/Debugging/Debugging_Using the Debug Interface/image01.png rename to source/_static/amebad/Example_Guides/Debugging/Debugging_Using_the_Debug_Interface/image01.png diff --git a/source/_static/amebad/Example_Guides/Debugging/Debugging_Using the Debug Interface/image02.png b/source/_static/amebad/Example_Guides/Debugging/Debugging_Using_the_Debug_Interface/image02.png similarity index 100% rename from source/_static/amebad/Example_Guides/Debugging/Debugging_Using the Debug Interface/image02.png rename to source/_static/amebad/Example_Guides/Debugging/Debugging_Using_the_Debug_Interface/image02.png diff --git a/source/_static/amebad/Example_Guides/Debugging/Debugging_Using the Debug Interface/image03.png b/source/_static/amebad/Example_Guides/Debugging/Debugging_Using_the_Debug_Interface/image03.png similarity index 100% rename from source/_static/amebad/Example_Guides/Debugging/Debugging_Using the Debug Interface/image03.png rename to source/_static/amebad/Example_Guides/Debugging/Debugging_Using_the_Debug_Interface/image03.png diff --git a/source/_static/amebad/Example_Guides/Debugging/Debugging_Using the Debug Interface/image04.png b/source/_static/amebad/Example_Guides/Debugging/Debugging_Using_the_Debug_Interface/image04.png similarity index 100% rename from source/_static/amebad/Example_Guides/Debugging/Debugging_Using the Debug Interface/image04.png rename to source/_static/amebad/Example_Guides/Debugging/Debugging_Using_the_Debug_Interface/image04.png diff --git a/source/_static/amebad/Example_Guides/Debugging/Debugging_Using the Debug Interface/image05.png b/source/_static/amebad/Example_Guides/Debugging/Debugging_Using_the_Debug_Interface/image05.png similarity index 100% rename from source/_static/amebad/Example_Guides/Debugging/Debugging_Using the Debug Interface/image05.png rename to source/_static/amebad/Example_Guides/Debugging/Debugging_Using_the_Debug_Interface/image05.png diff --git a/source/_static/amebad/Example_Guides/Debugging/Debugging_Using the Debug Interface/image06.png b/source/_static/amebad/Example_Guides/Debugging/Debugging_Using_the_Debug_Interface/image06.png similarity index 100% rename from source/_static/amebad/Example_Guides/Debugging/Debugging_Using the Debug Interface/image06.png rename to source/_static/amebad/Example_Guides/Debugging/Debugging_Using_the_Debug_Interface/image06.png diff --git a/source/_static/amebad/Example_Guides/Debugging/Debugging_Using the Debug Interface/image07.png b/source/_static/amebad/Example_Guides/Debugging/Debugging_Using_the_Debug_Interface/image07.png similarity index 100% rename from source/_static/amebad/Example_Guides/Debugging/Debugging_Using the Debug Interface/image07.png rename to source/_static/amebad/Example_Guides/Debugging/Debugging_Using_the_Debug_Interface/image07.png diff --git a/source/_static/amebad/Example_Guides/Debugging/Debugging_Using the Debug Interface/image08.png b/source/_static/amebad/Example_Guides/Debugging/Debugging_Using_the_Debug_Interface/image08.png similarity index 100% rename from source/_static/amebad/Example_Guides/Debugging/Debugging_Using the Debug Interface/image08.png rename to source/_static/amebad/Example_Guides/Debugging/Debugging_Using_the_Debug_Interface/image08.png diff --git a/source/_static/amebad/Example_Guides/Debugging/Debugging_Using the Debug Interface/image09.png b/source/_static/amebad/Example_Guides/Debugging/Debugging_Using_the_Debug_Interface/image09.png similarity index 100% rename from source/_static/amebad/Example_Guides/Debugging/Debugging_Using the Debug Interface/image09.png rename to source/_static/amebad/Example_Guides/Debugging/Debugging_Using_the_Debug_Interface/image09.png diff --git a/source/_static/amebad/Example_Guides/FlashMemory/Flash Memory_Store data in Flash EEPROM/image01.png b/source/_static/amebad/Example_Guides/FlashMemory/Flash_Memory_Store_data_in_Flash_EEPROM/image01.png similarity index 100% rename from source/_static/amebad/Example_Guides/FlashMemory/Flash Memory_Store data in Flash EEPROM/image01.png rename to source/_static/amebad/Example_Guides/FlashMemory/Flash_Memory_Store_data_in_Flash_EEPROM/image01.png diff --git a/source/_static/amebad/Example_Guides/FlashMemory/Flash Memory_Store data in Flash EEPROM/image02.png b/source/_static/amebad/Example_Guides/FlashMemory/Flash_Memory_Store_data_in_Flash_EEPROM/image02.png similarity index 100% rename from source/_static/amebad/Example_Guides/FlashMemory/Flash Memory_Store data in Flash EEPROM/image02.png rename to source/_static/amebad/Example_Guides/FlashMemory/Flash_Memory_Store_data_in_Flash_EEPROM/image02.png diff --git a/source/_static/amebad/Example_Guides/FlashMemory/Flash Memory_Use Flash Memory Larger Than 4K/image01.png b/source/_static/amebad/Example_Guides/FlashMemory/Flash_Memory_Use_Flash_Memory_Larger_Than_4K/image01.png similarity index 100% rename from source/_static/amebad/Example_Guides/FlashMemory/Flash Memory_Use Flash Memory Larger Than 4K/image01.png rename to source/_static/amebad/Example_Guides/FlashMemory/Flash_Memory_Use_Flash_Memory_Larger_Than_4K/image01.png diff --git a/source/_static/amebad/Example_Guides/GPIO/GPIO_Measure Temperature And Humidity/image01.png b/source/_static/amebad/Example_Guides/GPIO/GPIO_Measure_Temperature_And_Humidity/image01.png similarity index 100% rename from source/_static/amebad/Example_Guides/GPIO/GPIO_Measure Temperature And Humidity/image01.png rename to source/_static/amebad/Example_Guides/GPIO/GPIO_Measure_Temperature_And_Humidity/image01.png diff --git a/source/_static/amebad/Example_Guides/GPIO/GPIO_Measure Temperature And Humidity/image02.png b/source/_static/amebad/Example_Guides/GPIO/GPIO_Measure_Temperature_And_Humidity/image02.png similarity index 100% rename from source/_static/amebad/Example_Guides/GPIO/GPIO_Measure Temperature And Humidity/image02.png rename to source/_static/amebad/Example_Guides/GPIO/GPIO_Measure_Temperature_And_Humidity/image02.png diff --git a/source/_static/amebad/Example_Guides/GPIO/GPIO_Measure Temperature And Humidity/image03.png b/source/_static/amebad/Example_Guides/GPIO/GPIO_Measure_Temperature_And_Humidity/image03.png similarity index 100% rename from source/_static/amebad/Example_Guides/GPIO/GPIO_Measure Temperature And Humidity/image03.png rename to source/_static/amebad/Example_Guides/GPIO/GPIO_Measure_Temperature_And_Humidity/image03.png diff --git a/source/_static/amebad/Example_Guides/GPIO/GPIO_Measure Temperature And Humidity/image04.png b/source/_static/amebad/Example_Guides/GPIO/GPIO_Measure_Temperature_And_Humidity/image04.png similarity index 100% rename from source/_static/amebad/Example_Guides/GPIO/GPIO_Measure Temperature And Humidity/image04.png rename to source/_static/amebad/Example_Guides/GPIO/GPIO_Measure_Temperature_And_Humidity/image04.png diff --git a/source/_static/amebad/Example_Guides/GPIO/GPIO_Measure Temperature And Humidity/image05.png b/source/_static/amebad/Example_Guides/GPIO/GPIO_Measure_Temperature_And_Humidity/image05.png similarity index 100% rename from source/_static/amebad/Example_Guides/GPIO/GPIO_Measure Temperature And Humidity/image05.png rename to source/_static/amebad/Example_Guides/GPIO/GPIO_Measure_Temperature_And_Humidity/image05.png diff --git a/source/_static/amebad/Example_Guides/GPIO/GPIO_Measure Temperature And Humidity/image06.png b/source/_static/amebad/Example_Guides/GPIO/GPIO_Measure_Temperature_And_Humidity/image06.png similarity index 100% rename from source/_static/amebad/Example_Guides/GPIO/GPIO_Measure Temperature And Humidity/image06.png rename to source/_static/amebad/Example_Guides/GPIO/GPIO_Measure_Temperature_And_Humidity/image06.png diff --git a/source/_static/amebad/Example_Guides/GPIO/GPIO_Measure Temperature And Humidity/image07.png b/source/_static/amebad/Example_Guides/GPIO/GPIO_Measure_Temperature_And_Humidity/image07.png similarity index 100% rename from source/_static/amebad/Example_Guides/GPIO/GPIO_Measure Temperature And Humidity/image07.png rename to source/_static/amebad/Example_Guides/GPIO/GPIO_Measure_Temperature_And_Humidity/image07.png diff --git a/source/_static/amebad/Example_Guides/GPIO/GPIO_Measure Temperature And Humidity/image08.png b/source/_static/amebad/Example_Guides/GPIO/GPIO_Measure_Temperature_And_Humidity/image08.png similarity index 100% rename from source/_static/amebad/Example_Guides/GPIO/GPIO_Measure Temperature And Humidity/image08.png rename to source/_static/amebad/Example_Guides/GPIO/GPIO_Measure_Temperature_And_Humidity/image08.png diff --git a/source/_static/amebad/Example_Guides/GPIO/GPIO_Measure Temperature And Humidity/image09.png b/source/_static/amebad/Example_Guides/GPIO/GPIO_Measure_Temperature_And_Humidity/image09.png similarity index 100% rename from source/_static/amebad/Example_Guides/GPIO/GPIO_Measure Temperature And Humidity/image09.png rename to source/_static/amebad/Example_Guides/GPIO/GPIO_Measure_Temperature_And_Humidity/image09.png diff --git a/source/_static/amebad/Example_Guides/GPIO/GPIO_Measure_Temperature_And_Humidity/image10.png b/source/_static/amebad/Example_Guides/GPIO/GPIO_Measure_Temperature_And_Humidity/image10.png new file mode 100644 index 0000000..cb763be Binary files /dev/null and b/source/_static/amebad/Example_Guides/GPIO/GPIO_Measure_Temperature_And_Humidity/image10.png differ diff --git a/source/_static/amebad/Example_Guides/GPIO/GPIO_Measure Temperature And Humidity/image11.png b/source/_static/amebad/Example_Guides/GPIO/GPIO_Measure_Temperature_And_Humidity/image11.png similarity index 100% rename from source/_static/amebad/Example_Guides/GPIO/GPIO_Measure Temperature And Humidity/image11.png rename to source/_static/amebad/Example_Guides/GPIO/GPIO_Measure_Temperature_And_Humidity/image11.png diff --git a/source/_static/amebad/Example_Guides/GPIO/GPIO_Measure the Distance by Ultrasound Module/image01.png b/source/_static/amebad/Example_Guides/GPIO/GPIO_Measure_the_Distance_by_Ultrasound_Module/image01.png similarity index 100% rename from source/_static/amebad/Example_Guides/GPIO/GPIO_Measure the Distance by Ultrasound Module/image01.png rename to source/_static/amebad/Example_Guides/GPIO/GPIO_Measure_the_Distance_by_Ultrasound_Module/image01.png diff --git a/source/_static/amebad/Example_Guides/GPIO/GPIO_Measure the Distance by Ultrasound Module/image02.png b/source/_static/amebad/Example_Guides/GPIO/GPIO_Measure_the_Distance_by_Ultrasound_Module/image02.png similarity index 100% rename from source/_static/amebad/Example_Guides/GPIO/GPIO_Measure the Distance by Ultrasound Module/image02.png rename to source/_static/amebad/Example_Guides/GPIO/GPIO_Measure_the_Distance_by_Ultrasound_Module/image02.png diff --git a/source/_static/amebad/Example_Guides/GPIO/GPIO_Measure the Distance by Ultrasound Module/image03.png b/source/_static/amebad/Example_Guides/GPIO/GPIO_Measure_the_Distance_by_Ultrasound_Module/image03.png similarity index 100% rename from source/_static/amebad/Example_Guides/GPIO/GPIO_Measure the Distance by Ultrasound Module/image03.png rename to source/_static/amebad/Example_Guides/GPIO/GPIO_Measure_the_Distance_by_Ultrasound_Module/image03.png diff --git a/source/_static/amebad/Example_Guides/GPIO/GPIO_Measure the Distance by Ultrasound Module/image04.png b/source/_static/amebad/Example_Guides/GPIO/GPIO_Measure_the_Distance_by_Ultrasound_Module/image04.png similarity index 100% rename from source/_static/amebad/Example_Guides/GPIO/GPIO_Measure the Distance by Ultrasound Module/image04.png rename to source/_static/amebad/Example_Guides/GPIO/GPIO_Measure_the_Distance_by_Ultrasound_Module/image04.png diff --git a/source/_static/amebad/Example_Guides/GPIO/GPIO_Measure the Distance by Ultrasound Module/image05.png b/source/_static/amebad/Example_Guides/GPIO/GPIO_Measure_the_Distance_by_Ultrasound_Module/image05.png similarity index 100% rename from source/_static/amebad/Example_Guides/GPIO/GPIO_Measure the Distance by Ultrasound Module/image05.png rename to source/_static/amebad/Example_Guides/GPIO/GPIO_Measure_the_Distance_by_Ultrasound_Module/image05.png diff --git a/source/_static/amebad/Example_Guides/GPIO/GPIO_Measure the Distance by Ultrasound Module/image06.png b/source/_static/amebad/Example_Guides/GPIO/GPIO_Measure_the_Distance_by_Ultrasound_Module/image06.png similarity index 100% rename from source/_static/amebad/Example_Guides/GPIO/GPIO_Measure the Distance by Ultrasound Module/image06.png rename to source/_static/amebad/Example_Guides/GPIO/GPIO_Measure_the_Distance_by_Ultrasound_Module/image06.png diff --git a/source/_static/amebad/Example_Guides/GPIO/GPIO_Measure the Distance by Ultrasound Module/image07.png b/source/_static/amebad/Example_Guides/GPIO/GPIO_Measure_the_Distance_by_Ultrasound_Module/image07.png similarity index 100% rename from source/_static/amebad/Example_Guides/GPIO/GPIO_Measure the Distance by Ultrasound Module/image07.png rename to source/_static/amebad/Example_Guides/GPIO/GPIO_Measure_the_Distance_by_Ultrasound_Module/image07.png diff --git a/source/_static/amebad/Example_Guides/GPIO/GPIO_Measure the Distance by Ultrasound Module/image08.png b/source/_static/amebad/Example_Guides/GPIO/GPIO_Measure_the_Distance_by_Ultrasound_Module/image08.png similarity index 100% rename from source/_static/amebad/Example_Guides/GPIO/GPIO_Measure the Distance by Ultrasound Module/image08.png rename to source/_static/amebad/Example_Guides/GPIO/GPIO_Measure_the_Distance_by_Ultrasound_Module/image08.png diff --git a/source/_static/amebad/Example_Guides/GPIO/GPIO_Measure the Distance by Ultrasound Module/image09.png b/source/_static/amebad/Example_Guides/GPIO/GPIO_Measure_the_Distance_by_Ultrasound_Module/image09.png similarity index 100% rename from source/_static/amebad/Example_Guides/GPIO/GPIO_Measure the Distance by Ultrasound Module/image09.png rename to source/_static/amebad/Example_Guides/GPIO/GPIO_Measure_the_Distance_by_Ultrasound_Module/image09.png diff --git a/source/_static/amebad/Example_Guides/GPIO/GPIO_Measure the Distance by Ultrasound Module/image10.png b/source/_static/amebad/Example_Guides/GPIO/GPIO_Measure_the_Distance_by_Ultrasound_Module/image10.png similarity index 100% rename from source/_static/amebad/Example_Guides/GPIO/GPIO_Measure the Distance by Ultrasound Module/image10.png rename to source/_static/amebad/Example_Guides/GPIO/GPIO_Measure_the_Distance_by_Ultrasound_Module/image10.png diff --git a/source/_static/amebad/Example_Guides/GPIO/GPIO_Measure the Distance by Ultrasound Module/image11.png b/source/_static/amebad/Example_Guides/GPIO/GPIO_Measure_the_Distance_by_Ultrasound_Module/image11.png similarity index 100% rename from source/_static/amebad/Example_Guides/GPIO/GPIO_Measure the Distance by Ultrasound Module/image11.png rename to source/_static/amebad/Example_Guides/GPIO/GPIO_Measure_the_Distance_by_Ultrasound_Module/image11.png diff --git a/source/_static/amebad/Example_Guides/GPIO/GPIO_Measure the Distance by Ultrasound Module/image12.png b/source/_static/amebad/Example_Guides/GPIO/GPIO_Measure_the_Distance_by_Ultrasound_Module/image12.png similarity index 100% rename from source/_static/amebad/Example_Guides/GPIO/GPIO_Measure the Distance by Ultrasound Module/image12.png rename to source/_static/amebad/Example_Guides/GPIO/GPIO_Measure_the_Distance_by_Ultrasound_Module/image12.png diff --git a/source/_static/amebad/Example_Guides/GPIO/GPIO_Measure the Distance by Ultrasound Module/image13.png b/source/_static/amebad/Example_Guides/GPIO/GPIO_Measure_the_Distance_by_Ultrasound_Module/image13.png similarity index 100% rename from source/_static/amebad/Example_Guides/GPIO/GPIO_Measure the Distance by Ultrasound Module/image13.png rename to source/_static/amebad/Example_Guides/GPIO/GPIO_Measure_the_Distance_by_Ultrasound_Module/image13.png diff --git a/source/_static/amebad/Example_Guides/GPIO/GPIO_Measure the Distance by Ultrasound Module/image14.png b/source/_static/amebad/Example_Guides/GPIO/GPIO_Measure_the_Distance_by_Ultrasound_Module/image14.png similarity index 100% rename from source/_static/amebad/Example_Guides/GPIO/GPIO_Measure the Distance by Ultrasound Module/image14.png rename to source/_static/amebad/Example_Guides/GPIO/GPIO_Measure_the_Distance_by_Ultrasound_Module/image14.png diff --git a/source/_static/amebad/Example_Guides/GPIO/GPIO_Measure the Distance by Ultrasound Module/image15.png b/source/_static/amebad/Example_Guides/GPIO/GPIO_Measure_the_Distance_by_Ultrasound_Module/image15.png similarity index 100% rename from source/_static/amebad/Example_Guides/GPIO/GPIO_Measure the Distance by Ultrasound Module/image15.png rename to source/_static/amebad/Example_Guides/GPIO/GPIO_Measure_the_Distance_by_Ultrasound_Module/image15.png diff --git a/source/_static/amebad/Example_Guides/GPIO/GPIO_Use GPIO Interrupt to Control LED/image01.png b/source/_static/amebad/Example_Guides/GPIO/GPIO_Use_GPIO_Interrupt_to_Control_LED/image01.png similarity index 100% rename from source/_static/amebad/Example_Guides/GPIO/GPIO_Use GPIO Interrupt to Control LED/image01.png rename to source/_static/amebad/Example_Guides/GPIO/GPIO_Use_GPIO_Interrupt_to_Control_LED/image01.png diff --git a/source/_static/amebad/Example_Guides/GPIO/GPIO_Use GPIO Interrupt to Control LED/image02.png b/source/_static/amebad/Example_Guides/GPIO/GPIO_Use_GPIO_Interrupt_to_Control_LED/image02.png similarity index 100% rename from source/_static/amebad/Example_Guides/GPIO/GPIO_Use GPIO Interrupt to Control LED/image02.png rename to source/_static/amebad/Example_Guides/GPIO/GPIO_Use_GPIO_Interrupt_to_Control_LED/image02.png diff --git a/source/_static/amebad/Example_Guides/GPIO/GPIO_Use GPIO Interrupt to Control LED/image03.png b/source/_static/amebad/Example_Guides/GPIO/GPIO_Use_GPIO_Interrupt_to_Control_LED/image03.png similarity index 100% rename from source/_static/amebad/Example_Guides/GPIO/GPIO_Use GPIO Interrupt to Control LED/image03.png rename to source/_static/amebad/Example_Guides/GPIO/GPIO_Use_GPIO_Interrupt_to_Control_LED/image03.png diff --git a/source/_static/amebad/Example_Guides/GPIO/GPIO_Use GPIO Interrupt to Control LED/image04.png b/source/_static/amebad/Example_Guides/GPIO/GPIO_Use_GPIO_Interrupt_to_Control_LED/image04.png similarity index 100% rename from source/_static/amebad/Example_Guides/GPIO/GPIO_Use GPIO Interrupt to Control LED/image04.png rename to source/_static/amebad/Example_Guides/GPIO/GPIO_Use_GPIO_Interrupt_to_Control_LED/image04.png diff --git a/source/_static/amebad/Example_Guides/GPIO/GPIO_Use GPIO Interrupt to Control LED/image05.png b/source/_static/amebad/Example_Guides/GPIO/GPIO_Use_GPIO_Interrupt_to_Control_LED/image05.png similarity index 100% rename from source/_static/amebad/Example_Guides/GPIO/GPIO_Use GPIO Interrupt to Control LED/image05.png rename to source/_static/amebad/Example_Guides/GPIO/GPIO_Use_GPIO_Interrupt_to_Control_LED/image05.png diff --git a/source/_static/amebad/Example_Guides/GPIO/GPIO_Use GPIO Interrupt to Control LED/image06.PNG b/source/_static/amebad/Example_Guides/GPIO/GPIO_Use_GPIO_Interrupt_to_Control_LED/image06.png similarity index 100% rename from source/_static/amebad/Example_Guides/GPIO/GPIO_Use GPIO Interrupt to Control LED/image06.PNG rename to source/_static/amebad/Example_Guides/GPIO/GPIO_Use_GPIO_Interrupt_to_Control_LED/image06.png diff --git a/source/ameba_d/amb21/API_Documents/index.rst b/source/ameba_d/amb21/API_Documents/index.rst index 25fa9d8..1cd7775 100644 --- a/source/ameba_d/amb21/API_Documents/index.rst +++ b/source/ameba_d/amb21/API_Documents/index.rst @@ -19,4 +19,13 @@ API Documents NTPClient/index OTA/index PowerSave/index - WiFi/index \ No newline at end of file + RTC/index + SoftwareSerial/index + SPI/index + Sys/index + USB/index + WDT/index + WiFi/index + Wire/index + WS2812B/index + \ No newline at end of file diff --git a/source/ameba_d/amb21/Example_Guides/index.rst b/source/ameba_d/amb21/Example_Guides/index.rst index 7e5050f..8dc1bbb 100644 --- a/source/ameba_d/amb21/Example_Guides/index.rst +++ b/source/ameba_d/amb21/Example_Guides/index.rst @@ -5,7 +5,11 @@ Example Guides :maxdepth: 2 Basic/index + BLE/index + Debugging/index E-Paper/index + Flash Memory/index + GPIO/index HTTP/index NTP/index OTA/index diff --git a/source/ameba_d/amb23/API_Documents/index.rst b/source/ameba_d/amb23/API_Documents/index.rst index 25fa9d8..1cd7775 100644 --- a/source/ameba_d/amb23/API_Documents/index.rst +++ b/source/ameba_d/amb23/API_Documents/index.rst @@ -19,4 +19,13 @@ API Documents NTPClient/index OTA/index PowerSave/index - WiFi/index \ No newline at end of file + RTC/index + SoftwareSerial/index + SPI/index + Sys/index + USB/index + WDT/index + WiFi/index + Wire/index + WS2812B/index + \ No newline at end of file diff --git a/source/ameba_d/amb23/Example_Guides/index.rst b/source/ameba_d/amb23/Example_Guides/index.rst index 369a4bd..1da79a4 100644 --- a/source/ameba_d/amb23/Example_Guides/index.rst +++ b/source/ameba_d/amb23/Example_Guides/index.rst @@ -6,8 +6,12 @@ Example Guides AudioCodec/index Basic/index + BLE/index + Debugging/index E-Paper/index FatfsSDIO/index + Flash Memory/index + GPIO/index HTTP/index NTP/index OTA/index diff --git a/source/ameba_d/amb25/API_Documents/index.rst b/source/ameba_d/amb25/API_Documents/index.rst index 25fa9d8..1cd7775 100644 --- a/source/ameba_d/amb25/API_Documents/index.rst +++ b/source/ameba_d/amb25/API_Documents/index.rst @@ -19,4 +19,13 @@ API Documents NTPClient/index OTA/index PowerSave/index - WiFi/index \ No newline at end of file + RTC/index + SoftwareSerial/index + SPI/index + Sys/index + USB/index + WDT/index + WiFi/index + Wire/index + WS2812B/index + \ No newline at end of file diff --git a/source/ameba_d/amb25/Example_Guides/index.rst b/source/ameba_d/amb25/Example_Guides/index.rst index 7e5050f..8dc1bbb 100644 --- a/source/ameba_d/amb25/Example_Guides/index.rst +++ b/source/ameba_d/amb25/Example_Guides/index.rst @@ -5,7 +5,11 @@ Example Guides :maxdepth: 2 Basic/index + BLE/index + Debugging/index E-Paper/index + Flash Memory/index + GPIO/index HTTP/index NTP/index OTA/index diff --git a/source/ameba_d/amb26/API_Documents/index.rst b/source/ameba_d/amb26/API_Documents/index.rst index 25fa9d8..1cd7775 100644 --- a/source/ameba_d/amb26/API_Documents/index.rst +++ b/source/ameba_d/amb26/API_Documents/index.rst @@ -19,4 +19,13 @@ API Documents NTPClient/index OTA/index PowerSave/index - WiFi/index \ No newline at end of file + RTC/index + SoftwareSerial/index + SPI/index + Sys/index + USB/index + WDT/index + WiFi/index + Wire/index + WS2812B/index + \ No newline at end of file diff --git a/source/ameba_d/amb26/Example_Guides/index.rst b/source/ameba_d/amb26/Example_Guides/index.rst index 7e5050f..8dc1bbb 100644 --- a/source/ameba_d/amb26/Example_Guides/index.rst +++ b/source/ameba_d/amb26/Example_Guides/index.rst @@ -5,7 +5,11 @@ Example Guides :maxdepth: 2 Basic/index + BLE/index + Debugging/index E-Paper/index + Flash Memory/index + GPIO/index HTTP/index NTP/index OTA/index diff --git a/source/ameba_d/aw-cu488/API_Documents/index.rst b/source/ameba_d/aw-cu488/API_Documents/index.rst index 25fa9d8..1cd7775 100644 --- a/source/ameba_d/aw-cu488/API_Documents/index.rst +++ b/source/ameba_d/aw-cu488/API_Documents/index.rst @@ -19,4 +19,13 @@ API Documents NTPClient/index OTA/index PowerSave/index - WiFi/index \ No newline at end of file + RTC/index + SoftwareSerial/index + SPI/index + Sys/index + USB/index + WDT/index + WiFi/index + Wire/index + WS2812B/index + \ No newline at end of file diff --git a/source/ameba_d/aw-cu488/Example_Guides/index.rst b/source/ameba_d/aw-cu488/Example_Guides/index.rst index 7e5050f..8dc1bbb 100644 --- a/source/ameba_d/aw-cu488/Example_Guides/index.rst +++ b/source/ameba_d/aw-cu488/Example_Guides/index.rst @@ -5,7 +5,11 @@ Example Guides :maxdepth: 2 Basic/index + BLE/index + Debugging/index E-Paper/index + Flash Memory/index + GPIO/index HTTP/index NTP/index OTA/index diff --git a/source/ameba_d/bw16-typeb/API_Documents/index.rst b/source/ameba_d/bw16-typeb/API_Documents/index.rst index 25fa9d8..1cd7775 100644 --- a/source/ameba_d/bw16-typeb/API_Documents/index.rst +++ b/source/ameba_d/bw16-typeb/API_Documents/index.rst @@ -19,4 +19,13 @@ API Documents NTPClient/index OTA/index PowerSave/index - WiFi/index \ No newline at end of file + RTC/index + SoftwareSerial/index + SPI/index + Sys/index + USB/index + WDT/index + WiFi/index + Wire/index + WS2812B/index + \ No newline at end of file diff --git a/source/ameba_d/bw16-typeb/Example_Guides/index.rst b/source/ameba_d/bw16-typeb/Example_Guides/index.rst index 839d5e3..f152630 100644 --- a/source/ameba_d/bw16-typeb/Example_Guides/index.rst +++ b/source/ameba_d/bw16-typeb/Example_Guides/index.rst @@ -5,7 +5,11 @@ Example Guides :maxdepth: 2 Basic/index + BLE/index + Debugging/index E-Paper/index + Flash Memory/index + GPIO/index HTTP/index NTP/index OTA/index diff --git a/source/ameba_d/bw16-typec/API_Documents/index.rst b/source/ameba_d/bw16-typec/API_Documents/index.rst index 25fa9d8..1cd7775 100644 --- a/source/ameba_d/bw16-typec/API_Documents/index.rst +++ b/source/ameba_d/bw16-typec/API_Documents/index.rst @@ -19,4 +19,13 @@ API Documents NTPClient/index OTA/index PowerSave/index - WiFi/index \ No newline at end of file + RTC/index + SoftwareSerial/index + SPI/index + Sys/index + USB/index + WDT/index + WiFi/index + Wire/index + WS2812B/index + \ No newline at end of file diff --git a/source/ameba_d/bw16-typec/Example_Guides/index.rst b/source/ameba_d/bw16-typec/Example_Guides/index.rst index 839d5e3..f152630 100644 --- a/source/ameba_d/bw16-typec/Example_Guides/index.rst +++ b/source/ameba_d/bw16-typec/Example_Guides/index.rst @@ -5,7 +5,11 @@ Example Guides :maxdepth: 2 Basic/index + BLE/index + Debugging/index E-Paper/index + Flash Memory/index + GPIO/index HTTP/index NTP/index OTA/index diff --git a/source/ameba_pro2/amb82-mini/Example_Guides/Debugging/Debugging - Using the Debug Interface.rst b/source/ameba_pro2/amb82-mini/Example_Guides/Debugging/Debugging - Using the Debug Interface.rst new file mode 100644 index 0000000..7b7d2c2 --- /dev/null +++ b/source/ameba_pro2/amb82-mini/Example_Guides/Debugging/Debugging - Using the Debug Interface.rst @@ -0,0 +1,107 @@ +Debugging - Using the Debug Interface +===================================== + +.. contents:: + :local: + :depth: 2 + +Materials +--------- + +- `AMB82-mini `_ x 1 + +- SEGGER debug probe x 1 + +Example +------- + +Using the debugging feature available in the Arduino 2.0 IDE to debug your board. In this example, we will use SEGGER's debug probe with Arduino IDE's debug interface. Begin by installing the SEGGER debugging software. This can be found on SEGGER's official website: https://www.segger.com/downloads/jlink/ + +Before debugging, ensure that the code is optimized for debugging. Enable it by navigating to Sketch -> Optimize for Debugging. + +|image01| + +Open the Debug example, “File” -> “Examples” -> “Debugging” -> “ExampleDebug” + +|image02| + +Two files will open in the IDE; ExampleDebug.ino and debug_custom.json. Click on debug_custom.json. Under “serverArgs”, insert the directory path to Arduino15 folder, as well as the current version number of the tools folder. + +|image03| + +Connect the JLink Debug Probe and AmebaD board to the computer. Refer to the table below for the wiring connection between JLink Debug Probe and AmebaD board. For more information, please refer to: https://www.segger.com/products/debug-probes/j-link/technology/interface-description/ + ++-----------------------------------+-----------------------------------+ +| **JLink Debug Probe** | **AMB82 Mini Board** | ++===================================+===================================+ +| VTref | 3.3V | ++-----------------------------------+-----------------------------------+ +| GND | GND | ++-----------------------------------+-----------------------------------+ +| SWDIO | SWDIO | ++-----------------------------------+-----------------------------------+ +| SWCLK | SWCLK | ++-----------------------------------+-----------------------------------+ + +|image04| + +|image05| + +[STRIKEOUT:Note that, VTref (Pin 1) is indicate by the blue/red wire on the cable depending on the JLink Debug Probe that you are using.] + +AMB82 Mini boards have 4 hardware breakpoints. Hardware breakpoints can be set at the left of the code and are indicated by a red dot shown in line 42. Setting more than 4 hardware breakpoints will cause debugging to fail. You will need to stop debugging and reset if this happens. + +If 4 hardware breakpoint is not enough, software breakpoint can be used. Either of the instructions (\__BKPT() or \__asm\_\_("BKPT")) can be used to add a software breakpoint in the program execution. + +|image06| + +Upload the code and press the reset button on Ameba once the upload is finished. + +Once uploading is completed, reset the board. Start debugging by selecting the Debug button. This is located to the right of the upload button. Arduino will proceed with opening a gdb-server tab in the same window as the output window if all connections were connected correctly between JLink and board. This can sometimes take up to 10 seconds to set up. + +|image07| + +The line highlighted in yellow indicates which line of code the program is currently halted at. Debug console will appear to show the debugging information. + +|image08| + +To continue running the code after the breakpoint, use any of the single-stepping functions highlighted in the red box above (continue, step over, step into, step out, restart, stop) + +.. note :: For AmebaD boards, using any of the single-stepping functionality requires both hardware breakpoint resources to be free. You should remove or disable all existing breakpoints before using them. + +|image09| + +.. |image01| image:: ../../../../_static/amebapro2/Example_Guides/Debugging/Using_the_Debug_Interface/image01.png + :width: 1265 px + :height: 542 px + :scale: 70% +.. |image02| image:: ../../../../_static/amebapro2/Example_Guides/Debugging/Using_the_Debug_Interface/image02.png + :width: 1266 px + :height: 1040 px + :scale: 70% +.. |image03| image:: ../../../../_static/amebapro2/Example_Guides/Debugging/Using_the_Debug_Interface/image03.png + :width: 1813 px + :height: 457 px + :scale: 40% +.. |image04| image:: ../../../../_static/amebapro2/Example_Guides/Debugging/Using_the_Debug_Interface/image04.png + :width: 500 px + :height: 500 px +.. |image05| image:: ../../../../_static/amebapro2/Example_Guides/Debugging/Using_the_Debug_Interface/image05.png + :width: 3264 px + :height: 2448 px + :scale: 20% +.. |image06| image:: ../../../../_static/amebapro2/Example_Guides/Debugging/Using_the_Debug_Interface/image06.png + :width: 1266 px + :height: 831 px + :scale: 70% +.. |image07| image:: ../../../../_static/amebapro2/Example_Guides/Debugging/Using_the_Debug_Interface/image07.png + :width: 1256 px + :height: 711 px + :scale: 70% +.. |image08| image:: ../../../../_static/amebapro2/Example_Guides/Debugging/Using_the_Debug_Interface/image08.png + :width: 1365 px + :height: 728 px + :scale: 70% +.. |image09| image:: ../../../../_static/amebapro2/Example_Guides/Debugging/Using_the_Debug_Interface/image09.png + :width: 618 px + :height: 459 px diff --git a/source/ameba_pro2/amb82-mini/Example_Guides/Debugging/index.rst b/source/ameba_pro2/amb82-mini/Example_Guides/Debugging/index.rst new file mode 100644 index 0000000..a95620e --- /dev/null +++ b/source/ameba_pro2/amb82-mini/Example_Guides/Debugging/index.rst @@ -0,0 +1,7 @@ +Debugging +========= + +.. toctree:: + :maxdepth: 1 + + Debugging - Using the Debug Interface diff --git a/source/ameba_pro2/amb82-mini/Example_Guides/index.rst b/source/ameba_pro2/amb82-mini/Example_Guides/index.rst index 9003c98..af47dfd 100644 --- a/source/ameba_pro2/amb82-mini/Example_Guides/index.rst +++ b/source/ameba_pro2/amb82-mini/Example_Guides/index.rst @@ -6,6 +6,7 @@ Example Guides Basic/index BLE/index + Debugging/index E-Paper/index File System/index Flash Memory/index diff --git a/source/custom_script.py b/source/custom_script.py index 5e9d3ab..5bd8d46 100644 --- a/source/custom_script.py +++ b/source/custom_script.py @@ -11,43 +11,64 @@ , '_common/ameba_d/API_Documents/BLE', '_common/ameba_d/Example_Guides/OTA', '_common/ameba_d/API_Documents/EPDIF', '_common/ameba_d/API_Documents/FatfsSDcard', '_common/ameba_d/API_Documents/FlashMemory' , '_common/ameba_d/API_Documents/GPIO', '_common/ameba_d/Example_Guides/SPI', '_common/ameba_d/Example_Guides/Power Save', '_common/ameba_d/Example_Guides/WiFi', '_common/ameba_d/Example_Guides/HTTP' , '_common/ameba_d/Example_Guides/NTP', '_common/ameba_d/Example_Guides/RTC', '_common/ameba_d/API_Documents/Gtimer', '_common/ameba_d/API_Documents/Http', '_common/ameba_d/API_Documents/IRDevice' - , '_common/ameba_d/API_Documents/MDNS', '_common/ameba_d/API_Documents/MQTTClient', '_common/ameba_d/API_Documents/NTPClient', '_common/ameba_d/API_Documents/PowerSave'], + , '_common/ameba_d/API_Documents/MDNS', '_common/ameba_d/API_Documents/MQTTClient', '_common/ameba_d/API_Documents/NTPClient', '_common/ameba_d/API_Documents/PowerSave', '_common/ameba_d/API_Documents/RTC' + , '_common/ameba_d/API_Documents/SoftwareSerial', '_common/ameba_d/API_Documents/SPI', '_common/ameba_d/API_Documents/Sys', '_common/ameba_d/API_Documents/USB', '_common/ameba_d/API_Documents/WDT' + , '_common/ameba_d/API_Documents/Wire', '_common/ameba_d/API_Documents/WS2812B', '_common/ameba_d/Example_Guides/BLE', '_common/ameba_d/Example_Guides/Debugging', '_common/ameba_d/Example_Guides/Flash Memory' + , '_common/ameba_d/Example_Guides/GPIO'], 'amb23': ['_common/ameba_d/API_Documents/Analog', '_common/ameba_d/API_Documents/AudioCodec' , '_common/ameba_d/API_Documents/BLE', '_common/ameba_d/Example_Guides/OTA', '_common/ameba_d/API_Documents/EPDIF', '_common/ameba_d/API_Documents/FatfsSDcard', '_common/ameba_d/API_Documents/FlashMemory' , '_common/ameba_d/API_Documents/GPIO', '_common/ameba_d/Example_Guides/SPI', '_common/ameba_d/Example_Guides/Power Save', '_common/ameba_d/Example_Guides/WiFi', '_common/ameba_d/Example_Guides/HTTP' , '_common/ameba_d/Example_Guides/NTP', '_common/ameba_d/Example_Guides/RTC', '_common/ameba_d/API_Documents/Gtimer', '_common/ameba_d/API_Documents/Http', '_common/ameba_d/API_Documents/IRDevice' - , '_common/ameba_d/API_Documents/MDNS', '_common/ameba_d/API_Documents/MQTTClient', '_common/ameba_d/API_Documents/NTPClient', '_common/ameba_d/API_Documents/PowerSave'], + , '_common/ameba_d/API_Documents/MDNS', '_common/ameba_d/API_Documents/MQTTClient', '_common/ameba_d/API_Documents/NTPClient', '_common/ameba_d/API_Documents/PowerSave', '_common/ameba_d/API_Documents/RTC' + , '_common/ameba_d/API_Documents/SoftwareSerial', '_common/ameba_d/API_Documents/SPI', '_common/ameba_d/API_Documents/Sys', '_common/ameba_d/API_Documents/USB', '_common/ameba_d/API_Documents/WDT' + , '_common/ameba_d/API_Documents/Wire', '_common/ameba_d/API_Documents/WS2812B', '_common/ameba_d/Example_Guides/BLE', '_common/ameba_d/Example_Guides/Debugging', '_common/ameba_d/Example_Guides/Flash Memory' + , '_common/ameba_d/Example_Guides/GPIO'], 'amb25': ['_common/ameba_d/API_Documents/Analog', '_common/ameba_d/API_Documents/AudioCodec' , '_common/ameba_d/API_Documents/BLE', '_common/ameba_d/Example_Guides/OTA', '_common/ameba_d/API_Documents/EPDIF', '_common/ameba_d/API_Documents/FatfsSDcard', '_common/ameba_d/API_Documents/FlashMemory' , '_common/ameba_d/API_Documents/GPIO', '_common/ameba_d/Example_Guides/SPI', '_common/ameba_d/Example_Guides/Power Save', '_common/ameba_d/Example_Guides/WiFi', '_common/ameba_d/Example_Guides/HTTP' , '_common/ameba_d/Example_Guides/NTP', '_common/ameba_d/Example_Guides/RTC', '_common/ameba_d/API_Documents/Gtimer', '_common/ameba_d/API_Documents/Http', '_common/ameba_d/API_Documents/IRDevice' - , '_common/ameba_d/API_Documents/MDNS', '_common/ameba_d/API_Documents/MQTTClient', '_common/ameba_d/API_Documents/NTPClient', '_common/ameba_d/API_Documents/PowerSave'], + , '_common/ameba_d/API_Documents/MDNS', '_common/ameba_d/API_Documents/MQTTClient', '_common/ameba_d/API_Documents/NTPClient', '_common/ameba_d/API_Documents/PowerSave', '_common/ameba_d/API_Documents/RTC' + , '_common/ameba_d/API_Documents/SoftwareSerial', '_common/ameba_d/API_Documents/SPI', '_common/ameba_d/API_Documents/Sys', '_common/ameba_d/API_Documents/USB', '_common/ameba_d/API_Documents/WDT' + , '_common/ameba_d/API_Documents/Wire', '_common/ameba_d/API_Documents/WS2812B', '_common/ameba_d/Example_Guides/BLE', '_common/ameba_d/Example_Guides/Debugging', '_common/ameba_d/Example_Guides/Flash Memory' + , '_common/ameba_d/Example_Guides/GPIO'], 'amb26': ['_common/ameba_d/API_Documents/Analog', '_common/ameba_d/API_Documents/AudioCodec' , '_common/ameba_d/API_Documents/BLE', '_common/ameba_d/Example_Guides/OTA', '_common/ameba_d/API_Documents/EPDIF', '_common/ameba_d/API_Documents/FatfsSDcard', '_common/ameba_d/API_Documents/FlashMemory' , '_common/ameba_d/API_Documents/GPIO', '_common/ameba_d/Example_Guides/SPI', '_common/ameba_d/Example_Guides/Power Save', '_common/ameba_d/Example_Guides/WiFi', '_common/ameba_d/Example_Guides/HTTP' , '_common/ameba_d/Example_Guides/NTP', '_common/ameba_d/Example_Guides/RTC', '_common/ameba_d/API_Documents/Gtimer', '_common/ameba_d/API_Documents/Http', '_common/ameba_d/API_Documents/IRDevice' - , '_common/ameba_d/API_Documents/MDNS', '_common/ameba_d/API_Documents/MQTTClient', '_common/ameba_d/API_Documents/NTPClient', '_common/ameba_d/API_Documents/PowerSave'], + , '_common/ameba_d/API_Documents/MDNS', '_common/ameba_d/API_Documents/MQTTClient', '_common/ameba_d/API_Documents/NTPClient', '_common/ameba_d/API_Documents/PowerSave', '_common/ameba_d/API_Documents/RTC' + , '_common/ameba_d/API_Documents/SoftwareSerial', '_common/ameba_d/API_Documents/SPI', '_common/ameba_d/API_Documents/Sys', '_common/ameba_d/API_Documents/USB', '_common/ameba_d/API_Documents/WDT' + , '_common/ameba_d/API_Documents/Wire', '_common/ameba_d/API_Documents/WS2812B', '_common/ameba_d/Example_Guides/BLE', '_common/ameba_d/Example_Guides/Debugging', '_common/ameba_d/Example_Guides/Flash Memory' + , '_common/ameba_d/Example_Guides/GPIO'], 'bw16-typeb': ['_common/ameba_d/API_Documents/Analog', '_common/ameba_d/API_Documents/AudioCodec' , '_common/ameba_d/API_Documents/BLE', '_common/ameba_d/Example_Guides/OTA', '_common/ameba_d/API_Documents/EPDIF', '_common/ameba_d/API_Documents/FatfsSDcard', '_common/ameba_d/API_Documents/FlashMemory' , '_common/ameba_d/API_Documents/GPIO', '_common/ameba_d/Example_Guides/SPI', '_common/ameba_d/Example_Guides/Power Save', '_common/ameba_d/Example_Guides/WiFi', '_common/ameba_d/Example_Guides/HTTP' , '_common/ameba_d/Example_Guides/NTP', '_common/ameba_d/Example_Guides/RTC', '_common/ameba_d/API_Documents/Gtimer', '_common/ameba_d/API_Documents/Http', '_common/ameba_d/API_Documents/IRDevice' - , '_common/ameba_d/API_Documents/MDNS', '_common/ameba_d/API_Documents/MQTTClient', '_common/ameba_d/API_Documents/NTPClient', '_common/ameba_d/API_Documents/PowerSave'], + , '_common/ameba_d/API_Documents/MDNS', '_common/ameba_d/API_Documents/MQTTClient', '_common/ameba_d/API_Documents/NTPClient', '_common/ameba_d/API_Documents/PowerSave', '_common/ameba_d/API_Documents/RTC' + , '_common/ameba_d/API_Documents/SoftwareSerial', '_common/ameba_d/API_Documents/SPI', '_common/ameba_d/API_Documents/Sys', '_common/ameba_d/API_Documents/USB', '_common/ameba_d/API_Documents/WDT' + , '_common/ameba_d/API_Documents/Wire', '_common/ameba_d/API_Documents/WS2812B', '_common/ameba_d/Example_Guides/BLE', '_common/ameba_d/Example_Guides/Debugging', '_common/ameba_d/Example_Guides/Flash Memory' + , '_common/ameba_d/Example_Guides/GPIO'], 'aw-cu488': ['_common/ameba_d/API_Documents/Analog', '_common/ameba_d/API_Documents/AudioCodec' , '_common/ameba_d/API_Documents/BLE', '_common/ameba_d/Example_Guides/OTA', '_common/ameba_d/API_Documents/EPDIF', '_common/ameba_d/API_Documents/FatfsSDcard', '_common/ameba_d/API_Documents/FlashMemory' , '_common/ameba_d/API_Documents/GPIO', '_common/ameba_d/Example_Guides/SPI', '_common/ameba_d/Example_Guides/Power Save', '_common/ameba_d/Example_Guides/WiFi', '_common/ameba_d/Example_Guides/HTTP' , '_common/ameba_d/Example_Guides/NTP', '_common/ameba_d/Example_Guides/RTC', '_common/ameba_d/API_Documents/Gtimer', '_common/ameba_d/API_Documents/Http', '_common/ameba_d/API_Documents/IRDevice' - , '_common/ameba_d/API_Documents/MDNS', '_common/ameba_d/API_Documents/MQTTClient', '_common/ameba_d/API_Documents/NTPClient', '_common/ameba_d/API_Documents/PowerSave'], + , '_common/ameba_d/API_Documents/MDNS', '_common/ameba_d/API_Documents/MQTTClient', '_common/ameba_d/API_Documents/NTPClient', '_common/ameba_d/API_Documents/PowerSave', '_common/ameba_d/API_Documents/RTC' + , '_common/ameba_d/API_Documents/SoftwareSerial', '_common/ameba_d/API_Documents/SPI', '_common/ameba_d/API_Documents/Sys', '_common/ameba_d/API_Documents/USB', '_common/ameba_d/API_Documents/WDT' + , '_common/ameba_d/API_Documents/Wire', '_common/ameba_d/API_Documents/WS2812B', '_common/ameba_d/Example_Guides/BLE', '_common/ameba_d/Example_Guides/Debugging', '_common/ameba_d/Example_Guides/Flash Memory' + , '_common/ameba_d/Example_Guides/GPIO'], 'bw16-typec': ['_common/ameba_d/API_Documents/Analog', '_common/ameba_d/API_Documents/AudioCodec' , '_common/ameba_d/API_Documents/BLE', '_common/ameba_d/Example_Guides/OTA', '_common/ameba_d/API_Documents/EPDIF', '_common/ameba_d/API_Documents/FatfsSDcard', '_common/ameba_d/API_Documents/FlashMemory' , '_common/ameba_d/API_Documents/GPIO', '_common/ameba_d/Example_Guides/SPI', '_common/ameba_d/Example_Guides/Power Save', '_common/ameba_d/Example_Guides/WiFi', '_common/ameba_d/Example_Guides/HTTP' , '_common/ameba_d/Example_Guides/NTP', '_common/ameba_d/Example_Guides/RTC', '_common/ameba_d/API_Documents/Gtimer', '_common/ameba_d/API_Documents/Http', '_common/ameba_d/API_Documents/IRDevice' - , '_common/ameba_d/API_Documents/MDNS', '_common/ameba_d/API_Documents/MQTTClient', '_common/ameba_d/API_Documents/NTPClient', '_common/ameba_d/API_Documents/PowerSave'], + , '_common/ameba_d/API_Documents/MDNS', '_common/ameba_d/API_Documents/MQTTClient', '_common/ameba_d/API_Documents/NTPClient', '_common/ameba_d/API_Documents/PowerSave', '_common/ameba_d/API_Documents/RTC' + , '_common/ameba_d/API_Documents/SoftwareSerial', '_common/ameba_d/API_Documents/SPI', '_common/ameba_d/API_Documents/Sys', '_common/ameba_d/API_Documents/USB', '_common/ameba_d/API_Documents/WDT' + , '_common/ameba_d/API_Documents/Wire', '_common/ameba_d/API_Documents/WS2812B', '_common/ameba_d/Example_Guides/BLE', '_common/ameba_d/Example_Guides/Debugging', '_common/ameba_d/Example_Guides/Flash Memory' + , '_common/ameba_d/Example_Guides/GPIO'], } def create_folder(folder_name):