#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 |
Referenced by at24mac602_arch_init(), set_sda_input(), and set_sda_output().
#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 |
Referenced by at24mac602_arch_read_eui64().
#define EEPROM_SERIAL128_ADDRESS 0x80 |
Referenced by at24mac602_arch_read_serial128().
#define LEN_EUI 8 |
Referenced by at24mac602_arch_read_eui64().
#define LEN_SERIALNUMBER 16 |
Referenced by at24mac602_arch_read_serial128().
#define OUTPUT_BYTE | ( | b | ) |
#define SCL_0 | ( | ) | port_pin_set_output_level(AT24MAC602_SCL_PIN, false) |
Referenced by read(), and reset_i2c().
#define SCL_1 | ( | ) | port_pin_set_output_level(AT24MAC602_SCL_PIN, true) |
Referenced by read(), and reset_i2c().
#define SDA_0 | ( | ) | port_pin_set_output_level(AT24MAC602_SDA_PIN, false) |
Referenced by read().
#define SDA_1 | ( | ) | port_pin_set_output_level(AT24MAC602_SDA_PIN, true) |
#define SDA_IS_1 | ( | ) | port_pin_get_input_level(AT24MAC602_SDA_PIN) |
Referenced by read().
#define START_CONDITION | ( | ) |
Referenced by read(), and reset_i2c().
#define STOP_CONDITION | ( | ) |
Referenced by read(), and reset_i2c().
int at24mac602_arch_init | ( | void | ) |
Init the AT24MAC602 EEPROM arch dependencies, ie MCU pins etc.
0 | Success |
-1 | Fail |
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.
eui | Pointer EUI-64 structure |
0 | Success |
-1 | Fail |
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.
eui | Pointer EUI-64 structure |
0 | Success |
-1 | Fail |
References EEPROM_SERIAL128_ADDRESS, i, LEN_SERIALNUMBER, printf, read(), readbuf, and at24mac602_serialnumber_t::u8.
Referenced by at24mac602_read_serial128().
|
static |
References COMMAND_READ, COMMAND_WRITE, ENTER_TRX_CRITICAL_REGION, i, LEAVE_TRX_CRITICAL_REGION, len, n, OUTPUT_BYTE, reset_i2c(), SCL_0, SCL_1, SDA_0, SDA_IS_1, set_sda_input(), set_sda_output(), START_CONDITION, and STOP_CONDITION.
Referenced by at24mac602_arch_read_eui64(), and at24mac602_arch_read_serial128().
void reset_i2c | ( | void | ) |
References i, SCL_0, SCL_1, set_sda_output(), START_CONDITION, and STOP_CONDITION.
Referenced by at24mac602_read_eui64(), and read().
|
static |
References AT24MAC602_SDA_PIN, port_config::direction, port_config::input_pull, PORT_PIN_DIR_INPUT, PORT_PIN_PULL_NONE, and port_pin_set_config().
Referenced by read().
|
static |
References AT24MAC602_SDA_PIN, port_config::direction, PORT_PIN_DIR_OUTPUT, port_pin_set_config(), and port_pin_set_output_level().
Referenced by read(), and reset_i2c().