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/wdt.h> // WatchDog
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
 | 
			
		||||
#include "common.h"
 | 
			
		||||
 | 
			
		||||
#include "Ethernet/socket.h"
 | 
			
		||||
#include "Ethernet/wizchip_conf.h"
 | 
			
		||||
@@ -17,10 +20,9 @@
 | 
			
		||||
 | 
			
		||||
#include "util/delay.h"
 | 
			
		||||
 | 
			
		||||
#include "modbus.h"
 | 
			
		||||
#include "modbus_master.h"
 | 
			
		||||
 | 
			
		||||
#define PLC_MQTT_ENABLED 1
 | 
			
		||||
#include "kraftsensor.h"
 | 
			
		||||
#include "taenzer.h"
 | 
			
		||||
#include "abzug.h"
 | 
			
		||||
 | 
			
		||||
Client mqtt_client;
 | 
			
		||||
 | 
			
		||||
@@ -57,12 +59,6 @@ void IO_LIBRARY_Init(void) {
 | 
			
		||||
    //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()
 | 
			
		||||
{
 | 
			
		||||
    // Initialize device here.
 | 
			
		||||
@@ -79,22 +75,16 @@ static void avr_init()
 | 
			
		||||
    return;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void do_kraftsensor(){
 | 
			
		||||
    uint16_t m_data[4];
 | 
			
		||||
    char msg[64];
 | 
			
		||||
void send_abzug_speed(void){
 | 
			
		||||
    char msg[4];
 | 
			
		||||
    sprintf(msg, "%d", abzug_speed);
 | 
			
		||||
    mqtt_pub(&mqtt_client, "/Filamentanlage/05_Abzug/state/abzug/speed", msg, strlen(msg));
 | 
			
		||||
 | 
			
		||||
    readReg(1,0,2);
 | 
			
		||||
    if(wait_receive(2, m_data, 10))
 | 
			
		||||
        sprintf(msg, "n/a");
 | 
			
		||||
    else{
 | 
			
		||||
        int32_t tmp = (uint32_t)m_data[0]<<16;
 | 
			
		||||
        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
 | 
			
		||||
    if(TCCR3B & (1<<CS31))
 | 
			
		||||
        sprintf(msg, "True");
 | 
			
		||||
    else
 | 
			
		||||
        sprintf(msg, "False");
 | 
			
		||||
    mqtt_pub(&mqtt_client, "/Filamentanlage/05_Abzug/state/abzug/onoff", msg, strlen(msg));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void do_notaus(){
 | 
			
		||||
@@ -162,7 +152,7 @@ int main()
 | 
			
		||||
    // INIT MCU
 | 
			
		||||
    avr_init();
 | 
			
		||||
    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");
 | 
			
		||||
    timer3_init();
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user