Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: max32625pico maxim-dev mbed-rtos USBDevice
Fork of PICO_USB_I2C_SPI by
main.cpp
- Committer:
- seanburford
- Date:
- 2017-11-20
- Revision:
- 14:7a4b0f9d1474
- Parent:
- 13:fed6ff32bf5d
- Child:
- 15:9801f08ce0ee
File content as of revision 14:7a4b0f9d1474:
#include "mbed.h"
#include "rtos.h"
#include "gpio_api.h"
#include "max32625pico.h"
// #define MAX_GPIO_API 1
#define MAX_I2C_API 1
static DigitalOut rLED(LED1);
static DigitalOut gLED(LED2);
static DigitalOut bLED(LED3);
int main()
{
rLED = LED_ON;
gLED = LED_ON;
bLED = LED_OFF;
MAX32625PICO pico(
MAX32625PICO::IOH_3V3, MAX32625PICO::VIO_IOH, MAX32625PICO::VIO_IOH);
#ifdef MAX_GPIO_API
gpio_t gpio_p1_6;
gpio_t gpio_p1_7;
gpio_init(&gpio_p1_6, P1_6);
gpio_init(&gpio_p1_7, P1_7);
// gpio_api.c:104 sets the pin to MXC_V_GPIO_OUT_MODE_HIGH_Z_WEAK_PULLUP
pin_dir_mode(P1_6, PIN_INPUT, PullUp);
pin_dir_mode(P1_7, PIN_INPUT, PullUp);
#else
DigitalInOut(P1_6, PIN_INPUT, PullUp, 1);
DigitalInOut(P1_7, PIN_INPUT, PullUp, 1);
#endif
Thread::wait(15);
#ifdef MAX_I2C_API
i2c_t i2c_o;
i2c_init(&i2c_o, P1_6, P1_7);
#else
I2C i2c(P1_6, P1_7);
#endif
rLED = LED_OFF;
gLED = LED_OFF;
char dbuf[32];
while(1) {
Thread::wait(15);
#ifdef MAX_I2C_API
if (i2c_read(&i2c_o, 0x55, dbuf, 8, 1) > 0) {
#else
if (i2c.read(0x55, dbuf, 8) == 0) {
#endif
gLED = !gLED;
} else {
rLED = !rLED;
}
}
}
