Appendix A - Sample Code - Infineon MERUS MA120 Series User Manual

Table of Contents

Advertisement

User manual for MA120xxx reference boards
Appendix A – sample code
4
Appendix A – sample code
/*----------------------------------------------------------
* Title: I
2
C basic communication set-up
* Author: Rien Oortgiesen
* This code demonstrates basic I
* using Arduino UNO together with MA120XXX devices
* Use:
* The code uses I
2
C lib from Wayne Truchsess which allows repeated
* start and can be used in an interrupt service routine
*
* I
C hardware config:
2
* Uno breakout: SCL = A5; SDA = A4 GND = GND;
* Reference board CONN_COM: SCL = pin 4; SDA = pin 3; GND = pin 2
*
* Revisions:
* D1a: use of external lib initial test working
* F1: final version for demonstration
*
* This code is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*/
#include <I2C.h>
const byte LED = 13; // LED pin number
const byte BUTTON = 2; // BUTTON pin number
volatile int state = LOW;
// Interrupt Service Routine (ISR)
void switchPressed ()
{
state = !state; // change state
digitalWrite(LED, state); //write state to LED
write_I2C(state); //jump to I
}
void setup ()
{
pinMode (LED, OUTPUT); // so we can update the LED
digitalWrite (BUTTON, HIGH); // internal pull-up resistor
Application Note
C communication
2
C handling
2
25 of 28
V 1.0
2019-04-28

Advertisement

Table of Contents
loading

This manual is also suitable for:

Merus ma12070Merus ma12040pMerus ma12040Merus ma12070p

Table of Contents