change include names etc
This commit is contained in:
42
main.c
42
main.c
@@ -2,6 +2,9 @@
|
|||||||
#include <avr/interrupt.h>
|
#include <avr/interrupt.h>
|
||||||
#include <avr/wdt.h> // WatchDog
|
#include <avr/wdt.h> // WatchDog
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
#include "Ethernet/socket.h"
|
#include "Ethernet/socket.h"
|
||||||
#include "Ethernet/wizchip_conf.h"
|
#include "Ethernet/wizchip_conf.h"
|
||||||
@@ -17,10 +20,9 @@
|
|||||||
|
|
||||||
#include "util/delay.h"
|
#include "util/delay.h"
|
||||||
|
|
||||||
#include "modbus.h"
|
#include "kraftsensor.h"
|
||||||
#include "modbus_master.h"
|
#include "taenzer.h"
|
||||||
|
#include "abzug.h"
|
||||||
#define PLC_MQTT_ENABLED 1
|
|
||||||
|
|
||||||
Client mqtt_client;
|
Client mqtt_client;
|
||||||
|
|
||||||
@@ -57,12 +59,6 @@ void IO_LIBRARY_Init(void) {
|
|||||||
//wizchip_setinterruptmask(IK_SOCK_0);
|
//wizchip_setinterruptmask(IK_SOCK_0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void modbus_master_init(){
|
|
||||||
modbusSetAddress(1); //better set this to sth.
|
|
||||||
modbusInit();
|
|
||||||
timer2_init(); // modbus tick timer
|
|
||||||
}
|
|
||||||
|
|
||||||
static void avr_init()
|
static void avr_init()
|
||||||
{
|
{
|
||||||
// Initialize device here.
|
// Initialize device here.
|
||||||
@@ -79,22 +75,16 @@ static void avr_init()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void do_kraftsensor(){
|
void send_abzug_speed(void){
|
||||||
uint16_t m_data[4];
|
char msg[4];
|
||||||
char msg[64];
|
sprintf(msg, "%d", abzug_speed);
|
||||||
|
mqtt_pub(&mqtt_client, "/Filamentanlage/05_Abzug/state/abzug/speed", msg, strlen(msg));
|
||||||
|
|
||||||
readReg(1,0,2);
|
if(TCCR3B & (1<<CS31))
|
||||||
if(wait_receive(2, m_data, 10))
|
sprintf(msg, "True");
|
||||||
sprintf(msg, "n/a");
|
else
|
||||||
else{
|
sprintf(msg, "False");
|
||||||
int32_t tmp = (uint32_t)m_data[0]<<16;
|
mqtt_pub(&mqtt_client, "/Filamentanlage/05_Abzug/state/abzug/onoff", msg, strlen(msg));
|
||||||
tmp |= m_data[1];
|
|
||||||
sprintf(msg, "%ld", tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if PLC_MQTT_ENABLED
|
|
||||||
mqtt_pub(&mqtt_client, "/Filamentanlage/05_Abzug/state/kraft", msg, strlen(msg));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void do_notaus(){
|
void do_notaus(){
|
||||||
@@ -162,7 +152,7 @@ int main()
|
|||||||
// INIT MCU
|
// INIT MCU
|
||||||
avr_init();
|
avr_init();
|
||||||
spi_init(); //SPI Master, MODE0, 4Mhz(DIV4), CS_PB.3=HIGH - suitable for WIZNET 5x00(1/2/5)
|
spi_init(); //SPI Master, MODE0, 4Mhz(DIV4), CS_PB.3=HIGH - suitable for WIZNET 5x00(1/2/5)
|
||||||
modbus_master_init();
|
kraftsensor_init();
|
||||||
|
|
||||||
printf("moin!\n\r");
|
printf("moin!\n\r");
|
||||||
timer3_init();
|
timer3_init();
|
||||||
|
|||||||
Reference in New Issue
Block a user