Syrostan-MCU-C/Core/Inc/User/ethernet.h

30 lines
1013 B
C

#ifndef ETHERNET_H
#define ETHERNET_H
#include "user_main.h"
#define ENC_CMD_RESET (0b11001010)
#define ENC_CMD_RCR(add) (0b00000000 | add)
#define ENC_CMD_WCR(add) (0b01000000 | add)
#define ENC_CMD_BFS(add) (0b10000000 | add)
#define ENC_CMD_BFC(add) (0b10100000 | add)
#define ENC_CMD_RCRU (0b00100000)
#define ENC_CMD_WCRU (0b00100010)
#define ENC_CMD_BFSU (0b00100100)
#define ENC_CMD_BFCU (0b00100110)
#define ENC_CMD_BxSEL(x) (0b11000000 | (x << 1U))
#define ENC_CMD_RBSEL (0b11001000)
typedef enum
{
ENC_SPI_READ = 0,
ENC_SPI_WRITE
} enc_spi_operate_type_t;
void ethernet_init();
void ethernet_spi_n_byte_banked(enc_spi_operate_type_t type, uint8_t spi_cmd, uint8_t *spi_data, uint8_t n);
void ethernet_spi_n_byte_unbanked(enc_spi_operate_type_t type, uint8_t spi_cmd, uint8_t unbanked_address, uint8_t *spi_data, uint8_t n);
void ethernet_spi_2_byte(uint8_t spi_cmd, uint8_t *spi_data);
void ethernet_spi_1_byte(uint8_t spi_cmd);
#endif