Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ tags:
- Audio Jack
author: 'Jacob Hylén'
hardware:
- hardware/08.mega/boards/giga-r1-wifi
- hardware/10.mega/boards/giga-r1-wifi
software:
- ide-v1
- ide-v2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
title: Guide to GIGA R1 Advanced ADC/DAC and Audio Features
description: 'Learn how to use the ADC/DAC features, along with useful examples on how to generate waveforms and play audio from a file.'
author: José Bagur, Taddy Chung & Karl Söderby
hardware:
- hardware/10.mega/boards/giga-r1-wifi
tags: [ADC, DAC, Audio, USB]
---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ title: GIGA R1 Camera Guide
description: Learn about the GIGA R1 WiFi's camera connector, and how to use existing examples.
tags: [ArduCAM, Camera, Processing]
author: Karl Söderby
hardware:
- hardware/10.mega/boards/giga-r1-wifi
---

The GIGA R1 has a dedicated camera connector that allows certain camera modules to mount directly on the board. This makes it possible to add machine vision to your GIGA R1 board without much effort at all.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
title: Guide to GIGA R1 Dual Cores
description: Learn how to access and control the M4 and M7 cores on the GIGA R1, and how to communicate between them using RPC.
author: Karl Söderby
hardware:
- hardware/10.mega/boards/giga-r1-wifi
tags: [Dual Core, M4, M7]
---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
title: Getting Started with GIGA R1 WiFi
description: A step-by-step guide to install the board package needed for the GIGA R1 WiFi board.
author: Karl Söderby
hardware:
- hardware/10.mega/boards/giga-r1-wifi
tags: [GIGA R1 WiFi, Installation, IDE]
---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
title: MicroPython on the GIGA R1
description: Get started with MicroPython on the GIGA R1.
author: Karl Söderby
hardware:
- hardware/10.mega/boards/giga-r1-wifi
tags: [MicroPython, dfu-util]
---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
title: Guide to Arduino GIGA USB Features
description: 'Learn how you can turn your USB device into a mouse or keyboard, how to read & write to a USB mass storage, and connecting a keyboard via the USB-A connector.'
author: Karl Söderby
hardware:
- hardware/10.mega/boards/giga-r1-wifi
tags: [USB, USB HID, USBHost, Mass Storage, Keyboard, Mouse]
---

Expand Down Expand Up @@ -92,234 +94,19 @@ FILE *f = fopen("/usb/text.txt", "r+");

Below is an example sketch that can be used to **list** files in a USB mass storage device.

```arduino
#include <DigitalOut.h>
#include <FATFileSystem.h>
#include <Arduino_USBHostMbed5.h>

USBHostMSD msd;
mbed::FATFileSystem usb("usb");


void setup()
{
Serial.begin(115200);

pinMode(PA_15, OUTPUT); //enable the USB-A port
digitalWrite(PA_15, HIGH);

while (!Serial)
;

Serial.println("Starting USB Dir List example...");

// if you are using a Max Carrier uncomment the following line
// start_hub();

while (!msd.connect()) {
//while (!port.connected()) {
delay(1000);
}

Serial.print("Mounting USB device... ");
int err = usb.mount(&msd);
if (err) {
Serial.print("Error mounting USB device ");
Serial.println(err);
while (1);
}
Serial.println("done.");

char buf[256];

// Display the root directory
Serial.print("Opening the root directory... ");
DIR* d = opendir("/usb/");
Serial.println(!d ? "Fail :(" : "Done");
if (!d) {
snprintf(buf, sizeof(buf), "error: %s (%d)\r\n", strerror(errno), -errno);
Serial.print(buf);
}
Serial.println("done.");

Serial.println("Root directory:");
unsigned int count { 0 };
while (true) {
struct dirent* e = readdir(d);
if (!e) {
break;
}
count++;
snprintf(buf, sizeof(buf), " %s\r\n", e->d_name);
Serial.print(buf);
}
Serial.print(count);
Serial.println(" files found!");

snprintf(buf, sizeof(buf), "Closing the root directory... ");
Serial.print(buf);
fflush(stdout);
err = closedir(d);
snprintf(buf, sizeof(buf), "%s\r\n", (err < 0 ? "Fail :(" : "OK"));
Serial.print(buf);
if (err < 0) {
snprintf(buf, sizeof(buf), "error: %s (%d)\r\n", strerror(errno), -errno);
Serial.print(buf);
}
}

void loop()
{
}
```
<CodeBlock url="https://github.com/arduino-libraries/Arduino_USBHostMbed5/blob/master/examples/DirList/DirList.ino" className="arduino"/>

### File Read

Below is an example sketch that can be used to **read** files from a USB mass storage device.

