wiznet stuff
This commit is contained in:
@ -3,8 +3,18 @@
|
||||
#include <stdint.h>
|
||||
#include <main2.h>
|
||||
#include <spi.h>
|
||||
#include <stdbool.h>
|
||||
#include <logger.h>
|
||||
#include <PontCoopScheduler.h>
|
||||
#include <utils.h>
|
||||
#include <wizchip_conf.h>
|
||||
|
||||
|
||||
wiz_NetInfo wizNetInfo = {
|
||||
.mac = { 0xa0, 0x57, 0x62, 0x01, 0x02, 0x03 },
|
||||
.dhcp = NETINFO_DHCP
|
||||
};
|
||||
|
||||
|
||||
void wizchip_cs_select(void) {
|
||||
HAL_GPIO_WritePin(ETHER_CS_GPIO_Port, ETHER_CS_Pin, GPIO_PIN_RESET);
|
||||
@ -30,4 +40,34 @@ void wizchip_spi_readburst(uint8_t* pBuf, uint16_t len) {
|
||||
|
||||
void wizchip_spi_writeburst(uint8_t* pBuf, uint16_t len) {
|
||||
|
||||
}
|
||||
|
||||
static void wizReset(bool b) {
|
||||
HAL_GPIO_WritePin(ETHER_RES_GPIO_Port, ETHER_RES_Pin, b ? GPIO_PIN_RESET : GPIO_PIN_SET);
|
||||
}
|
||||
|
||||
static void wizDHCPHandler(void *handle) {
|
||||
uint8_t phyLink = 0;
|
||||
int8_t res = ctlwizchip(CW_GET_PHYLINK, (void*) &phyLink);
|
||||
coloredMsg(LOG_RED, "wizdh, ctlwizchip returns %d, phy link is %d", res, phyLink);
|
||||
}
|
||||
|
||||
int wizInit() {
|
||||
coloredMsg(LOG_RED, "wizI, resetting Ethernet module");
|
||||
wizReset(true);
|
||||
activeDelay(2);
|
||||
wizReset(false);
|
||||
activeDelay(2);
|
||||
|
||||
coloredMsg(LOG_RED, "wizI, initializing Ethernet module");
|
||||
int8_t res = wizchip_init(NULL, NULL);
|
||||
coloredMsg(LOG_RED, "wizI, module driver returned %d", res);
|
||||
|
||||
wizchip_setnetinfo(&wizNetInfo);
|
||||
coloredMsg(LOG_RED, "wizI, netinfo set to Ethernet module");
|
||||
|
||||
schAdd(wizDHCPHandler, NULL, 0, 1000);
|
||||
coloredMsg(LOG_RED, "wizI, DHCP handler scheduled");
|
||||
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user