aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Embedded_SW/Embedded/Modules
diff options
context:
space:
mode:
authorAvi Levkovich <avi@twine-s.com>2018-03-19 14:34:14 +0200
committerAvi Levkovich <avi@twine-s.com>2018-03-19 14:34:14 +0200
commitace16e89b777d94d9a655fef27aa58c763f5b378 (patch)
treeb67890385896cc1c0ff3ff020fbaceac93d7bcde /Software/Embedded_SW/Embedded/Modules
parent47d8c850e03797475c3bcd99bdd3d1a0e115413b (diff)
downloadTango-ace16e89b777d94d9a655fef27aa58c763f5b378.tar.gz
Tango-ace16e89b777d94d9a655fef27aa58c763f5b378.zip
Commit Avi Embedded_SW
Diffstat (limited to 'Software/Embedded_SW/Embedded/Modules')
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Container.c39
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Stubs_Handler/DataDef.h57
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_FPGAReadBackReg.c69
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_FPGAReadBackReg.h11
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_FPGAReadVersion.c81
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_FPGAReadVersion.h6
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_HW_Version.c95
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_HW_Version.h6
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_L6470.c133
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_L6470.h3
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Motor.c453
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Motor.h7
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Stubs_Handler/temperature_sensor.c264
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Stubs_Handler/temperature_sensor.h1
14 files changed, 1218 insertions, 7 deletions
diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Container.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Container.c
index 1014c08fc..49ddb757c 100644
--- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Container.c
+++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Container.c
@@ -15,6 +15,12 @@
#include "Stub_SteperMotor.h"
#include "Stub_Valve.h"
#include "Stub_ExtFlash.h"
+#include "Stub_FPGAReadBackReg.h"
+#include "Stub_FPGAReadVersion.h"
+#include "Stub_L6470.h"
+#include "Stub_Motor.h"
+#include "Stub_HW_Version.h"
+
#include "General/GeneralHardware.h"
#include "heaters/heaters_ex.h"
#include "Drivers/USB_Communication/USBCDCD.h"
@@ -111,6 +117,39 @@ void receive_callback(char* buffer, size_t length)
case MESSAGE_TYPE__StubExtFlashWriteRequest:
Stub_ExtFlashWriteRequest(requestContainer);
break;
+ case MESSAGE_TYPE__StubFPGAReadBackRegRequest:
+ Stub_FPGAReadBackRegRequest(requestContainer);
+ break;
+ case MESSAGE_TYPE__StubFPGAReadVersionRequest:
+ Stub_FPGAReadVersionRequest(requestContainer);
+ break;
+ case MESSAGE_TYPE__StubL6470DriverRequest:
+ Stub_L6470DriverRequest(requestContainer);
+ break;
+ case MESSAGE_TYPE__StubMotorInitRequest:
+ Stub_MotorInitRequest(requestContainer);
+ break;
+ case MESSAGE_TYPE__StubMotorRunRequest:
+ Stub_MotorRunRequest(requestContainer);
+ break;
+ case MESSAGE_TYPE__StubMotorStopRequest:
+ Stub_MotorStopRequest(requestContainer);
+ break;
+ case MESSAGE_TYPE__StubMotorStatusRequest:
+ Stub_MotorStatusRequest(requestContainer);
+ break;
+ case MESSAGE_TYPE__StubMotorPositionRequest:
+ Stub_MotorPositionRequest(requestContainer);
+ break;
+ case MESSAGE_TYPE__StubMotorSpeedRequest:
+ Stub_MotorSpeedRequest(requestContainer);
+ break;
+ case MESSAGE_TYPE__StubMotorMovRequest:
+ Stub_MotorMovRequest(requestContainer);
+ break;
+ case MESSAGE_TYPE__StubHWVersionRequest:
+ Stub_HWVersionRequest(requestContainer);
+ break;
case MESSAGE_TYPE__DebugLogRequest:
ReportInitMessage(requestContainer);
break;
diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/DataDef.h b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/DataDef.h
index 08da87c09..67c509d33 100644
--- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/DataDef.h
+++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/DataDef.h
@@ -25,18 +25,23 @@ enum
#define NEW 0
#define USED 1
-#define START 1
-#define STOP 0
+#define START 0
+#define STOP 1
+#define NOSTOP 2
+#define CONTINUE 2
+#define NOTBUSY 0
+#define BUSY 1
+//
// motor direction
-#define CW 1 // clockwise
-#define CCW 0 // counter clockwise
+#define CW 0 // clockwise
+#define CCW 1 // counter clockwise
#define TRUE 1
#define FALSE 0
-#define INPUT 1
-#define OUTPUT 0
+#define INPUT 0x0
+#define OUTPUT 0x1
#define PULLDOWN 0
#define PULLUP 1
@@ -44,6 +49,41 @@ enum
#define TX 0
#define RX 1
#define TXRX 2
+#define ODD 0
+#define EVEN 1
+
+#define READY 0
+#define NOTREADY 1
+#define WAIT 2
+
+#define LOW 0x0
+#define HIGH 0x1
+
+#define WR 0
+#define RD 1
+
+#define FLAGSTART 1
+#define FLAGSET 1
+#define FLAGCLEAR 0
+
+#define IN 2
+#define OUT 3
+
+#define INIT 1
+#define SKIP_INIT 0
+
+#define byte uint8_t//char
+#define boolean bool
+
+#define SERIAL 0x0
+#define DISPLAY 0x1
+
+#define LSBFIRST 0
+#define MSBFIRST 1
+
+#define CHANGE 1
+#define FALLING 2
+#define RISING 3
//---------------------------------------------------------------------
#pragma diag_suppress 169 /* Avoid warnings on VOID * conversions (protobuf issue)
@@ -56,7 +96,10 @@ The warning:
or in the environment add command line:
Project -> properties ->
-
+Press on show advanced settings
+CCS Build ->
+Advanced Options ->
+Diagnistic Options ->
Add the warning number in
Supports diagnostic <id> (--diag_suppress, - pds)
169
diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_FPGAReadBackReg.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_FPGAReadBackReg.c
new file mode 100644
index 000000000..13df055d6
--- /dev/null
+++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_FPGAReadBackReg.c
@@ -0,0 +1,69 @@
+
+#include <PMR/Stubs/StubFPGAReadBackRegRequest.pb-c.h>
+#include <PMR/Stubs/StubFPGAReadBackRegResponse.pb-c.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+#include <Stubs_Handler/DataDef.h>
+#include "inc/hw_memmap.h"
+#include "inc/hw_types.h"
+#include "inc/hw_uart.h"
+
+#include "Drivers/USB_Communication/USBCDCD.h"
+#include "drivers/twine_graphicslib/graphics_adapter.h"
+
+#include "MessageContainer.pb-c.h"
+
+#include "Container.h"
+#include "Stub_Status.h"
+#include "drivers/FPGA/FPGA.h"
+
+void Stub_FPGAReadBackRegRequest(MessageContainer* requestContainer)
+{
+ uint32_t status = FAILED;
+
+ unsigned short ReadBack_Value;
+
+ MessageContainer responseContainer;
+
+ StubFPGAReadBackRegRequest* request = stub_fpgaread_back_reg_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data);
+
+ writeLine("ReadBack Request: ");
+
+ writeFloat(request->fpgaid);
+ writeString(", ");
+ writeFloat(request->value);
+
+ status = Test_FPGA_ReadBack((unsigned char) request->fpgaid, (unsigned short) request->value, &ReadBack_Value);
+
+ StubFPGAReadBackRegResponse response = STUB_FPGAREAD_BACK_REG_RESPONSE__INIT;
+
+ status_response(status,&response.status, &response.statusword ,&response.has_statusword);
+
+ response.fpgaid = request->fpgaid;
+ response.has_fpgaid = true;
+ response.readbackvalue = ReadBack_Value;
+ response.has_readbackvalue = true;
+
+ responseContainer = createContainer(MESSAGE_TYPE__StubFPGAReadBackRegResponse, requestContainer->token, true, &response, &stub_fpgaread_back_reg_response__pack, &stub_fpgaread_back_reg_response__get_packed_size);
+
+ writeLine("Sending Response: ");
+
+ writeFloat(response.fpgaid);
+ writeString(", ");
+ writeFloat(response.readbackvalue);
+ writeString(", ");
+
+ Write_status_response(status);
+
+ free(request);
+ //-------------------------------------------------------------------------------------------
+ uint8_t* container_buffer = malloc(message_container__get_packed_size(&responseContainer));
+ size_t container_size = message_container__pack(&responseContainer, container_buffer);
+ SendChars((char*)container_buffer, container_size);
+ free(container_buffer);
+ free(requestContainer);
+
+}
diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_FPGAReadBackReg.h b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_FPGAReadBackReg.h
new file mode 100644
index 000000000..14e245225
--- /dev/null
+++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_FPGAReadBackReg.h
@@ -0,0 +1,11 @@
+#ifndef STUB_READBACK_H
+#define STUB_READBACK_H
+
+void Stub_FPGAReadBackRegRequest(MessageContainer* requestContainer);
+
+#endif //STUB_READBACK_H
+
+
+
+
+
diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_FPGAReadVersion.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_FPGAReadVersion.c
new file mode 100644
index 000000000..71ec6fc0a
--- /dev/null
+++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_FPGAReadVersion.c
@@ -0,0 +1,81 @@
+
+#include <PMR/Stubs/StubFPGAReadVersionResponse.pb-c.h>
+#include <PMR/Stubs/StubFPGAReadVersionRequest.pb-c.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+#include <Stubs_Handler/DataDef.h>
+#include "inc/hw_memmap.h"
+#include "inc/hw_types.h"
+#include "inc/hw_uart.h"
+
+#include "Drivers/USB_Communication/USBCDCD.h"
+#include "drivers/twine_graphicslib/graphics_adapter.h"
+
+#include "MessageContainer.pb-c.h"
+
+#include "Container.h"
+#include "Stub_Status.h"
+#include "drivers/FPGA/FPGA.h"
+
+void Stub_FPGAReadVersionRequest(MessageContainer* requestContainer)
+{
+ uint32_t status = FAILED;
+ unsigned char Version = 0;
+ unsigned char Year = 0 ;
+ unsigned char Month = 0;
+ unsigned char Day = 0;
+
+ MessageContainer responseContainer;
+
+ StubFPGAReadVersionRequest* request = stub_fpgaread_version_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data);
+
+ writeLine("ReadBack Request: ");
+
+ writeFloat(request->fpgaid);
+
+ status = FPGA_ReadVersion((unsigned char)request->fpgaid, &Version, &Year, &Month, &Day);
+
+ StubFPGAReadVersionResponse response = STUB_FPGAREAD_VERSION_RESPONSE__INIT;
+
+ status_response(status,&response.status, &response.statusword ,&response.has_statusword);
+
+ response.fpgaid = request->fpgaid;
+ response.has_fpgaid = true;
+ response.day = Day;
+ response.has_day = true;
+ response.month = Month;
+ response.has_month = true;
+ response.year = Year;
+ response.has_year = true;
+ response.ver_num = Version;
+ response.has_ver_num = true;
+
+ responseContainer = createContainer(MESSAGE_TYPE__StubFPGAReadVersionResponse, requestContainer->token, true, &response, &stub_fpgaread_version_response__pack, &stub_fpgaread_version_response__get_packed_size);
+
+ writeLine("Sending Response: ");
+
+ writeFloat(response.fpgaid);
+ writeString(", ");
+ writeFloat(response.day);
+ writeString(", ");
+ writeFloat(response.month);
+ writeString(", ");
+ writeFloat(response.year);
+ writeString(", ");
+ writeFloat(response.ver_num);
+ writeString(", ");
+
+ Write_status_response(status);
+
+ free(request);
+ //-------------------------------------------------------------------------------------------
+ uint8_t* container_buffer = malloc(message_container__get_packed_size(&responseContainer));
+ size_t container_size = message_container__pack(&responseContainer, container_buffer);
+ SendChars((char*)container_buffer, container_size);
+ free(container_buffer);
+ free(requestContainer);
+
+}
diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_FPGAReadVersion.h b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_FPGAReadVersion.h
new file mode 100644
index 000000000..d9c33b8b8
--- /dev/null
+++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_FPGAReadVersion.h
@@ -0,0 +1,6 @@
+#ifndef STUB_FPGAVER_H
+#define STUB_FPGAVER_H
+
+void Stub_FPGAReadVersionRequest(MessageContainer* requestContainer);
+
+#endif //STUB_FPGAVER_H
diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_HW_Version.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_HW_Version.c
new file mode 100644
index 000000000..72d935b83
--- /dev/null
+++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_HW_Version.c
@@ -0,0 +1,95 @@
+
+#include <PMR/Stubs/StubHWVersionResponse.pb-c.h>
+#include <PMR/Stubs/StubHWVersionRequest.pb-c.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+#include <Stubs_Handler/DataDef.h>
+#include "inc/hw_memmap.h"
+#include "inc/hw_types.h"
+#include "inc/hw_uart.h"
+#include "driverlib/gpio.h"
+#include "Drivers/USB_Communication/USBCDCD.h"
+#include "drivers/twine_graphicslib/graphics_adapter.h"
+
+#include "MessageContainer.pb-c.h"
+
+#include "Container.h"
+#include "Stub_Status.h"
+#include "drivers/FPGA/FPGA.h"
+#include "driverlib/rom_map.h"
+#include "driverlib/rom.h"
+
+
+char Read_HW_Version(unsigned char *Brd_ID, unsigned char *Assy_ID)
+{
+ //TODO Move in GPIO Initialisation
+
+ // ----------- Set HW Version GPIO as Input -----------
+ MAP_GPIOPinTypeGPIOInput(GPIO_PORTS_BASE, GPIO_PIN_3 | GPIO_PIN_2 | GPIO_PIN_1);
+ MAP_GPIOPinTypeGPIOInput(GPIO_PORTJ_BASE, GPIO_PIN_5 | GPIO_PIN_4 | GPIO_PIN_7);
+ MAP_GPIOPinTypeGPIOInput(GPIO_PORTP_BASE, GPIO_PIN_3 | GPIO_PIN_5);
+
+ //Set HW Version GPIO to Pull down
+ GPIOPadConfigSet(GPIO_PORTS_BASE, GPIO_PIN_3 | GPIO_PIN_2 | GPIO_PIN_1, GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD_WPD );
+ GPIOPadConfigSet(GPIO_PORTJ_BASE, GPIO_PIN_5 | GPIO_PIN_4 | GPIO_PIN_7, GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD_WPD );
+ GPIOPadConfigSet(GPIO_PORTP_BASE, GPIO_PIN_3 | GPIO_PIN_5, GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD_WPD );
+ // ------------------------------------------------------
+
+ if (ROM_GPIOPinRead(GPIO_PORTS_BASE, GPIO_PIN_3) == GPIO_PIN_3)
+ *Brd_ID |= 0x08;
+ if (ROM_GPIOPinRead(GPIO_PORTS_BASE, GPIO_PIN_2) == GPIO_PIN_2)
+ *Brd_ID |= 0x04;
+ if (ROM_GPIOPinRead(GPIO_PORTJ_BASE, GPIO_PIN_5) == GPIO_PIN_5)
+ *Brd_ID |= 0x02;
+ if (ROM_GPIOPinRead(GPIO_PORTJ_BASE, GPIO_PIN_4) == GPIO_PIN_4)
+ *Brd_ID |= 0x01;
+
+ if (ROM_GPIOPinRead(GPIO_PORTP_BASE, GPIO_PIN_3) == GPIO_PIN_3)
+ *Assy_ID |= 0x08;
+ if (ROM_GPIOPinRead(GPIO_PORTP_BASE, GPIO_PIN_5) == GPIO_PIN_5)
+ *Assy_ID |= 0x04;
+ if (ROM_GPIOPinRead(GPIO_PORTS_BASE, GPIO_PIN_1) == GPIO_PIN_1)
+ *Assy_ID |= 0x02;
+ if (ROM_GPIOPinRead(GPIO_PORTJ_BASE, GPIO_PIN_7) == GPIO_PIN_7)
+ *Assy_ID |= 0x01;
+
+ return PASSED;
+}
+
+void Stub_HWVersionRequest(MessageContainer* requestContainer)
+{
+ uint32_t status = FAILED;
+ unsigned char Brd_ID = 0;
+ unsigned char Assy_ID = 0;
+
+ MessageContainer responseContainer;
+
+ StubHWVersionRequest* request = stub_hwversion_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data);
+
+ status = Read_HW_Version(&Brd_ID, &Assy_ID);
+
+ StubHWVersionResponse response = STUB_HWVERSION_RESPONSE__INIT;
+
+ status_response(status,&response.status, &response.statusword ,&response.has_statusword);
+
+ response.brd_id = Brd_ID ;
+ response.has_brd_id = true;
+ response.assy_id = Assy_ID;
+ response.has_assy_id = true;
+
+ responseContainer = createContainer(MESSAGE_TYPE__StubHWVersionResponse, requestContainer->token, true, &response, &stub_hwversion_response__pack, &stub_hwversion_response__get_packed_size);
+
+ Write_status_response(status);
+
+ free(request);
+ //-------------------------------------------------------------------------------------------
+ uint8_t* container_buffer = malloc(message_container__get_packed_size(&responseContainer));
+ size_t container_size = message_container__pack(&responseContainer, container_buffer);
+ SendChars((char*)container_buffer, container_size);
+ free(container_buffer);
+ free(requestContainer);
+
+}
diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_HW_Version.h b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_HW_Version.h
new file mode 100644
index 000000000..b1bc504a3
--- /dev/null
+++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_HW_Version.h
@@ -0,0 +1,6 @@
+#ifndef STUB_HWVER_H
+#define STUB_HWVER_H
+
+void Stub_HWVersionRequest(MessageContainer* requestContainer);
+
+#endif //STUB_HWVER_H
diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_L6470.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_L6470.c
new file mode 100644
index 000000000..4b9f016de
--- /dev/null
+++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_L6470.c
@@ -0,0 +1,133 @@
+
+#include <PMR/Stubs/StubL6470DriverResponse.pb-c.h>
+#include <PMR/Stubs/StubL6470DriverRequest.pb-c.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+#include <Stubs_Handler/DataDef.h>
+#include "inc/hw_memmap.h"
+#include "inc/hw_types.h"
+#include "inc/hw_uart.h"
+
+#include "Drivers/USB_Communication/USBCDCD.h"
+#include "drivers/twine_graphicslib/graphics_adapter.h"
+
+#include "MessageContainer.pb-c.h"
+
+#include "Container.h"
+#include "Stub_Status.h"
+//#include "drivers/FPGA/FPGA.h"
+#include "drivers/SPI/SPI_Comm.h"
+
+#include "drivers/FPGA/Moters_Driver/L6470.h"
+
+#include "driverlib/ssi.h"
+
+ unsigned long Run_Value = 136902 ;
+ unsigned long Pos_Value;
+ unsigned long Mov_Value ;
+ bool Direction ;
+ unsigned long Time_2_Change_Direction ;
+ bool Display_Tx_ON_LCD;
+ bool Display_Rx_on_LCD;
+ unsigned long Init_MicroStep ;
+ unsigned long Init_Acc;
+ unsigned long Init_Dec;
+ bool TestBool_1;
+ bool TestBool_2;
+ bool TestBool_3;
+ bool TestBool_4;
+ bool TestBool_5;
+ unsigned long TestUint32_1;
+ unsigned long TestUint32_2;
+ unsigned long TestUint32_3;
+ unsigned long TestUint32_4;
+ unsigned long TestUint32_5;
+ unsigned long TestUint32_6;
+
+void Stub_L6470DriverRequest(MessageContainer* requestContainer)
+{
+ uint32_t status = PASSED;
+
+ MessageContainer responseContainer;
+
+ StubL6470DriverRequest* request = stub_l6470_driver_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data);
+
+ Run_Value = request->run_value;
+ Mov_Value = request->mov_value;
+ Direction = request->direction;
+ Time_2_Change_Direction = request->time_2_change_direction;
+ Display_Tx_ON_LCD = request->display_tx_on_lcd;
+ Display_Rx_on_LCD = request->display_rx_on_lcd;
+ Init_MicroStep = request->init_microstep;
+ Init_Acc = request->init_acc;
+ Init_Dec = request->init_dec;
+ TestBool_1 = request->testbool_1;
+ TestBool_2 = request->testbool_2;
+ TestBool_3 = request->testbool_3;
+ TestBool_4 = request->testbool_4;
+ TestBool_5 = request->testbool_5;
+ TestUint32_1 = request->testuint32_1;
+ TestUint32_2 = request->testuint32_2;
+ TestUint32_3 = request->testuint32_3;
+ TestUint32_4 = request->testuint32_4;
+ TestUint32_5 = request->testuint32_5;
+ TestUint32_6 = request->testuint32_6;
+
+ writeLine("L6470 Request: ");
+
+ writeFloat(request->run_value);
+
+ //status = FPGA_ReadVersion((unsigned char)request->fpgaid, &Version, &Year, &Month, &Day);
+ SPI_Control(INIT);
+
+ //temp_init_spi2();
+
+
+ StubL6470DriverResponse response = STUB_L6470_DRIVER_RESPONSE__INIT;
+
+ status_response(status,&response.status, &response.statusword ,&response.has_statusword);
+
+ //response.run_value = Get_Param(x_SPEED);
+ /*
+ response.mov_value = ;
+ response.day = Day;
+ response.has_day = true;
+ response.month = Month;
+ response.has_month = true;
+ response.year = Year;
+ response.has_year = true;
+ response.ver_num = Version;
+ response.has_ver_num = true;
+*/
+ responseContainer = createContainer(MESSAGE_TYPE__StubL6470DriverResponse, requestContainer->token, true, &response, &stub_l6470_driver_response__pack, &stub_l6470_driver_response__get_packed_size);
+
+ writeLine("Sending Response: ");
+
+ writeFloat(response.run_value);
+ /*
+ writeString(", ");
+ writeFloat(response.day);
+ writeString(", ");
+ writeFloat(response.month);
+ writeString(", ");
+ writeFloat(response.year);
+ writeString(", ");
+ writeFloat(response.ver_num);
+ writeString(", ");
+*/
+ Write_status_response(status);
+
+ free(request);
+ //-------------------------------------------------------------------------------------------
+ uint8_t* container_buffer = malloc(message_container__get_packed_size(&responseContainer));
+ size_t container_size = message_container__pack(&responseContainer, container_buffer);
+ SendChars((char*)container_buffer, container_size);
+ free(container_buffer);
+ free(requestContainer);
+
+
+ //StartUSB(ui32SysClock); //todo to test the USB comm problem after using 6470
+}
diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_L6470.h b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_L6470.h
new file mode 100644
index 000000000..0b4702861
--- /dev/null
+++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_L6470.h
@@ -0,0 +1,3 @@
+void Stub_L6470DriverRequest(MessageContainer* requestContainer);
+
+void temp_init_spi2();
diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Motor.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Motor.c
new file mode 100644
index 000000000..c16e33a99
--- /dev/null
+++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Motor.c
@@ -0,0 +1,453 @@
+
+#include <PMR/Stubs/StubMotorInitRequest.pb-c.h>
+#include <PMR/Stubs/StubMotorInitResponse.pb-c.h>
+#include <PMR/Stubs/StubMotorRunRequest.pb-c.h>
+#include <PMR/Stubs/StubMotorRunResponse.pb-c.h>
+#include <PMR/Stubs/StubMotorStopRequest.pb-c.h>
+#include <PMR/Stubs/StubMotorStopResponse.pb-c.h>
+#include <PMR/Stubs/StubMotorStatusRequest.pb-c.h>
+#include <PMR/Stubs/StubMotorStatusResponse.pb-c.h>
+#include <PMR/Stubs/StubMotorSpeedResponse.pb-c.h>
+#include <PMR/Stubs/StubMotorSpeedRequest.pb-c.h>
+#include <PMR/Stubs/StubMotorPositionRequest.pb-c.h>
+#include <PMR/Stubs/StubMotorPositionResponse.pb-c.h>
+#include <PMR/Stubs/StubMotorMovRequest.pb-c.h>
+#include <PMR/Stubs/StubMotorMovResponse.pb-c.h>
+
+#include <stdbool.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+#include <Stubs_Handler/DataDef.h>
+#include "inc/hw_memmap.h"
+#include "inc/hw_types.h"
+#include "inc/hw_uart.h"
+
+#include "Drivers/USB_Communication/USBCDCD.h"
+#include "drivers/twine_graphicslib/graphics_adapter.h"
+
+#include "MessageContainer.pb-c.h"
+
+#include "Container.h"
+#include "Stub_Status.h"
+#include "drivers/FPGA/FPGA.h"
+#include "drivers/SPI/SPI_Comm.h"
+
+#include "drivers/FPGA/Moters_Driver/L6470.h"
+
+#include "driverlib/ssi.h"
+
+
+extern unsigned long Run_Value ;
+extern unsigned long Pos_Value ;
+extern bool Direction ;
+unsigned char Stop_Command = 0 ;
+
+
+
+void Stub_MotorInitRequest(MessageContainer* requestContainer)
+{
+ //uint32_t status = FAILED;
+
+ MessageContainer responseContainer;
+
+ StubMotorInitRequest* request = stub_motor_init_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data);
+
+ //SPI_Control(INIT);
+
+ SPI2_Init();
+ init_BUSY_Pin();
+ //while(SSIBusy(SSI2_BASE)){};
+ //init_BUSY_Pin();
+
+
+ setup(request);
+ //setup();
+
+ //init_BUSY_Pin();
+ //while(SSIBusy(SSI2_BASE)){};
+ //ResetPos();
+ //while(SSIBusy(SSI2_BASE)){};
+
+ //Run_Value = request->run_value;
+ //Mov_Value = request->mov_value;
+ //Direction = request->direction;
+
+
+ //writeLine("L6470 Request: ");
+
+ //writeFloat(request->run_value);
+
+ //status = FPGA_ReadVersion((unsigned char)request->fpgaid, &Version, &Year, &Month, &Day);
+ //SPI_Control();
+
+ //temp_init_spi2();
+
+
+ StubMotorInitResponse response = STUB_MOTOR_INIT_RESPONSE__INIT;
+
+ // status_response(status,&response.status, &response.statusword ,&response.has_statusword);
+
+
+ response.motor_id = request->motor_id;
+ response.has_motor_id = true;
+ response.status = 0;
+
+ responseContainer = createContainer(MESSAGE_TYPE__StubMotorInitResponse, requestContainer->token, true, &response, &stub_motor_init_response__pack, &stub_motor_init_response__get_packed_size);
+
+ writeLine("Sending Response: ");
+
+ writeFloat(response.motor_id);
+ writeString(", ");
+ writeFloat(response.status);
+
+ //writeString(", ");
+ //
+ //Write_status_response(status);
+
+ free(request);
+ //-------------------------------------------------------------------------------------------
+ uint8_t* container_buffer = malloc(message_container__get_packed_size(&responseContainer));
+ size_t container_size = message_container__pack(&responseContainer, container_buffer);
+ SendChars((char*)container_buffer, container_size);
+ free(container_buffer);
+ free(requestContainer);
+}
+
+
+void Stub_MotorRunRequest(MessageContainer* requestContainer)
+{
+ //uint32_t status = FAILED;
+
+ uint32_t read_status;
+
+ MessageContainer responseContainer;
+
+ StubMotorRunRequest* request = stub_motor_run_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data);
+
+ float temp = (float)request->speed;
+ Run_Value = SpdCalc(temp);
+ Direction = request->direction;
+
+ //SPI_Control(SKIP_INIT);
+ Mot_Run();
+
+ //writeLine("L6470 Request: ");
+
+ //writeFloat(request->run_value);
+
+ //status = FPGA_ReadVersion((unsigned char)request->fpgaid, &Version, &Year, &Month, &Day);
+
+
+
+ StubMotorRunResponse response = STUB_MOTOR_RUN_RESPONSE__INIT;
+
+ // status_response(status,&response.status, &response.statusword ,&response.has_statusword);
+
+
+ response.motor_id = request->motor_id;
+ response.has_motor_id = true;
+
+ read_status = Get_and_Clear_Status();
+
+ response.speed = (double)(CurrentSpdCalc(Get_Param(x_SPEED)));
+ response.has_speed = true;
+
+ response.status_reg = read_status;
+ response.has_status_reg = true;
+
+ response.direction = ((read_status & x_STATUS_DIR)>>4);
+ response.has_direction = true;
+
+ response.step_loss_a = ((read_status & x_STATUS_STEP_LOSS_A)>>13);
+ response.has_step_loss_a = true;
+ response.step_loss_b = ((read_status & x_STATUS_STEP_LOSS_B)>>14);
+ response.has_step_loss_b = true;
+
+
+ response.mot_status = ((read_status & x_STATUS_MOT_STATUS)>>5);
+ response.has_mot_status = true;
+
+ response.busy = ((read_status & x_STATUS_BUSY)>>1);
+ response.has_busy = true;
+
+
+ responseContainer = createContainer(MESSAGE_TYPE__StubMotorRunResponse, requestContainer->token, true, &response, &stub_motor_run_response__pack, &stub_motor_run_response__get_packed_size);
+
+ writeLine("Sending Response: ");
+
+ writeFloat(response.motor_id);
+
+ //writeString(", ");
+ //writeFloat(response.day);
+
+ //Write_status_response(status);
+
+ free(request);
+ //-------------------------------------------------------------------------------------------
+ uint8_t* container_buffer = malloc(message_container__get_packed_size(&responseContainer));
+ size_t container_size = message_container__pack(&responseContainer, container_buffer);
+ SendChars((char*)container_buffer, container_size);
+ free(container_buffer);
+ free(requestContainer);
+}
+
+
+void Stub_MotorStopRequest(MessageContainer* requestContainer)
+{
+ uint32_t read_status;
+ //uint32_t status = FAILED;
+
+ MessageContainer responseContainer;
+
+ StubMotorStopRequest* request = stub_motor_stop_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data);
+
+
+ Stop_Command = request->stop_cmd;
+
+ //SPI_Control(SKIP_INIT);
+ Mot_Stop();
+
+ //writeLine("L6470 Request: ");
+
+ //writeFloat(request->run_value);
+
+ //status = FPGA_ReadVersion((unsigned char)request->fpgaid, &Version, &Year, &Month, &Day);
+
+
+
+ StubMotorStopResponse response = STUB_MOTOR_STOP_RESPONSE__INIT;
+
+ // status_response(status,&response.status, &response.statusword ,&response.has_statusword);
+
+
+ response.motor_id = request->motor_id;
+ response.has_motor_id = true;
+
+ read_status = Get_and_Clear_Status();
+
+ response.mot_status = ((read_status & x_STATUS_MOT_STATUS)>>5);
+ response.has_mot_status = true;
+
+ response.hiz = (read_status & x_STATUS_HIZ);
+ response.has_hiz = true;
+
+ response.busy = ((read_status & x_STATUS_BUSY)>>1);
+ response.has_busy = true;
+
+ responseContainer = createContainer(MESSAGE_TYPE__StubMotorStopResponse, requestContainer->token, true, &response, &stub_motor_stop_response__pack, &stub_motor_stop_response__get_packed_size);
+
+ writeLine("Sending Response: ");
+
+ writeFloat(response.motor_id);
+
+ //writeString(", ");
+ //writeFloat(response.day);
+
+ //Write_status_response(status);
+
+ free(request);
+ //-------------------------------------------------------------------------------------------
+ uint8_t* container_buffer = malloc(message_container__get_packed_size(&responseContainer));
+ size_t container_size = message_container__pack(&responseContainer, container_buffer);
+ SendChars((char*)container_buffer, container_size);
+ free(container_buffer);
+ free(requestContainer);
+}
+
+
+
+void Stub_MotorStatusRequest(MessageContainer* requestContainer)
+{
+ uint32_t read_status;
+
+ MessageContainer responseContainer;
+
+ StubMotorStatusRequest* request = stub_motor_status_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data);
+
+
+ if(request->clearstatus)
+ {
+ read_status = Get_and_Clear_Status();
+ }
+ else
+ {
+ read_status = Get_Param(x_STATUS);
+ }
+
+ StubMotorStatusResponse response = STUB_MOTOR_STATUS_RESPONSE__INIT;
+
+ response.motor_id = request->motor_id;
+ response.has_motor_id = true;
+
+ response.sck_mod = ((read_status & x_STATUS_SCK_MOD)>>15);
+ response.has_sck_mod = true;
+
+ response.step_loss_b = ((read_status & x_STATUS_STEP_LOSS_B)>>14);
+ response.has_step_loss_b = true;
+
+ response.step_loss_a = ((read_status & x_STATUS_STEP_LOSS_A)>>13);
+ response.has_step_loss_a = true;
+
+ response.ocd = ((read_status & x_STATUS_OCD)>>12);
+ response.has_ocd = true;
+
+ response.th_sd = ((read_status & x_STATUS_TH_SD)>>11);
+ response.has_th_sd = true;
+
+ response.th_wrn = ((read_status & x_STATUS_TH_WRN)>>10);
+ response.has_th_wrn = true;
+
+ response.uvlo = ((read_status & x_STATUS_UVLO)>>9);
+ response.has_uvlo = true;
+
+ response.wrong_cmd = ((read_status & x_STATUS_WRONG_CMD)>>8);
+ response.has_wrong_cmd = true;
+
+ response.notperf_cmd = ((read_status & x_STATUS_NOTPERF_CMD)>>7);
+ response.has_notperf_cmd = true;
+
+ response.mot_status = ((read_status & x_STATUS_MOT_STATUS)>>5);
+ response.has_mot_status = true;
+
+ response.dir = ((read_status & x_STATUS_DIR)>>4);
+ response.has_dir = true;
+
+ response.sw_evn = ((read_status & x_STATUS_SW_EVN)>>3);
+ response.has_sw_evn = true;
+
+ response.sw_f = ((read_status & x_STATUS_SW_F)>>2);
+ response.has_sw_f = true;
+
+ response.busy = ((read_status & x_STATUS_BUSY)>>1);
+ response.has_busy = true;
+
+ response.hiz = (read_status & x_STATUS_HIZ);
+ response.has_hiz = true;
+
+ responseContainer = createContainer(MESSAGE_TYPE__StubMotorStatusResponse, requestContainer->token, true, &response, &stub_motor_status_response__pack, &stub_motor_status_response__get_packed_size);
+
+ writeLine("Sending Response: ");
+
+ writeFloat(response.motor_id);
+
+
+ free(request);
+ //-------------------------------------------------------------------------------------------
+ uint8_t* container_buffer = malloc(message_container__get_packed_size(&responseContainer));
+ size_t container_size = message_container__pack(&responseContainer, container_buffer);
+ SendChars((char*)container_buffer, container_size);
+ free(container_buffer);
+ free(requestContainer);
+}
+
+
+void Stub_MotorSpeedRequest(MessageContainer* requestContainer)
+{
+
+ MessageContainer responseContainer;
+
+ StubMotorSpeedRequest* request = stub_motor_speed_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data);
+
+ StubMotorSpeedResponse response = STUB_MOTOR_SPEED_RESPONSE__INIT;
+
+ response.motor_id = request->motor_id;
+ response.has_motor_id = true;
+
+ //response.speed = Get_Param(x_SPEED);
+ response.speed = (double)(CurrentSpdCalc(Get_Param(x_SPEED)));
+ response.has_speed = true;
+
+ responseContainer = createContainer(MESSAGE_TYPE__StubMotorSpeedResponse, requestContainer->token, true, &response, &stub_motor_speed_response__pack, &stub_motor_speed_response__get_packed_size);
+
+ free(request);
+ //-------------------------------------------------------------------------------------------
+ uint8_t* container_buffer = malloc(message_container__get_packed_size(&responseContainer));
+ size_t container_size = message_container__pack(&responseContainer, container_buffer);
+ SendChars((char*)container_buffer, container_size);
+ free(container_buffer);
+ free(requestContainer);
+}
+
+
+void Stub_MotorPositionRequest(MessageContainer* requestContainer)
+{
+
+ MessageContainer responseContainer;
+
+ StubMotorPositionRequest* request = stub_motor_position_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data);
+
+ StubMotorPositionResponse response = STUB_MOTOR_POSITION_RESPONSE__INIT;
+
+ response.motor_id = request->motor_id;
+ response.has_motor_id = true;
+
+ response.position = Get_Param(x_ABS_POS);
+ response.has_position = true;
+
+ responseContainer = createContainer(MESSAGE_TYPE__StubMotorPositionResponse, requestContainer->token, true, &response, &stub_motor_position_response__pack, &stub_motor_position_response__get_packed_size);
+
+ free(request);
+ //-------------------------------------------------------------------------------------------
+ uint8_t* container_buffer = malloc(message_container__get_packed_size(&responseContainer));
+ size_t container_size = message_container__pack(&responseContainer, container_buffer);
+ SendChars((char*)container_buffer, container_size);
+ free(container_buffer);
+ free(requestContainer);
+}
+
+
+void Stub_MotorMovRequest(MessageContainer* requestContainer)
+{
+ uint32_t read_status;
+
+ MessageContainer responseContainer;
+
+ StubMotorMovRequest* request = stub_motor_mov_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data);
+
+ Pos_Value = request->position;
+ Direction = request->direction;
+
+ Mot_Mov();
+
+ StubMotorMovResponse response = STUB_MOTOR_MOV_RESPONSE__INIT;
+
+ response.motor_id = request->motor_id;
+ response.has_motor_id = true;
+
+
+ response.position = Get_Param(x_ABS_POS);
+ response.has_position = true;
+
+ while(SSIBusy(SSI2_BASE)){};
+
+ read_status = Get_and_Clear_Status();
+
+
+ response.status_reg = read_status;
+ response.has_status_reg = true;
+
+ response.direction = ((read_status & x_STATUS_DIR)>>4);
+ response.has_direction = true;
+
+ response.step_loss_a = ((read_status & x_STATUS_STEP_LOSS_A)>>13);
+ response.has_step_loss_a = true;
+ response.step_loss_b = ((read_status & x_STATUS_STEP_LOSS_B)>>14);
+ response.has_step_loss_b = true;
+
+
+ response.mot_status = ((read_status & x_STATUS_MOT_STATUS)>>5);
+ response.has_mot_status = true;
+
+ responseContainer = createContainer(MESSAGE_TYPE__StubMotorMovResponse, requestContainer->token, true, &response, &stub_motor_mov_response__pack, &stub_motor_mov_response__get_packed_size);
+
+ free(request);
+ //-------------------------------------------------------------------------------------------
+ uint8_t* container_buffer = malloc(message_container__get_packed_size(&responseContainer));
+ size_t container_size = message_container__pack(&responseContainer, container_buffer);
+ SendChars((char*)container_buffer, container_size);
+ free(container_buffer);
+ free(requestContainer);
+}
+
diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Motor.h b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Motor.h
new file mode 100644
index 000000000..95f82353f
--- /dev/null
+++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Motor.h
@@ -0,0 +1,7 @@
+void Stub_MotorInitRequest(MessageContainer* requestContainer);
+void Stub_MotorRunRequest(MessageContainer* requestContainer);
+void Stub_MotorStopRequest(MessageContainer* requestContainer);
+void Stub_MotorStatusRequest(MessageContainer* requestContainer);
+void Stub_MotorSpeedRequest(MessageContainer* requestContainer);
+void Stub_MotorPositionRequest(MessageContainer* requestContainer);
+void Stub_MotorMovRequest(MessageContainer* requestContainer);
diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/temperature_sensor.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/temperature_sensor.c
new file mode 100644
index 000000000..994f6d84f
--- /dev/null
+++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/temperature_sensor.c
@@ -0,0 +1,264 @@
+//*****************************************************************************
+//
+// temperature_sensor.c - Example demonstrating the internal ADC temperature
+// sensor.
+//
+// Copyright (c) 2010-2014 Texas Instruments Incorporated. All rights reserved.
+// Software License Agreement
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+//
+// Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//
+// Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the
+// distribution.
+//
+// Neither the name of Texas Instruments Incorporated nor the names of
+// its contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// This is part of revision 2.1.0.12573 of the Tiva Firmware Development Package.
+//
+//*****************************************************************************
+/*
+ * This code was made to show a simple ADC read.
+ *
+ * It was made from the example provided by TivaWare but it was a some modifications
+ * like the math
+ *
+ *
+ * Lu?s Afonso
+ * https://sites.google.com/site/luiselectronicprojects/tutorials/tiva-tutorials/tiva-adc/internal-temperature-sensor
+ *
+ */
+
+#include <stdint.h>
+#include <stdbool.h>
+#include "stdlib.h"
+#include "inc/hw_ints.h"
+#include "inc/hw_memmap.h"
+#include "inc/hw_uart.h"
+#include "inc/hw_gpio.h"
+#include "inc/hw_pwm.h"
+#include "inc/hw_types.h"
+#include "driverlib/adc.h"
+#include "driverlib/timer.h"
+#include "driverlib/gpio.h"
+#include "driverlib/interrupt.h"
+#include "driverlib/pin_map.h"
+#include "driverlib/rom.h"
+#include "driverlib/rom_map.h"
+#include "driverlib/sysctl.h"
+#include "driverlib/uart.h"
+#include "driverlib/udma.h"
+#include "driverlib/pwm.h"
+#include "driverlib/ssi.h"
+#include "driverlib/systick.h"
+#include "driverlib/adc.h"
+#include "utils/uartstdio.h"
+#include "utils/uartstdio.c"
+#include <string.h>
+
+#include "Drivers/USB_Communication/USBCDCD.h"
+#include "drivers/twine_graphicslib/graphics_adapter.h"
+
+//*****************************************************************************
+//
+// This function sets up UART0 to be used for a console to display information
+// as the example is running.
+//
+//*****************************************************************************
+void
+InitConsole(void)
+{
+ //
+ // Enable GPIO port A which is used for UART0 pins.
+ // TODO: change this to whichever GPIO port you are using.
+ //
+ SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
+
+ //
+ // Configure the pin muxing for UART0 functions on port A0 and A1.
+ // This step is not necessary if your part does not support pin muxing.
+ // TODO: change this to select the port/pin you are using.
+ //
+ GPIOPinConfigure(GPIO_PA0_U0RX);
+ GPIOPinConfigure(GPIO_PA1_U0TX);
+
+ //
+ // Enable UART0 so that we can configure the clock.
+ //
+ SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
+
+ //
+ // Use the internal 16MHz oscillator as the UART clock source.
+ //
+ UARTClockSourceSet(UART0_BASE, UART_CLOCK_PIOSC);
+
+ //
+ // Select the alternate (UART) function for these pins.
+ // TODO: change this to select the port/pin you are using.
+ //
+ GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
+
+ //
+ // Initialize the UART for console I/O.
+ //
+ UARTStdioConfig(0, 115200, 16000000);
+}
+
+int temperature_main(){
+ SysCtlClockSet(SYSCTL_SYSDIV_2_5|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ);
+ InitConsole();
+ //
+ // This array is used for storing the data read from the ADC FIFO. It
+ // must be as large as the FIFO for the sequencer in use. This example
+ // uses sequence 3 which has a FIFO depth of 1. If another sequence
+ // was used with a deeper FIFO, then the array size must be changed.
+ //
+ uint32_t ADCValues[1];
+
+ //
+ // These variables are used to store the temperature conversions for
+ // Celsius and Fahrenheit.
+ //
+ uint32_t TempValueC ;
+ uint32_t TempValueF ;
+
+
+ //
+ // Display the setup on the console.
+ //
+ UARTprintf("ADC ->\n");
+ UARTprintf(" Type: Internal Temperature Sensor\n");
+ UARTprintf(" Samples: One\n");
+ UARTprintf(" Update Rate: 250ms\n");
+ UARTprintf(" Input Pin: Internal temperature sensor\n\n");
+
+ writeLine("ADC ->\n");
+ writeLine(" Type: Internal Temperature Sensor\n");
+ writeLine(" Samples: One\n");
+ writeLine(" Update Rate: 250ms\n");
+ writeLine(" Input Pin: Internal temperature sensor\n\n");
+
+ //
+ // The ADC0 peripheral must be enabled for use.
+ //
+ SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
+ SysCtlDelay(3);//3 wait cycles after enabling a clock on a peripheral
+
+ //
+ // Enable sample sequence 3 with a processor signal trigger. Sequence 3
+ // will do a single sample when the processor sends a singal to start the
+ // conversion. Each ADC module has 4 programmable sequences, sequence 0
+ // to sequence 3. This example is arbitrarily using sequence 3.
+ //
+ ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_PROCESSOR, 0);
+
+ //
+ // Configure step 0 on sequence 3. Sample the temperature sensor
+ // (ADC_CTL_TS) and configure the interrupt flag (ADC_CTL_IE) to be set
+ // when the sample is done. Tell the ADC logic that this is the last
+ // conversion on sequence 3 (ADC_CTL_END). Sequence 3 has only one
+ // programmable step. Sequence 1 and 2 have 4 steps, and sequence 0 has
+ // 8 programmable steps. Since we are only doing a single conversion using
+ // sequence 3 we will only configure step 0. For more information on the
+ // ADC sequences and steps, reference the datasheet.
+ //
+ ADCSequenceStepConfigure(ADC0_BASE, 3, 0, ADC_CTL_TS | ADC_CTL_IE |
+ ADC_CTL_END);
+
+ //ADCHardwareOversampleConfigure(ADC0_BASE,64);//This will configure to do averages of 64 values (powers of 2, from 2 to 64 )
+
+ //
+ // Since sample sequence 3 is now configured, it must be enabled.
+ //
+ ADCSequenceEnable(ADC0_BASE, 3);
+
+ //
+ // Clear the interrupt status flag. This is done to make sure the
+ // interrupt flag is cleared before we sample.
+ //
+ ADCIntClear(ADC0_BASE, 3);
+
+ //
+ // Sample the temperature sensor forever. Display the value on the
+ // console.
+ //
+ while(1)
+ {
+ //
+ // Trigger the ADC conversion.
+ //
+ ADCProcessorTrigger(ADC0_BASE, 3);
+
+ //
+ // Wait for conversion to be completed.
+ //
+ while(!ADCIntStatus(ADC0_BASE, 3, false))
+ {
+ }
+
+ //
+ // Clear the ADC interrupt flag.
+ //
+ ADCIntClear(ADC0_BASE, 3);
+
+ //
+ // Read ADC Value.
+ //
+ ADCSequenceDataGet(ADC0_BASE, 3, ADCValues);
+
+ //
+ // Use non-calibrated conversion provided in the data sheet. I use floats in intermediate
+ // math but you could use intergers with multiplied by powers of 10 and divide on the end
+ // Make sure you divide last to avoid dropout.
+ //
+ TempValueC = (uint32_t)(147.5 - ((75.0*3.3 *(float)ADCValues[0])) / 4096.0);
+
+ //float Temaraure_C = 147.5 - ((75.0*3.3 *(float)ADCValues[0])) / 4096.0;
+
+ //
+ // Get Fahrenheit value. Make sure you divide last to avoid dropout.
+ //
+ TempValueF = ((TempValueC * 9) + 160) / 5;
+
+ //
+ // Display the temperature value on the console.
+ //
+ UARTprintf("Temperature = %3d*C or %3d*F\r", TempValueC,
+ TempValueF);
+
+ writeLine("Temperature(Celsius): ");
+ writeFloat(TempValueC);
+
+ //
+ // This function provides a means of generating a constant length
+ // delay. The function delay (in cycles) = 3 * parameter. Delay
+ // 250ms arbitrarily.
+ //
+ SysCtlDelay(80000000 / 12);
+
+ ///SysCtlDelay(80000000);
+ }
+
+
+
+}
diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/temperature_sensor.h b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/temperature_sensor.h
new file mode 100644
index 000000000..6368cf744
--- /dev/null
+++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/temperature_sensor.h
@@ -0,0 +1 @@
+int temperature_main();