```arduino
#include <Arduino_USBHostMbed5.h>
#include <DigitalOut.h>
#include <FATFileSystem.h>

USBHostMSD msd;
mbed::FATFileSystem usb("usb");

// If you are using a Portenta Machine Control uncomment the following line
mbed::DigitalOut otg(PB_14, 0);

void setup() {
Serial.begin(115200);

pinMode(PA_15, OUTPUT); //enable the USB-A port
digitalWrite(PA_15, HIGH);

while (!Serial);

delay(2500);
Serial.println("Starting USB File Read example...");

// if you are using a Max Carrier uncomment the following line
//start_hub();

while (!msd.connect()) {
delay(1000);
}

Serial.println("Mounting USB device...");
int err = usb.mount(&msd);
if (err) {
Serial.print("Error mounting USB device ");
Serial.println(err);
while (1);
}
Serial.print("read done ");
mbed::fs_file_t file;
struct dirent *ent;
int dirIndex = 0;
int res = 0;
Serial.println("Open file..");
FILE *f = fopen("/usb/Arduino.txt", "r+");
char buf[256];
Serial.println("File content:");

while (fgets(buf, 256, f) != NULL) {
Serial.print(buf);
}

Serial.println("File closing");
fflush(stdout);
err = fclose(f);
if (err < 0) {
Serial.print("fclose error:");
Serial.print(strerror(errno));
Serial.print(" (");
Serial.print(-errno);
Serial.print(")");
} else {
Serial.println("File closed");
}
}

void loop() {

}
```
<CodeBlock url="https://github.com/arduino-libraries/Arduino_USBHostMbed5/blob/master/examples/FileRead/FileRead.ino" className="arduino"/>

### File Write

Below is an example sketch that can be used to **write** files from a USB mass storage device.

```arduino
#include <Arduino_USBHostMbed5.h>
#include <DigitalOut.h>
#include <FATFileSystem.h>

USBHostMSD msd;
mbed::FATFileSystem usb("usb");

// mbed::DigitalOut pin5(PC_6, 0);
mbed::DigitalOut otg(PB_8, 1);

void setup() {
Serial.begin(115200);

pinMode(PA_15, OUTPUT); //enable the USB-A port
digitalWrite(PA_15, HIGH);

while (!Serial);

msd.connect();

while (!msd.connected()) {
//while (!port.connected()) {
delay(1000);
}

Serial.println("Mounting USB device...");
int err = usb.mount(&msd);
if (err) {
Serial.print("Error mounting USB device ");
Serial.println(err);
while (1);
}
Serial.print("read done ");
mbed::fs_file_t file;
struct dirent *ent;
int dirIndex = 0;
int res = 0;
Serial.println("Open /usb/numbers.txt");
FILE *f = fopen("/usb/numbers.txt", "w+");
for (int i = 0; i < 10; i++) {
Serial.print("Writing numbers (");
Serial.print(i);
Serial.println("/10)");
fflush(stdout);
err = fprintf(f, "%d\n", i);
if (err < 0) {
Serial.println("Fail :(");
error("error: %s (%d)\n", strerror(errno), -errno);
}
}

Serial.println("File closing");
fflush(stdout);
err = fclose(f);
if (err < 0) {
Serial.print("fclose error:");
Serial.print(strerror(errno));
Serial.print(" (");
Serial.print(-errno);
Serial.print(")");
} else {
Serial.println("File closed");
}
}

void loop() {

}
```
<CodeBlock url="https://github.com/arduino-libraries/Arduino_USBHostMbed5/blob/master/examples/FileWrite/FileWrite.ino" className="arduino"/>

### Datalogger Example

Expand Down Expand Up @@ -439,35 +226,7 @@ Please note that this library is in **Alpha** development stage. This means supp

***The USBHostGiga library is not available in the Arduino IDE and needs to be installed manually. You can do so my navigating to `Sketch` > `Include Library` > `Add .ZIP Library`.***

```arduino
#include "USBHostGiga.h"

//REDIRECT_STDOUT_TO(Serial)
Keyboard keyb;
HostSerial ser;

void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
while (!Serial);
pinMode(PA_15, OUTPUT);
keyb.begin();
ser.begin();
}


void loop() {
if (keyb.available()) {
auto _key = keyb.read();
Serial.println(keyb.getAscii(_key));
}
while (ser.available()) {
auto _char = ser.read();
Serial.write(_char);
}
//delay(1);
}
```
<CodeBlock url="https://github.com/arduino-libraries/USBHostGiga/blob/master/examples/KeyboardGiga/KeyboardGiga.ino" className="arduino"/>

## USB HID

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
title: GIGA R1 WiFi Network Examples
description: Discover examples compatible with the WiFi library included in the GIGA core.
author: Karl Söderby
hardware:
- hardware/10.mega/boards/giga-r1-wifi
tags: [Wi-Fi, Web Server, AP Mode, SSL, UDP]
---

Expand Down