aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c
blob: 5ec7c6b1681e8f807b7706b23aad72501a330655 (plain)
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
/*
 * AlarmHandling.c

 *
 *  Created on: 24 may 2018
 *      Author: shlomo
 */

#include "include.h"
#include "Modules/General/GeneralHardware.h"

#include "AlarmHandling.h"
#include <driverlib/timer.h>
#include <inc/hw_ints.h>

#include "drivers/adc_sampling/adc.h"
#include "Control/control.h"

#include "drivers/Motors/Motor.h"
#include "drivers/Danser_SSI/SSI_Comm.h"
#include "drivers/Heater/TemperatureSensor.h"
#include "drivers/FPGA/FPGA_SPI_Comm.h"
#include "drivers/FPGA/FPGA.h"

#include "modules/thread/thread_ex.h"

Task_Handle AlarmHandling_Task_Handle;
Mailbox_Handle          AlarmHandlingMsgQ = NULL;

/******************** Functions  ********************************************/
//uint32_t Control_Delta_Position_Pass(uint32_t Current_Read,uint32_t Previous_Read);
//**********************************************************************
typedef enum
{
    AlarmHandlingTrigger,
}AlarmHandlingMessages;

typedef struct AlarmHandlingMessage{
    uint16_t messageId;
    uint16_t msglen;
    uint32_t tick;
    uint8_t messageData[20];
}AlarmHandlingMessageStruc;

/******************** CODE  ********************************************/
//**********************************************************************

void AlarmHandlingInit(void)
{
    Error_Block eb;

    Error_init(&eb);

    AlarmHandlingMsgQ = Mailbox_create(sizeof(AlarmHandlingMessageStruc), 20, NULL,&eb);


    //memset(AlarmHandlingDatalog,0,sizeof(uint32_t)*MAX_TANGO_CONTROL_DEVICES);

    return;
}
void AlarmHandlingIterate(UArg arg0)
{
    AlarmHandlingMessageStruc Message;

    //send message to the Millisec task
    Message.messageId = AlarmHandlingTrigger;
    Message.tick = UsersysTickGet();
    Message.msglen = sizeof(AlarmHandlingMessageStruc);
    if (AlarmHandlingMsgQ != NULL)
        Mailbox_post(AlarmHandlingMsgQ , &Message, BIOS_NO_WAIT);


    return ;
}

uint32_t AlarmHandlingLoop(uint32_t tick)
{
    return OK;
}
/******************************************************************************
 *  ======== messageTsk ========
 *  Task for this function is created statically. See the project's .cfg file.
 *  this message task is created statically in system initialization,
 ******************************************************************************/
void AlarmHandlingTask(UArg arg0, UArg arg1)
{
    AlarmHandlingMessageStruc Message;
    //char str[60];
    //uint16_t length;
    //Clock_setTimeout(HostKAClock, 1000);
    //Clock_start(HostKAClock);
    AlarmHandlingInit();
    AlarmHandling_Task_Handle = Task_self();
    while(1)
    {
        Mailbox_pend(AlarmHandlingMsgQ , &Message, BIOS_WAIT_FOREVER);
        switch (Message.messageId)
        {
            case AlarmHandlingTrigger:
                AlarmHandlingLoop(Message.tick);
                break;
            default:
                break;
        }
    }
}