1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
/************************************************************************************************************************
* Heater.c
* Heater Driver
**************************************************************************************************************************/
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include "include.h"
#include "heater.h"
#include "TemperatureSensor.h"
#include "inc/hw_memmap.h"
#include "driverlib/rom.h"
#include "driverlib/gpio.h"
#include "driverlib/sysctl.h"
#include <drivers/FPGA/FPGA_Comm.h>
#include <DataDef.h>
#include "Drivers/Peripheral_GPIO/GPIO.h"
#include <Modules/Stubs_Handler/User_Leds.h>
#include "PMR/Hardware/HardwarePIDControl.pb-c.h"
#define MAX_HEATERS_NUM HARDWARE_PID_CONTROL_TYPE__MixerHeater+1
typedef struct
{
//uint32_t m_port;
uint32_t m_pin;
bool Active;
} GPIOIntPortMap;
static GPIOIntPortMap portMap[MAX_HEATERS_NUM] =
{
#warning temporarily moving SSR2 before SSR1 due to hardware changes
{DRYER_SSR2_CTRL, false}, // HARDWARE_PID_CONTROL_TYPE__DryerHeater1000w
{DRYER_SSR1_CTRL, false}, // HARDWARE_PID_CONTROL_TYPE__DryerHeater1000w
//{DRYER_SSR2_CTRL, false}, // HARDWARE_PID_CONTROL_TYPE__DryerHeater200w1
{DRYER_SSR3_CTRL, false}, // HARDWARE_PID_CONTROL_TYPE__DryerHeater200w2
{DYEINGH_SSR8_CTRL, false}, // HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ1 - Head Heater #1 - rightmost
{DYEINGH_SSR7_CTRL, false}, // HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ2 - Head Heaters #2 #3 #4
{DYEINGH_SSR6_CTRL, false}, // HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ3 - Head Heaters #5 #6 #7 #8
{DYEINGH_SSR5_CTRL, false}, // HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ4 - Head Heaters #9 - leftmost
{MIXCHIP_SSR4_CTRL, false}, // HARDWARE_PID_CONTROL_TYPE__MixerHeater
};
uint32_t ActivateHeater (int HeaterId)
{
assert(HeaterId < MAX_HEATERS_NUM);
F2_CTRL |= portMap[HeaterId].m_pin;
//---------------------------------------------------------------------------------------
// if(HeaterId < HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ1) // Turn On FPGA LED
// F3_GPO_01_bus |= (0x01 << HeaterId);
// else
// F3_GPO_01_bus |= BIT4;
if (HeaterId == HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ1)
STATUS_GREEN_LED_ON;
if (HeaterId == HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ2)
ACTIVITY_RED_LED_ON;
if (HeaterId == HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ3)
COMM_RED_LED_ON;
//---------------------------------------------------------------------------------------
portMap[HeaterId].Active = true;
return OK;
}
uint32_t DeActivateHeater (int HeaterId)
{
assert(HeaterId < MAX_HEATERS_NUM);
F2_CTRL &= ~portMap[HeaterId].m_pin;
//---------------------------------------------------------------------------------------
// if(HeaterId < HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ1) // Turn Off FPGA LED
// F3_GPO_01_bus &= ~(0x01 << HeaterId);
// else
// F3_GPO_01_bus &= ~BIT4;
if (HeaterId == HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ1)
STATUS_GREEN_LED_OFF;
if (HeaterId == HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ2)
ACTIVITY_RED_LED_OFF;
if (HeaterId == HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ3)
COMM_RED_LED_OFF;
//---------------------------------------------------------------------------------------
portMap[HeaterId].Active = false;
return OK;
}
bool GetHeaterState (int HeaterId)
{
assert(HeaterId < MAX_HEATERS_NUM);
return portMap[HeaterId].Active;
}
uint32_t HeaterBalanceLoadControlCBFunction(uint32_t IfIndex, uint32_t readValue)
{
static int HeaterIndex = 0;
int i;
for (i = 0; i < MAX_HEATERS_NUM; i++)
{
if (GetHeaterState(i))
{
if ((i == HeaterIndex)||(i+1 == HeaterIndex)||(i+2 == HeaterIndex))
ActivateHeater(i);
else
DeActivateHeater(i);
}
else
DeActivateHeater(i);
}
HeaterIndex++;
if (HeaterIndex >= MAX_HEATERS_NUM)
{
HeaterIndex = 0;
}
return OK;
}
|