Microchip® Advanced Software Framework

at24mac602-arch.c File Reference
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#include "contiki.h"
#include "asf.h"
#include "at24mac602.h"
#include "at24mac602-arch.h"
#include "samd21_xplained_pro.h"
#include "trx_access.h"

Macros

#define AT24MAC602_SCL_PIN   PIN_PA09
 
#define AT24MAC602_SDA_PIN   PIN_PA08
 
#define COMMAND_READ   0xB1 /* Read I2C command */
 
#define COMMAND_WRITE   0xB0 /* Write I2C command */
 
#define EEPROM_EUI64_ADDRESS   0x98
 
#define EEPROM_SERIAL128_ADDRESS   0x80
 
#define LEN_EUI   8
 
#define LEN_SERIALNUMBER   16
 
#define OUTPUT_BYTE(b)
 
#define SCL_0()   port_pin_set_output_level(AT24MAC602_SCL_PIN, false)
 
#define SCL_1()   port_pin_set_output_level(AT24MAC602_SCL_PIN, true)
 
#define SDA_0()   port_pin_set_output_level(AT24MAC602_SDA_PIN, false)
 
#define SDA_1()   port_pin_set_output_level(AT24MAC602_SDA_PIN, true)
 
#define SDA_IS_1()   port_pin_get_input_level(AT24MAC602_SDA_PIN)
 
#define START_CONDITION()
 
#define STOP_CONDITION()
 

Functions

int at24mac602_arch_init (void)
 Init the AT24MAC602 EEPROM arch dependencies, ie MCU pins etc. More...
 
int at24mac602_arch_read_eui64 (eui64_t *eui)
 Read the EEPROM EUI-64. More...
 
int at24mac602_arch_read_serial128 (at24mac602_serialnumber_t *serial)
 Read the EEPROM EUI-64. More...
 
static int read (uint8_t address, uint8_t len, uint8_t *buf)
 
void reset_i2c (void)
 
static void set_sda_input (void)
 
static void set_sda_output (void)
 

#define AT24MAC602_SCL_PIN   PIN_PA09

Referenced by at24mac602_arch_init().

#define AT24MAC602_SDA_PIN   PIN_PA08
#define COMMAND_READ   0xB1 /* Read I2C command */

Referenced by read().

#define COMMAND_WRITE   0xB0 /* Write I2C command */

Referenced by read().

#define EEPROM_EUI64_ADDRESS   0x98
#define EEPROM_SERIAL128_ADDRESS   0x80
#define LEN_EUI   8
#define LEN_SERIALNUMBER   16
#define OUTPUT_BYTE (   b)
Value:
do { \
for(n = 7; n >= 0; n--) { \
/* send bit, MSB */ \
if(b & (1 << n)) { \
SDA_1(); \
} else { \
SDA_0(); \
} \
SCL_1(); \
} \
SCL_0(); \
} while(0)
#define SCL_1()
Definition: at24mac602-arch.c:56
static struct uip_ds6_notification n
Definition: simple-rpl.c:48
#define SDA_1()
Definition: at24mac602-arch.c:58
if(memp!=NULL)
Definition: memp.c:407
#define SCL_0()
Definition: at24mac602-arch.c:55
#define SDA_0()
Definition: at24mac602-arch.c:57
static for(s->u.count=0;s->u.count< UIP_CONNS;++s->u.count)
Definition: httpd-cgi.c:232

Referenced by read().

Referenced by read(), and reset_i2c().

Referenced by read(), and reset_i2c().

Referenced by read().

#define SDA_IS_1 ( )    port_pin_get_input_level(AT24MAC602_SDA_PIN)

Referenced by read().

#define START_CONDITION ( )
Value:
do { \
SCL_0(); \
} while(0)
#define SCL_1()
Definition: at24mac602-arch.c:56
#define SDA_1()
Definition: at24mac602-arch.c:58
#define SCL_0()
Definition: at24mac602-arch.c:55
#define SDA_0()
Definition: at24mac602-arch.c:57

Referenced by read(), and reset_i2c().

#define STOP_CONDITION ( )
Value:
do { \
SCL_0(); \
} while(0)
#define SCL_1()
Definition: at24mac602-arch.c:56
#define SDA_1()
Definition: at24mac602-arch.c:58
#define SCL_0()
Definition: at24mac602-arch.c:55
#define SDA_0()
Definition: at24mac602-arch.c:57

Referenced by read(), and reset_i2c().

int at24mac602_arch_init ( void  )

Init the AT24MAC602 EEPROM arch dependencies, ie MCU pins etc.

Return values
0Success
-1Fail

References AT24MAC602_SCL_PIN, AT24MAC602_SDA_PIN, port_config::direction, port_get_config_defaults(), PORT_PIN_DIR_OUTPUT, port_pin_set_config(), and port_pin_set_output_level().

Referenced by at24mac602_init(), and at24mac602_read_eui64().

int at24mac602_arch_read_eui64 ( eui64_t eui)

Read the EEPROM EUI-64.

Parameters
euiPointer EUI-64 structure
Return values
0Success
-1Fail

References EEPROM_EUI64_ADDRESS, i, LEN_EUI, printf, read(), readbuf, and eui64_t::u8.

Referenced by at24mac602_read_eui64().

int at24mac602_arch_read_serial128 ( at24mac602_serialnumber_t serial)

Read the EEPROM EUI-64.

Parameters
euiPointer EUI-64 structure
Return values
0Success
-1Fail

References EEPROM_SERIAL128_ADDRESS, i, LEN_SERIALNUMBER, printf, read(), readbuf, and at24mac602_serialnumber_t::u8.

Referenced by at24mac602_read_serial128().

void reset_i2c ( void  )
static void set_sda_input ( void  )
static
static void set_sda_output ( void  )
static