wiznet stuff
This commit is contained in:
parent
d033412bdf
commit
65690775fb
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,4 +1,5 @@
|
||||
cube/build/
|
||||
cube/w5500.a
|
||||
.*.sw?
|
||||
*.o
|
||||
test
|
||||
|
@ -37,7 +37,7 @@ BUILD_DIR = build
|
||||
######################################
|
||||
# C sources
|
||||
C_SOURCES = \
|
||||
User/Src/wizHelper.c User/Src/eeprom.c User/Src/frontend.c User/Src/logger.c User/Src/loopCtrl.c User/Src/main2.c User/Src/mbusComm.c User/Src/ringbuffer.c User/Src/show.c hottislib/PontCoopScheduler.c \
|
||||
User/Src/utils.c User/Src/wizHelper.c User/Src/eeprom.c User/Src/frontend.c User/Src/logger.c User/Src/loopCtrl.c User/Src/main2.c User/Src/mbusComm.c User/Src/ringbuffer.c User/Src/show.c hottislib/PontCoopScheduler.c \
|
||||
libmbus/mbus/mbus-protocol.c \
|
||||
Core/Src/main.c \
|
||||
Core/Src/gpio.c \
|
||||
@ -122,6 +122,7 @@ AS_INCLUDES =
|
||||
C_INCLUDES = \
|
||||
-Ihottislib \
|
||||
-Ilibmbus \
|
||||
-IioLibrary_Driver/Ethernet \
|
||||
-IUser/Inc \
|
||||
-ICore/Inc \
|
||||
-IDrivers/STM32F1xx_HAL_Driver/Inc \
|
||||
@ -176,8 +177,8 @@ $(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR)
|
||||
$(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR)
|
||||
$(AS) -c $(CFLAGS) $< -o $@
|
||||
|
||||
$(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile
|
||||
$(CC) $(OBJECTS) $(LDFLAGS) -o $@
|
||||
$(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) w5500.a Makefile
|
||||
$(CC) $(OBJECTS) w5500.a $(LDFLAGS) -o $@
|
||||
$(SZ) $@
|
||||
|
||||
$(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
|
||||
|
8
cube/User/Inc/utils.h
Normal file
8
cube/User/Inc/utils.h
Normal file
@ -0,0 +1,8 @@
|
||||
#ifndef _UTILS_H_
|
||||
#define _UTILS_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
void activeDelay(uint8_t delay_ms);
|
||||
|
||||
#endif // _UTILS_H_
|
@ -1,6 +1,6 @@
|
||||
#ifndef _WIZHELPER_H_
|
||||
#define _WIZHELPER_H_
|
||||
|
||||
|
||||
int wizInit();
|
||||
|
||||
#endif // _WIZHELPER_H_
|
@ -5,6 +5,7 @@
|
||||
#include <logger.h>
|
||||
#include <mbusComm.h>
|
||||
#include <PontCoopScheduler.h>
|
||||
#include <utils.h>
|
||||
|
||||
#define HIGH GPIO_PIN_SET
|
||||
#define LOW GPIO_PIN_RESET
|
||||
@ -127,8 +128,7 @@ static void eepromHourlyUpdateDeviceStats(void *handle) {
|
||||
|
||||
// active waiting, use only during initialization!
|
||||
static void eepromActiveDelay(uint8_t delay_ms) {
|
||||
uint32_t startTime = HAL_GetTick();
|
||||
while (startTime + delay_ms > HAL_GetTick());
|
||||
activeDelay(delay_ms);
|
||||
}
|
||||
|
||||
void eepromInit() {
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include <logger.h>
|
||||
#include <frontend.h>
|
||||
#include <eeprom.h>
|
||||
#include <wizHelper.h>
|
||||
|
||||
void my_setup_1() {
|
||||
schInit();
|
||||
@ -187,11 +188,13 @@ void my_setup_2() {
|
||||
|
||||
eepromInit();
|
||||
|
||||
frontendInit();
|
||||
frontendSetThreshold(240);
|
||||
wizInit();
|
||||
|
||||
schAdd(scheduleMBusRequest, NULL, 0, 1000);
|
||||
schAdd(triggerMBusRequest, NULL, 0, 100);
|
||||
// frontendInit();
|
||||
// frontendSetThreshold(240);
|
||||
|
||||
// schAdd(scheduleMBusRequest, NULL, 0, 1000);
|
||||
// schAdd(triggerMBusRequest, NULL, 0, 100);
|
||||
}
|
||||
|
||||
void my_loop() {
|
||||
|
10
cube/User/Src/utils.c
Normal file
10
cube/User/Src/utils.c
Normal file
@ -0,0 +1,10 @@
|
||||
#include <utils.h>
|
||||
#include <main.h>
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
// active waiting, use only during initialization!
|
||||
void activeDelay(uint8_t delay_ms) {
|
||||
uint32_t startTime = HAL_GetTick();
|
||||
while (startTime + delay_ms > HAL_GetTick());
|
||||
}
|
@ -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;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user