aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Embedded_SW
diff options
context:
space:
mode:
authorAvi Levkovich <avi@twine-s.com>2019-03-31 10:12:51 +0300
committerAvi Levkovich <avi@twine-s.com>2019-03-31 10:12:51 +0300
commit53b77b20ed366c20958ea2d88275a9dc2c2d2f80 (patch)
treed4cf4d43cee06dc6fb12f41b3325fcfd9bbc19c3 /Software/Embedded_SW
parent15753ad60333a715ffa88b3d1ce461e1f6e6bce0 (diff)
parent05baf6a0dda66fdc1b66d3f769e709f88b540e1d (diff)
downloadTango-53b77b20ed366c20958ea2d88275a9dc2c2d2f80.tar.gz
Tango-53b77b20ed366c20958ea2d88275a9dc2c2d2f80.zip
Merge branch 'master' of https://twinetfs.visualstudio.com/_git/Tango
Diffstat (limited to 'Software/Embedded_SW')
-rw-r--r--Software/Embedded_SW/Embedded/Main.c2
-rw-r--r--Software/Embedded_SW/Embedded/Modules/General/buttons.c151
-rw-r--r--Software/Embedded_SW/Embedded/Modules/General/buttons.h6
3 files changed, 85 insertions, 74 deletions
diff --git a/Software/Embedded_SW/Embedded/Main.c b/Software/Embedded_SW/Embedded/Main.c
index 1a9517ac6..2147652e2 100644
--- a/Software/Embedded_SW/Embedded/Main.c
+++ b/Software/Embedded_SW/Embedded/Main.c
@@ -197,7 +197,7 @@ int main(void)
MotorsInit();
//Shai WHS_HW_test(); // for WHS sensor test
// WHS_init();
-// Buttons_Init();
+// Buttons_Init();
//IDS_ModuleInit();
Valve_Set(VALVE_MIXCHIP_WASTECH, Mixer_Waste);
diff --git a/Software/Embedded_SW/Embedded/Modules/General/buttons.c b/Software/Embedded_SW/Embedded/Modules/General/buttons.c
index 0550c8ca7..4befb83ea 100644
--- a/Software/Embedded_SW/Embedded/Modules/General/buttons.c
+++ b/Software/Embedded_SW/Embedded/Modules/General/buttons.c
@@ -23,9 +23,9 @@
#include "Modules/General/buttons.h"
-int MachineOnOff();
-int ch_to_power_down();
-int ch_to_power_up();
+//int MachineOnOff();
+int PowerDown();
+int PowerUp();
int thredJog();
@@ -57,8 +57,8 @@ typedef enum
button power , jog, load;
-uint32_t ButtonsCallBackFunction(uint32_t IfIndex, uint32_t ReadValue);
-uint32_t ButtonsCBFunction(uint32_t IfIndex, uint32_t ReadValue);
+uint32_t ButtonPowerCallBackFunction(uint32_t IfIndex, uint32_t ReadValue);
+uint32_t ButtonPowerCBFunction(uint32_t IfIndex, uint32_t ReadValue);
uint32_t ShortLongOffPB(uint8_t OnOffPB, button *pBtn);
uint32_t StateMachine( button *pBtn);
@@ -72,6 +72,8 @@ uint32_t joggingMachine(uint8_t OnOffPB, button *pBtn);
uint32_t ButtonLoadCallBackFunction(uint32_t IfIndex, uint32_t ReadValue);
uint32_t ButtonLoadCBFunction(uint32_t IfIndex, uint32_t ReadValue);
+uint32_t LoadStatMachine( button *pBtn);
+
/*
void Power_Reset();
@@ -81,6 +83,20 @@ bool Read_PWR_Button();//TODO move to GPIO folder
*/
+int PowerDown()
+{
+ bool ret = OK;
+
+ return ret;
+}
+
+int PowerUp()
+{
+ bool ret = OK;
+
+ return ret;
+}
+
/*
* read GPIO status
@@ -89,27 +105,34 @@ bool Read_PWR_Button();//TODO move to GPIO folder
*
* return !GPIOstatus
*/
-uint32_t ButtonsCallBackFunction(uint32_t IfIndex, uint32_t ReadValue)
+uint32_t ButtonPowerCallBackFunction(uint32_t IfIndex, uint32_t ReadValue)
{
- if(ROM_GPIOPinRead(GPIO_PORTN_BASE, GPIO_PIN_7))
+ return Read_PWR_Button();
+ /*
+ *
+ if(ROM_GPIOPinRead(GPIO_PORTN_BASE, GPIO_PIN_7))
return 0x00;
else
return 0x01;
+ */
}
uint32_t ButtonJogCallBackFunction(uint32_t IfIndex, uint32_t ReadValue)
{
- if(ROM_GPIOPinRead(GPIO_PORTN_BASE, GPIO_PIN_7))
- return 0x00;
- else
- return 0x01;
+ return Get_Thread_Jogging_Button();
+//
+// if(ROM_GPIOPinRead(GPIO_PORTN_BASE, GPIO_PIN_7))
+// return 0x00;
+// else
+// return 0x01;
}
uint32_t ButtonLoadCallBackFunction(uint32_t IfIndex, uint32_t ReadValue)
{
- if(ROM_GPIOPinRead(GPIO_PORTN_BASE, GPIO_PIN_7))
- return 0x00;
- else
- return 0x01;
+ return Get_Thread_Load_Button();
+// if(ROM_GPIOPinRead(GPIO_PORTN_BASE, GPIO_PIN_7))
+// return 0x00;
+// else
+// return 0x01;
}
//uint32_t AddControlCallback( ControlCBFunction Callback, CTRL_TIMING_ENUM CtrlFrequency, DataReadCBFunction DriverfPtr, uint16_t IfIndex, uint32_t Parameter1, uint32_t Parameter2 );
@@ -120,7 +143,7 @@ uint32_t ButtonLoadCallBackFunction(uint32_t IfIndex, uint32_t ReadValue)
uint32_t Buttons_Init(void)
{
- power.bttn_status = 0 ;
+// power.bttn_status = 0 ;
// power.bttn_name = "power"; //option
power.bttn_status = 0; // 0=release 1=press
power.Action = OFFPB ; //off,short,long,count,replong
@@ -128,10 +151,10 @@ uint32_t Buttons_Init(void)
power.state = sttOFF; //sttOFF, sttON, sttDISABLE, sttENABLE, sttIDLE, sttJOGGING
power.count = 0;
- AddControlCallback( ButtonsCBFunction, BUTTOMS_SAMPLE_TIME, ButtonsCallBackFunction, 0,0,0 ); // eFiftyMillisecond
+ AddControlCallback( ButtonPowerCBFunction, BUTTOMS_SAMPLE_TIME, ButtonPowerCallBackFunction, 0,0,0 ); // eFiftyMillisecond
- jog.bttn_status = 0 ;
-// power.bttn_name = "power"; //option
+// jog.bttn_status = 0 ;
+// jog.bttn_name = "jog"; //option
jog.bttn_status = 0; // 0=release 1=press
jog.Action = OFFPB ; //OFFPB,short,long,count,replong
jog.color = colorOFF; //colorOFF, BLUE, BLINK,
@@ -139,8 +162,8 @@ uint32_t Buttons_Init(void)
jog.count = 0;
AddControlCallback( ButtonJogCBFunction, BUTTOMS_SAMPLE_TIME, ButtonJogCallBackFunction, 0,0,0 ); //
- load.bttn_status = 0 ;
-// power.bttn_name = "power"; //option
+// load.bttn_status = 0 ;
+// load.bttn_name = "load"; //option
load.bttn_status = 0; // 0=release 1=press
load.Action = OFFPB ; //OFFPB,short,long,count,replong
load.color = colorOFF; //colorOFF, BLUE, BLINK,
@@ -153,7 +176,7 @@ return OK;
//read the buttons data here and handle
-uint32_t ButtonsCBFunction(uint32_t IfIndex, uint32_t ReadValue)
+uint32_t ButtonPowerCBFunction(uint32_t IfIndex, uint32_t ReadValue)
{
ShortLongOffPB(ReadValue,&power);
return 0;
@@ -169,7 +192,9 @@ uint32_t ButtonJogCBFunction(uint32_t IfIndex, uint32_t ReadValue)
uint32_t ButtonLoadCBFunction(uint32_t IfIndex, uint32_t ReadValue)
{
- // ShortLongOffPB(ReadValue,&load);
+ uint8_t parameter = 2;
+ REPORT_MSG(parameter," ------------ Start thread loading empty function ----------------- ");
+ LoadStatMachine(&load);
return 0;
}
@@ -177,36 +202,6 @@ uint32_t ButtonLoadCBFunction(uint32_t IfIndex, uint32_t ReadValue)
-//OnOffPB = getPBstatus(POWER_PB);
-
-
-
-/*
- *
- *
- */
-int Get_timer()
-{
- // to go timer
- return 0;
-}
-
-int ClearTimer()
-{
- //to do clear timer
- return 0;
-}
-int StartTimer()
-{
- // to do start timer
- return 0;
-}
-int StopTimer()
-{
- // to do start timer
- return 0;
-}
-
/* ---------------------------------------------------------
* --- ShortLongOffPB(int OnOffPB, enum PBstat *ret) ----
* input: OnOffPB status(0(pressed) or 1(relesed)
@@ -222,7 +217,6 @@ int StopTimer()
------------------------------------------------------------*/
-//ShortLongOffPB( OnOffPB, &ret)
uint32_t ShortLongOffPB(uint8_t OnOffPB, button *pBtn)
@@ -237,14 +231,16 @@ uint32_t ShortLongOffPB(uint8_t OnOffPB, button *pBtn)
if( OnOffPB )
{
pBtn->Action = COUNTPB ;
+ REPORT_MSG(parameter," ------------ Start count PB Power ----------------- ");
}
break;
case COUNTPB: // last OnOffPBstate was COUNTPB
if (OnOffPB)
{
- if( pBtn->count > 5 ) //250ms
+ if( pBtn->count > 5 ) //5*50ms=250ms
{
pBtn->Action = SHORTPB ;
+ REPORT_MSG(parameter," ------------ Start count PB Power ----------------- ");
}
}
else
@@ -259,14 +255,14 @@ uint32_t ShortLongOffPB(uint8_t OnOffPB, button *pBtn)
if (pBtn->count > 100) //5000ms
{
pBtn->Action = LONGPB ;
- REPORT_MSG(parameter,"Long PB ");
+ REPORT_MSG(parameter," ------------ Long PB Power ----------------- ");
StateMachine(pBtn);
pBtn->count = 0;
}
}
else
{
- REPORT_MSG(parameter,"Short PB ");
+ REPORT_MSG(parameter," ------------ Short PB Power ----------------- ");
StateMachine(pBtn);
pBtn->count = 0;
pBtn->Action = OFFPB ;
@@ -317,8 +313,9 @@ uint32_t StateMachine( button *pBtn) //short press(=0)/long press(=1)
switch (pBtn->Action)
{
case LONGPB: //Power Down
- pBtn->state = sttOFF; // todo
- REPORT_MSG(parameter,"Power state is OFF ");
+ pBtn->state = sttOFF;
+ PowerDown();// todo
+ REPORT_MSG(parameter," ------------ Power state is OFF ----------------- ");
break;
// case SHORTPB: //idle ?????
// setMachineStatus = IDLE; // ????/
@@ -335,8 +332,9 @@ uint32_t StateMachine( button *pBtn) //short press(=0)/long press(=1)
// break;
case SHORTPB: //powerup?
// to do ?
- pBtn->state = sttON; //todo
- REPORT_MSG(parameter,"Power state is ON ");
+ pBtn->state = sttON;
+ PowerUp(); //todo
+ REPORT_MSG(parameter," ------------ Power state is ON ----------------- ");
break;
default:
break;
@@ -346,14 +344,16 @@ uint32_t StateMachine( button *pBtn) //short press(=0)/long press(=1)
switch (pBtn->Action)
{
case LONGPB: //Power off from idle
- pBtn->state = sttOFF; // todo
+ pBtn->state = sttOFF;
+ PowerDown(); // todo
Pannel_Leds(POWER_ON_OFF,MODE_OFF); //AVI+ - TODO option MODE_ON to stop Breathing and the led will turn off in power down
- REPORT_MSG(parameter,"Power state is OFF ");
+ REPORT_MSG(parameter," ------------ Power state is OFF ----------------- ");
break;
case SHORTPB: //Wake up from idle
- pBtn->state = sttON;// to do ?
+ pBtn->state = sttON;
+ PowerUp(); // to do ?
Pannel_Leds(POWER_ON_OFF,MODE_ON); //AVI+
- REPORT_MSG(parameter,"Power state is ON ");
+ REPORT_MSG(parameter," ------------ Power state is ON ----------------- ");
break;
default:
break;
@@ -384,7 +384,10 @@ return 0;
uint32_t setJoggingEnableCondition( button *pBtn)
{
+ uint8_t parameter = 3;
+
if (0
+// to do : what are the conditions for enable / disable
// 1.
// 2.
// 3.
@@ -392,15 +395,15 @@ uint32_t setJoggingEnableCondition( button *pBtn)
)
{
pBtn->state = sttDISABLE;
- REPORT_MSG(pBtn->state,"Jogging : sttDISABLE ");
- ThreadAbortJoggingFunc();
+ REPORT_MSG(parameter," ------------ Jogging : sttDISABLE ----------------- ");
+ // ThreadAbortJoggingFunc();
}
else
{
pBtn->state = sttENABLE;
- REPORT_MSG(pBtn->state,"Jogging : sttENABLE ");
- ThreadJoggingFunc(40);
+ REPORT_MSG(parameter," ------------ Jogging : sttENABLE ----------------- ");
+ //ThreadJoggingFunc(40);
}
return 0;
@@ -421,9 +424,13 @@ return 0;
uint32_t joggingMachine(uint8_t OnOffPB, button *pBtn)
{
+
+ uint8_t parameter = 4;
+
if (sttDISABLE == pBtn->state)
{
// jogging is disable
+ REPORT_MSG(parameter," ------------ Jogging is Disable ----------------- ");
pBtn->color = colorOFF;
Pannel_Leds(THREAD_JOGGING,MODE_OFF);//AVI+
}
@@ -431,12 +438,14 @@ uint32_t joggingMachine(uint8_t OnOffPB, button *pBtn)
{
if (!OnOffPB)
{
+ REPORT_MSG(parameter," ------------ stop Jogging ----------------- ");
ThreadAbortJoggingFunc(); // to do!!!!
pBtn->color = BLUE;
Pannel_Leds(THREAD_JOGGING,MODE_ON);//AVI+
}
else
{
+ REPORT_MSG(parameter," ------------ start Jogging ----------------- ");
pBtn->color = BLINK;
ThreadJoggingFunc(40);
}
@@ -450,9 +459,11 @@ return 0;
/*------ THREAD LOAD/UNLOAD ----------*/
-int LoadStatMachine( PBstat PBAction, button *pBtn)
+uint32_t LoadStatMachine( button *pBtn)
{
+ uint8_t parameter = 5;
+ REPORT_MSG(parameter," ------------ start loadong ----------------- ");
switch (pBtn->state)
{
case sttRDY :
diff --git a/Software/Embedded_SW/Embedded/Modules/General/buttons.h b/Software/Embedded_SW/Embedded/Modules/General/buttons.h
index d0cea022c..adf975979 100644
--- a/Software/Embedded_SW/Embedded/Modules/General/buttons.h
+++ b/Software/Embedded_SW/Embedded/Modules/General/buttons.h
@@ -38,9 +38,9 @@ typedef struct Button
{
char bttn_name[10]; //option
int bttn_status; // 0=release 1=press
- /* enum */ PBstat Action; //offPB,shortPB,longPB,countPB,replongPB
- /* enum */ PBcolor color; //off, blue, blink, bithing
- /* enum */ PBmachinState state; //sttOFF, sttON, sttDISABLE, sttENABLE, sttIDLE, sttJOGGING
+ PBstat Action; // enum : offPB,shortPB,longPB,countPB,replongPB
+ PBcolor color; // enum : off, blue, blink, bithing
+ PBmachinState state; // enum : sttOFF, sttON, sttDISABLE, sttENABLE, sttIDLE, sttJOGGING
uint32_t count;
}button;