aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Embedded_SW/Embedded
diff options
context:
space:
mode:
authorShlomo Hecht <shlomo@twine-s.com>2018-04-08 18:39:20 +0300
committerShlomo Hecht <shlomo@twine-s.com>2018-04-08 18:39:20 +0300
commitf22f64fec07df88dc302c7d541197a01bec50879 (patch)
tree6582b163793d13ff57d5497cd6c464b98dfa12f9 /Software/Embedded_SW/Embedded
parent692d71abcd583ade2977d4b6012b9c2a6de7d4d8 (diff)
downloadTango-f22f64fec07df88dc302c7d541197a01bec50879.tar.gz
Tango-f22f64fec07df88dc302c7d541197a01bec50879.zip
Communication Tx, Communication Rx tasks.
UART comunication (no buffers yet!)
Diffstat (limited to 'Software/Embedded_SW/Embedded')
-rw-r--r--Software/Embedded_SW/Embedded/.cproject20
-rw-r--r--Software/Embedded_SW/Embedded/Common/Utilities/idle_task.c2
-rw-r--r--Software/Embedded_SW/Embedded/Common/report/reportInit.c5
-rw-r--r--Software/Embedded_SW/Embedded/Communication/CommunicationTask.c173
-rw-r--r--Software/Embedded_SW/Embedded/Communication/CommunicationTask.h27
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/Danser_SSI/SSI_Comm.c55
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA.c16
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_Comm.h58
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.c102
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.h6
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/Motors/Motor.c106
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/Motors/Motor.h47
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/SPI/SPI_Comm.c20
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/SPI/SPI_Comm.h2
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/USB_Communication/USBCDCD - Copy.new1063
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/USB_Communication/USBCDCD.bak1053
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/USB_Communication/USBCDCD.c79
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/USB_Communication/USBCDCD.h5
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/USB_Communication/usb_serial_buffer.c29
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/USB_Communication/usb_serial_buffer.h20
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/Uart_Comm/Uart.c271
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/Uart_Comm/Uart.h2
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/twine_usblib/usb_serial_buffer.c32
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/twine_usblib/usb_serial_buffer.h20
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/twine_usblib/usb_serial_structs.c211
-rw-r--r--Software/Embedded_SW/Embedded/Drivers/twine_usblib/usb_serial_structs.h49
-rw-r--r--Software/Embedded_SW/Embedded/Embedded.cfg32
-rw-r--r--Software/Embedded_SW/Embedded/Main.c16
-rw-r--r--Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c8
-rw-r--r--Software/Embedded_SW/Embedded/Modules/General/process.c2
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_init.c7
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Calculate.c2
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Container.c2
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Stubs_Handler/DataDef.h10
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c4
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Cartridge.c4
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Dispenser.c2
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_ExtFlash.c4
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_FPGAReadBackReg.c2
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_FPGAReadVersion.c2
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_GPIO.c10
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_HW_Version.c2
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Heater.c2
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_L6470.c2
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Motor.c14
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_MotorEncoder.c2
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_OptLimitSwitch.c2
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_SteperMotor.c2
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Valve.c2
-rw-r--r--Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c2
50 files changed, 887 insertions, 2723 deletions
diff --git a/Software/Embedded_SW/Embedded/.cproject b/Software/Embedded_SW/Embedded/.cproject
index 5c1e4b40e..cfa8874b0 100644
--- a/Software/Embedded_SW/Embedded/.cproject
+++ b/Software/Embedded_SW/Embedded/.cproject
@@ -14,7 +14,7 @@
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
- <configuration artifactExtension="out" artifactName="${ProjName}" buildProperties="" cleanCommand="${CG_CLEAN_CMD}" description="" errorParsers="org.eclipse.rtsc.xdctools.parsers.ErrorParser;com.ti.ccstudio.errorparser.CoffErrorParser;com.ti.ccstudio.errorparser.LinkErrorParser;com.ti.ccstudio.errorparser.AsmErrorParser;org.eclipse.cdt.core.GmakeErrorParser" id="com.ti.ccstudio.buildDefinitions.TMS470.Debug.87225697" name="Debug" parent="com.ti.ccstudio.buildDefinitions.TMS470.Debug" postbuildStep="&quot;${CCS_INSTALL_ROOT}/utils/tiobj2bin/tiobj2bin&quot; &quot;${BuildArtifactFileName}&quot; &quot;${BuildArtifactFileBaseName}.bin&quot; &quot;${CG_TOOL_ROOT}/bin/armofd&quot; &quot;${CG_TOOL_ROOT}/bin/armhex&quot; &quot;${CCS_INSTALL_ROOT}/utils/tiobj2bin/mkhex4bin&quot;;" prebuildStep="..\..\..\Visual_Studio\Build\Debug\proto-tc.exe -i ..\..\..\PMR\Messages -o ..\communication\PMR -l C -c&quot;Common,Stubs,Hardware,Printing,Debugging&quot;;">
+ <configuration artifactExtension="out" artifactName="${ProjName}" buildProperties="" cleanCommand="${CG_CLEAN_CMD}" description="" errorParsers="org.eclipse.rtsc.xdctools.parsers.ErrorParser;com.ti.ccstudio.errorparser.CoffErrorParser;com.ti.ccstudio.errorparser.LinkErrorParser;com.ti.ccstudio.errorparser.AsmErrorParser;org.eclipse.cdt.core.GmakeErrorParser" id="com.ti.ccstudio.buildDefinitions.TMS470.Debug.87225697" name="Debug" parent="com.ti.ccstudio.buildDefinitions.TMS470.Debug" postbuildStep="&quot;${CCS_INSTALL_ROOT}/utils/tiobj2bin/tiobj2bin&quot; &quot;${BuildArtifactFileName}&quot; &quot;${BuildArtifactFileBaseName}.bin&quot; &quot;${CG_TOOL_ROOT}/bin/armofd&quot; &quot;${CG_TOOL_ROOT}/bin/armhex&quot; &quot;${CCS_INSTALL_ROOT}/utils/tiobj2bin/mkhex4bin&quot;;" prebuildStep="&quot;../../../Visual_Studio/Build/Debug/proto-tc.exe&quot; -i ../../../PMR/Messages -o ../Communication/PMR -l C -c&quot;Common,Hardware,Printing,Debugging,Stubs&quot;;">
<folderInfo id="com.ti.ccstudio.buildDefinitions.TMS470.Debug.87225697." name="/" resourcePath="">
<toolChain id="com.ti.ccstudio.buildDefinitions.TMS470_16.9.exe.DebugToolchain.860669086" name="TI Build Tools" superClass="com.ti.ccstudio.buildDefinitions.TMS470_16.9.exe.DebugToolchain" targetTool="com.ti.ccstudio.buildDefinitions.TMS470_16.9.exe.linkerDebug.1136464770">
<option id="com.ti.ccstudio.buildDefinitions.core.OPT_TAGS.1867606889" superClass="com.ti.ccstudio.buildDefinitions.core.OPT_TAGS" valueType="stringList">
@@ -43,6 +43,7 @@
<option id="com.ti.ccstudio.buildDefinitions.TMS470_16.9.compilerID.GCC.2141632125" name="Enable support for GCC extensions (DEPRECATED) (--gcc)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_16.9.compilerID.GCC" value="true" valueType="boolean"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_16.9.compilerID.DEFINE.726218403" name="Pre-define NAME (--define, -D)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_16.9.compilerID.DEFINE" valueType="definedSymbols">
<listOptionValue builtIn="false" value="${COM_TI_RTSC_TIRTOSTIVAC_SYMBOLS}"/>
+ <listOptionValue builtIn="false" value="DEBUG_TEST_FUNCTIONS"/>
<listOptionValue builtIn="false" value="TARGET_IS_TM4C129_RA0"/>
<listOptionValue builtIn="false" value="ccs=&quot;ccs&quot;"/>
<listOptionValue builtIn="false" value="ccs"/>
@@ -53,19 +54,22 @@
<option id="com.ti.ccstudio.buildDefinitions.TMS470_16.9.compilerID.OPT_LEVEL.360066293" name="Optimization level (--opt_level, -O)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_16.9.compilerID.OPT_LEVEL" value="com.ti.ccstudio.buildDefinitions.TMS470_16.9.compilerID.OPT_LEVEL.off" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_16.9.compilerID.OPT_FOR_SPEED.365060741" name="Speed vs. size trade-offs (--opt_for_speed, -mf)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_16.9.compilerID.OPT_FOR_SPEED" value="com.ti.ccstudio.buildDefinitions.TMS470_16.9.compilerID.OPT_FOR_SPEED.0" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_16.9.compilerID.INCLUDE_PATH.1455785365" name="Add dir to #include search path (--include_path, -I)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_16.9.compilerID.INCLUDE_PATH" valueType="includePath">
- <listOptionValue builtIn="false" value="&quot;${COM_TI_RTSC_TIRTOSTIVAC_INCLUDE_PATH}&quot;"/>
+ <listOptionValue builtIn="false" value=""/>
<listOptionValue builtIn="false" value="&quot;${COM_TI_RTSC_TIRTOSTIVAC_INSTALL_DIR}/products/ndk_2_25_00_09/packages/ti/ndk/inc/bsd&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}}/Common/protobuf-c&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}}&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}}/Communication/PMR/Hardware&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}}/Communication/PMR/Printing&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}}/Communication/PMR/Common&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}}/Communication/PMR&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/Communication}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/Common}&quot;"/>
- <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}}/Communication/PMR&quot;"/>
- <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}}/Communication/PMR/Common&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}}/Modules&quot;"/>
<listOptionValue builtIn="false" value="&quot;${TIVAWARE_DRIVERS}&quot;"/>
<listOptionValue builtIn="false" value="&quot;C:\ti\xdctools_3_32_00_06_core\include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${COM_TI_RTSC_TIRTOSTIVAC_INSTALL_DIR}/products/TivaWare_C_Series-2.1.1.71b&quot;"/>
- <listOptionValue builtIn="false" value="&quot;${COM_TI_RTSC_TIRTOSTIVAC_INSTALL_DIR}/products/bios_6_45_02_31/packages/ti/sysbios/posix&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${COM_TI_RTSC_TIRTOSTIVAC_INSTALL_DIR}/products/bios_6_45_01_29/packages/ti/sysbios/posix&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${COM_TI_RTSC_TIRTOSTIVAC_INSTALL_DIR}/products/tidrivers_tivac_2_16_00_08&quot;"/>
<listOptionValue builtIn="false" value="&quot;${CG_TOOL_ROOT}/include&quot;"/>
</option>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_16.9.compilerID.DEBUGGING_MODEL.766037658" name="Debugging model" superClass="com.ti.ccstudio.buildDefinitions.TMS470_16.9.compilerID.DEBUGGING_MODEL" value="com.ti.ccstudio.buildDefinitions.TMS470_16.9.compilerID.DEBUGGING_MODEL.SYMDEBUG__DWARF" valueType="enumerated"/>
@@ -82,8 +86,8 @@
</tool>
<tool id="com.ti.ccstudio.buildDefinitions.TMS470_16.9.exe.linkerDebug.1136464770" name="ARM Linker" superClass="com.ti.ccstudio.buildDefinitions.TMS470_16.9.exe.linkerDebug">
<option id="com.ti.ccstudio.buildDefinitions.TMS470_16.9.linkerID.MAP_FILE.1799717231" name="Link information (map) listed into &lt;file&gt; (--map_file, -m)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_16.9.linkerID.MAP_FILE" value="&quot;${ProjName}.map&quot;" valueType="string"/>
- <option id="com.ti.ccstudio.buildDefinitions.TMS470_16.9.linkerID.STACK_SIZE.32186825" name="Set C system stack size (--stack_size, -stack)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_16.9.linkerID.STACK_SIZE" value="4096" valueType="string"/>
- <option id="com.ti.ccstudio.buildDefinitions.TMS470_16.9.linkerID.HEAP_SIZE.1726613453" name="Heap size for C/C++ dynamic memory allocation (--heap_size, -heap)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_16.9.linkerID.HEAP_SIZE" value="10240" valueType="string"/>
+ <option id="com.ti.ccstudio.buildDefinitions.TMS470_16.9.linkerID.STACK_SIZE.32186825" name="Set C system stack size (--stack_size, -stack)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_16.9.linkerID.STACK_SIZE" value="2048" valueType="string"/>
+ <option id="com.ti.ccstudio.buildDefinitions.TMS470_16.9.linkerID.HEAP_SIZE.1726613453" name="Heap size for C/C++ dynamic memory allocation (--heap_size, -heap)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_16.9.linkerID.HEAP_SIZE" value="20240" valueType="string"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_16.9.linkerID.OUTPUT_FILE.639816850" name="Specify output file name (--output_file, -o)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_16.9.linkerID.OUTPUT_FILE" value="&quot;${ProjName}.out&quot;" valueType="string"/>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_16.9.linkerID.LIBRARY.1644568501" name="Include library file or command file as input (--library, -l)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_16.9.linkerID.LIBRARY" valueType="libs">
<listOptionValue builtIn="false" value="${COM_TI_RTSC_TIRTOSTIVAC_LIBRARIES}"/>
@@ -155,7 +159,7 @@
</toolChain>
</folderInfo>
<sourceEntries>
- <entry excluding="Drivers/twine_usblib|Modules/Control/DriverWithCallbackExample.c|tm4c129xnczad_startup_ccs.c|Common/Software_CRC|Common/Sys_PinOut_Config/MCU_MAIN_pinout.c|Drivers/L6470|Flashstore.c|Configuration.c|Pin_config.c|SlowMotors.c|Profile.c|FastMotors.c|JigCommands.c|Pin.c|USBCDCD.c|ADCLogger.c|ADCUtils.c|PWM.c|Timer.c|Message.c|Communication.c" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
+ <entry excluding="src|tm4c129xnczad_startup_ccs.c|Common/Sys_PinOut_Config/MCU_MAIN_pinout.c|Drivers/L6470|Flashstore.c|Configuration.c|Pin_config.c|SlowMotors.c|Profile.c|FastMotors.c|JigCommands.c|Pin.c|USBCDCD.c|ADCLogger.c|ADCUtils.c|PWM.c|Timer.c|Message.c|Communication.c" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
</sourceEntries>
</configuration>
</storageModule>
diff --git a/Software/Embedded_SW/Embedded/Common/Utilities/idle_task.c b/Software/Embedded_SW/Embedded/Common/Utilities/idle_task.c
index f2caf3bcb..5f792e73d 100644
--- a/Software/Embedded_SW/Embedded/Common/Utilities/idle_task.c
+++ b/Software/Embedded_SW/Embedded/Common/Utilities/idle_task.c
@@ -47,8 +47,6 @@ static void calculate_system_load (int current_load);
static uint32_t idle_counter;
static long next_interval; /*by ticks*/
-static long idle_task_id;
-static long IDLE_statistic_task_id;
static bool first_time_after_init;
static int system_load;
static int load;
diff --git a/Software/Embedded_SW/Embedded/Common/report/reportInit.c b/Software/Embedded_SW/Embedded/Common/report/reportInit.c
index cf0b7536c..575813bc4 100644
--- a/Software/Embedded_SW/Embedded/Common/report/reportInit.c
+++ b/Software/Embedded_SW/Embedded/Common/report/reportInit.c
@@ -34,7 +34,6 @@
#include "PMR/common/MessageContainer.pb-c.h"
#include "PMR/debugging/DebugLogRequest.pb-c.h"
#include "PMR/debugging/DebugLogResponse.pb-c.h"
-#include "drivers/twine_usblib/usb_serial_adapter.h"
//#include "graphics_adapter.h"
#include "Modules/Stubs_Handler/Container.h"
@@ -54,7 +53,7 @@ char protobufToken[36] = {0};
free(responseContainer.data.data);
//USBCDCD_sendData(container_buffer, container_size,10);
SendChars(container_buffer, container_size);
- free(container_buffer);
+ //free(container_buffer);
}*/
@@ -90,7 +89,7 @@ int ReportResponseFunc(char *message, /* The formatted message
free(responseContainer.data.data);
//USBCDCD_sendData(container_buffer, container_size,10);
SendChars(container_buffer, container_size);
- free (container_buffer);
+ //free (container_buffer);
return OK;
diff --git a/Software/Embedded_SW/Embedded/Communication/CommunicationTask.c b/Software/Embedded_SW/Embedded/Communication/CommunicationTask.c
new file mode 100644
index 000000000..30c6f5ce5
--- /dev/null
+++ b/Software/Embedded_SW/Embedded/Communication/CommunicationTask.c
@@ -0,0 +1,173 @@
+/*
+ * CommunicationTask.c
+ *
+ * Created on: 8 áàôø× 2018
+ * Author: shlomo
+ */
+
+#include "include.h"
+
+
+static void (*callback)(char* buffer, size_t length);
+
+Mailbox_Handle CommunicationRxMsgQ = NULL;
+Mailbox_Handle CommunicationTxMsgQ = NULL;
+
+typedef struct CommRxMessage{
+ uint16_t messageId;
+ uint16_t msgSize;
+}CommRxMessageStruc;
+typedef struct CommTxMessage{
+ uint16_t messageId;
+ uint16_t msgSize;
+ char *Buff;
+}CommTxMessageStruc;
+
+
+struct serialBuffer {
+ char *buffer;
+ size_t used;
+ size_t size;
+} typedef SerialBuffer;
+
+char Buffer[2000];
+SerialBuffer inBuffer;
+uint32_t initArray(size_t initialSize) {
+ SerialBuffer *a = &inBuffer;
+ if (initialSize >= 2000) return 0;
+ a->buffer = Buffer;
+ a->used = 0;
+ a->size = initialSize;
+ return initialSize;
+}
+
+void insertArray(char element) {
+ SerialBuffer *a = &inBuffer;
+ // a->used is the number of used entries, because a->array[a->used++] updates a->used only *after* the array has been accessed.
+ // Therefore a->used can go up to a->size
+ a->buffer[a->used++] = element;
+}
+
+void freeArray(void) {
+ SerialBuffer *a = &inBuffer;
+ a->used = a->size = 0;
+}
+
+Mailbox_Handle CommunicationRxMsgQ;
+uint32_t CommunicationTaskInit(void)
+{
+ return OK;
+}
+uint32_t CommunicationTaskMessageReceived(uint16_t msgSize)
+{
+ CommRxMessageStruc Message;
+
+ Message.messageId = 1;
+ Message.msgSize = msgSize;
+ if (CommunicationRxMsgQ != NULL)
+ /*retcode =*/ Mailbox_post(CommunicationRxMsgQ , &Message, BIOS_NO_WAIT);
+
+}
+void RegisterReceiveCallback(void (*callback_ptr)(char* buffer, size_t length))
+{
+ callback = callback_ptr;
+}
+
+/******************************************************************************
+ * ======== communicationTask ========
+ * Task for this function is created statically. See the project's .cfg file.
+ * this communication task is created statically in system initialization, in blocking mode
+ * over one of the chosen ommunication methods (USB or Blutooth).
+ ******************************************************************************/
+void communicationTask(UArg arg0, UArg arg1)
+{
+
+ uint32_t ui32RxCount;
+ CommRxMessageStruc Message;
+
+ initArray(1);
+
+ ui32RxCount = 0;
+ CommunicationRxMsgQ = Mailbox_create(sizeof(CommRxMessageStruc), 5, NULL,NULL);
+
+ USBCDCD_init();
+ //Init_U0();
+ /* Block while the device is NOT connected to the USB */
+// Semaphore_pend(initConnectionSem, BIOS_WAIT_FOREVER);
+
+ while(1)
+ {
+ Mailbox_pend(CommunicationRxMsgQ , &Message, BIOS_WAIT_FOREVER);
+ switch (Message.messageId)
+ {
+ case 1:
+ ui32RxCount += Message.msgSize;
+ if (callback != NULL)
+ {
+ callback(inBuffer.buffer,inBuffer.used);
+ }
+
+ freeArray();
+ initArray( 1);
+ break;
+ default:
+ break;
+ }
+ }
+
+}
+
+uint32_t CommunicationTaskSendMessage(char* buffer,size_t length)
+{
+ CommTxMessageStruc Message;
+
+ Message.messageId = 1;
+ Message.msgSize = length;
+ Message.Buff = buffer;
+ if (CommunicationTxMsgQ != NULL)
+ /*retcode =*/ Mailbox_post(CommunicationTxMsgQ , &Message, BIOS_NO_WAIT);
+
+ return OK;
+}
+
+/******************************************************************************
+ * ======== communicationTask ========
+ * Task for this function is created statically. See the project's .cfg file.
+ * this communication task is created statically in system initialization, in blocking mode
+ * over one of the chosen ommunication methods (USB or Blutooth).
+ ******************************************************************************/
+void communicationTxTask(UArg arg0, UArg arg1)
+{
+
+ uint32_t ui32RxCount;
+ CommTxMessageStruc Message;
+/* typedef struct CommRxMessage{
+ uint16_t messageId;
+ uint16_t msgSize;
+ char *Buff;
+ }CommTxMessageStruc;
+*/
+ initArray(1);
+
+ ui32RxCount = 0;
+ CommunicationTxMsgQ = Mailbox_create(sizeof(CommTxMessageStruc), 10, NULL,NULL);
+
+ /* Block while the device is NOT connected to the USB */
+// Semaphore_pend(initConnectionSem, BIOS_WAIT_FOREVER);
+
+ while(1)
+ {
+ Mailbox_pend(CommunicationTxMsgQ , &Message, BIOS_WAIT_FOREVER);
+ switch (Message.messageId)
+ {
+ case 1:
+ //USBCDCD_sendData(Message.Buff, Message.msgSize,10);
+ Uart_Tx(Message.Buff, Message.msgSize);
+ free (Message.Buff);
+ break;
+ default:
+ break;
+ }
+ }
+
+}
diff --git a/Software/Embedded_SW/Embedded/Communication/CommunicationTask.h b/Software/Embedded_SW/Embedded/Communication/CommunicationTask.h
new file mode 100644
index 000000000..dd18c1039
--- /dev/null
+++ b/Software/Embedded_SW/Embedded/Communication/CommunicationTask.h
@@ -0,0 +1,27 @@
+/*
+ * CommunicationTask.h
+ *
+ * Created on: 8 áàôø× 2018
+ * Author: shlomo
+ */
+
+#ifndef COMMUNICATION_COMMUNICATIONTASK_H_
+#define COMMUNICATION_COMMUNICATIONTASK_H_
+
+
+void RegisterReceiveCallback(void (*callback_ptr)(char* buffer, size_t length));
+
+uint32_t initArray( size_t initialSize);
+
+void insertArray( char element);
+
+void freeArray(void);
+
+extern uint32_t CommunicationTaskInit(void);
+
+extern uint32_t CommunicationTaskMessageReceived(uint16_t msgSize);
+
+extern uint32_t CommunicationTaskSendMessage(char* buffer,size_t length);
+
+
+#endif /* COMMUNICATION_COMMUNICATIONTASK_H_ */
diff --git a/Software/Embedded_SW/Embedded/Drivers/Danser_SSI/SSI_Comm.c b/Software/Embedded_SW/Embedded/Drivers/Danser_SSI/SSI_Comm.c
index 727e3ecbe..dc8b2124a 100644
--- a/Software/Embedded_SW/Embedded/Drivers/Danser_SSI/SSI_Comm.c
+++ b/Software/Embedded_SW/Embedded/Drivers/Danser_SSI/SSI_Comm.c
@@ -10,6 +10,26 @@
//00 - No special requirements
+/*
+down
+
+Name : RByte
+ Default:34988
+ Hex:0x000088AC
+ Decimal:34988
+ Octal:0104254
+ Binary:0000000000000000 10001000101011 00b (position = 8747)
+up
+ Name : RByte
+ Default:44520
+ Hex:0x0000ADE8
+ Decimal:44520
+ Octal:0126750
+ Binary:0000000000000000 10101101111010 00b (position = 11130)
+
+ missing 8 bits of Detailed status (the 16 MSB should not be receive)
+ */
+
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
@@ -27,11 +47,12 @@
#include <driverlib/rom_map.h>
#include <Stubs_Handler/DataDef.h>
+#include "driverlib/uart.h"
typedef struct // 24bit
{
- unsigned char Det_status:8;
- unsigned char Gen_status:2;
unsigned short Position:14;
+ unsigned char Gen_status:2;
+ unsigned char Det_status:8;
}SSI_ENC;
/*
typedef enum
@@ -87,9 +108,9 @@ void SSI1_Init()
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
/* Configure pad settings */ // AVI
- GPIOPadConfigSet(GPIO_PORTE_BASE,
- GPIO_PIN_4,
- GPIO_STRENGTH_4MA, GPIO_PIN_TYPE_STD);
+// GPIOPadConfigSet(GPIO_PORTE_BASE,
+// GPIO_PIN_4,
+// GPIO_STRENGTH_4MA, GPIO_PIN_TYPE_STD);
GPIOPadConfigSet(GPIO_PORTE_BASE,
GPIO_PIN_5,
@@ -129,8 +150,12 @@ void SSI1_Init()
// Configure and enable the SSI1 port for SPI Master mode.
//
- SSIConfigSetExpClk(SSI1_BASE, ui32SysClock, SSI_FRF_NMW,
- SSI_MODE_MASTER, 500000, 16); // to receive Clock period 2uSec, Clock frequency 500KHz
+// SSIConfigSetExpClk(SSI1_BASE, ui32SysClock, SSI_FRF_NMW,
+// SSI_MODE_MASTER, 500000, 16); // to receive Clock period 2uSec, Clock frequency 500KHz
+// //SSI_MODE_MASTER send 24 bits 0x00 (dummy) 0x7f 0xff -> create clock of 24 bits for SSI
+//
+ SSIConfigSetExpClk(SSI1_BASE, ui32SysClock, SSI_FRF_MOTO_MODE_0,//SSI_FRF_NMW,
+ SSI_MODE_MASTER, 500000, 32);//16); // to receive Clock period 2uSec, Clock frequency 500KHz
//SSI_MODE_MASTER send 24 bits 0x00 (dummy) 0x7f 0xff -> create clock of 24 bits for SSI
SSIAdvModeSet(SSI1_BASE,SSI_ADV_MODE_READ_WRITE ); // ??? Acording to Silicon Errata - SSI1 can Only be Used in Legacy Mode !!!
@@ -148,14 +173,17 @@ uint32_t Write_Dummy_Byte()
uint8_t WByte = 0x00; // Dummy Byte
uint32_t RByte = 0x00;
+
SSIDataPut(SSI1_BASE, WByte);
while(SSIBusy(SSI1_BASE)){};
- SSIDataGet(SSI1_BASE, &RByte);// 24 bytes
- return (RByte & 0xffffff);// 24 bytes
+ while(SSIDataGetNonBlocking(SSI1_BASE, &RByte)){}; //FIFO to read 24 bit
+
+ //return (RByte & 0xffffff);// 24 bytes
+ return (RByte & 0xffff);//14 bit position + 2 bit general status
}
uint32_t Control_Read_Dancer_Position(uint32_t DancerId, uint32_t Parameter1, uint32_t Parameter2)
{
@@ -170,11 +198,14 @@ uint32_t Read_Dancer_Position (int DancerId)
ENC_SSI_Data = Write_Dummy_Byte();
- SSI_enc.Det_status = ENC_SSI_Data & 0xFF;
- ENC_SSI_Data = ENC_SSI_Data >> 8;
+
+ //SSI_enc.Det_status = ENC_SSI_Data & 0xFF;
+ //ENC_SSI_Data = ENC_SSI_Data >> 8;
+ SSI_enc.Det_status = 0;
+
SSI_enc.Gen_status = ENC_SSI_Data & 0x3;
ENC_SSI_Data = ENC_SSI_Data >> 2;
- SSI_enc.Position = ENC_SSI_Data & 0x3FFF;
+ SSI_enc.Position = ENC_SSI_Data & 0x3FFF; // up 11130 down 8747
SSIDisable(SSI1_BASE);
return SSI_enc.Position;
diff --git a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA.c b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA.c
index 968e55390..133bb9ed1 100644
--- a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA.c
+++ b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA.c
@@ -99,3 +99,19 @@ int FPGA_ReadVersion(unsigned char FPGA_NUM, unsigned char *Version, unsigned c
return PASSED;
}
+
+void Init_FPGA()
+{
+ //PreScale + PWM
+ //60MHz / PreScaler / (PWM High + PWM Low)
+ //for SPI Motor driver the maximum is 5MHz the default is the FPGA is 4 (60/2/(2+3)) = 4
+
+ //EPI Host-Bus 8 Configuration 3 (EPIHB8CFG3)
+ // Value Description
+ // 0x0 Active WRn is 2 EPI clocks
+ // 0x1 Active WRn is 4 EPI clocks <--
+ // 0x2 Active WRn is 6 EPI clocks
+ // 0x3 Active WRn is 8 EPI clocks
+
+}
+
diff --git a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_Comm.h b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_Comm.h
index 12c43dae6..8d83b74ed 100644
--- a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_Comm.h
+++ b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_Comm.h
@@ -841,36 +841,36 @@ typedef union
unsigned int uint;
}INT2SHORT;//16->32
-enum
-{
- RLOADING,
- RDRIVING,
- F1_LDRIVING,
- F1_LLOADING,
- F1_DRYER_LOADARM,
- F1_DRYER_DRIVING,
- F1_DH_CLEANHEAD,
- F1_DH_CLEANMECH,
- F1_SCREW,
- F1_WINDER,
- RLOADARM,
- RDANCER,
- LDANCER1,
- LDANCER2,
- DRYER_LID,
- DH_LID,
- LPIVOT1,
-}SPI_TYPE;
-
-//SPI
-typedef struct //S_SPI
-{
- unsigned char Type;
- unsigned int TX_MOSI; //32bit (Master Output Slave Input )
- unsigned int RX_MISO; //24bit (Master Input Slave Output)
- //unsigned int BUSY; //32bit
+//enum
+//{
+// RLOADING,
+// RDRIVING,
+// F1_LDRIVING,
+// F1_LLOADING,
+// F1_DRYER_LOADARM,
+// F1_DRYER_DRIVING,
+// F1_DH_CLEANHEAD,
+// F1_DH_CLEANMECH,
+// F1_SCREW,
+// F1_WINDER,
+// RLOADARM,
+// RDANCER,
+// LDANCER1,
+// LDANCER2,
+// DRYER_LID,
+// DH_LID,
+// LPIVOT1,
+//}SPI_TYPE;
-}SPI;//SPI
+////SPI
+//typedef struct //S_SPI
+//{
+// unsigned char Type;
+// unsigned int TX_MOSI; //32bit (Master Output Slave Input )
+// unsigned int RX_MISO; //24bit (Master Input Slave Output)
+// //unsigned int BUSY; //32bit
+//
+//}SPI;//SPI
/*
#define L6470_MOSI (*((volatile short *)(BASE | 0x0100)))
diff --git a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.c b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.c
index ede011df6..6ed020cf0 100644
--- a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.c
+++ b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.c
@@ -4,6 +4,22 @@
#include <drivers/FPGA/FPGA_Comm.h>
#include "Stubs_Handler/DataDef.h"
+#include "FPGA_SPI_Comm.h"
+#include "drivers/FPGA/Moters_Driver/L6470.h"
+#include "Drivers/Motors/Motor.h"
+
+////SPI
+//typedef struct //S_SPI
+//{
+// unsigned char Type;
+// unsigned int TX_MOSI; //32bit (Master Output Slave Input )
+// unsigned int RX_MISO; //24bit (Master Input Slave Output)
+// //unsigned int BUSY; //32bit
+//
+//}SPI;//SPI
+
+SPI spi;
+
uint8_t SPI_Transnit(SPI Spi)
{
@@ -14,9 +30,9 @@ uint8_t SPI_Transnit(SPI Spi)
Int2Short.uint = Spi.TX_MOSI;
- switch(Spi.Type)
+ switch(Spi.MotID)
{
- case RLOADING:
+ case MOTOR_RLOADING:
F1_MOTO_RLOADING_A1_TX_01 = Int2Short.ushort.MSB;
//Read the TX_01 register and make sure that the value was written properly.
while( Int2Short.ushort.MSB != F1_MOTO_RLOADING_A1_TX_01);
@@ -26,7 +42,7 @@ uint8_t SPI_Transnit(SPI Spi)
//Read the TX_00 register and make sure that the value was written properly.
while( Int2Short.ushort.LSB != F1_MOTO_RLOADING_A1_TX_00);
break;
- case RDRIVING:
+ case MOTOR_RDRIVING:
F1_MOTO_RDRIVING_A1_TX_01 = Int2Short.ushort.MSB;
//Read the TX_01 register and make sure that the value was written properly.
while( Int2Short.ushort.MSB != F1_MOTO_RDRIVING_A1_TX_01);
@@ -36,7 +52,7 @@ uint8_t SPI_Transnit(SPI Spi)
//Read the TX_00 register and make sure that the value was written properly.
while( Int2Short.ushort.LSB != F1_MOTO_RDRIVING_A1_TX_00);
break;
- case F1_LDRIVING:
+ case MOTOR_LDRIVING:
F1_MOTO_LDRIVING_A1_TX_01 = Int2Short.ushort.MSB;
//Read the TX_01 register and make sure that the value was written properly.
while( Int2Short.ushort.MSB != F1_MOTO_LDRIVING_A1_TX_01);
@@ -46,7 +62,7 @@ uint8_t SPI_Transnit(SPI Spi)
//Read the TX_00 register and make sure that the value was written properly.
while( Int2Short.ushort.LSB != F1_MOTO_LDRIVING_A1_TX_00);
break;
- case F1_LLOADING:
+ case MOTOR_LLOADING:
F1_MOTO_LLOADING_A1_TX_01 = Int2Short.ushort.MSB;
//Read the TX_01 register and make sure that the value was written properly.
while( Int2Short.ushort.MSB != F1_MOTO_LLOADING_A1_TX_01);
@@ -56,7 +72,7 @@ uint8_t SPI_Transnit(SPI Spi)
//Read the TX_00 register and make sure that the value was written properly.
while( Int2Short.ushort.LSB != F1_MOTO_LLOADING_A1_TX_00);
break;
- case F1_DRYER_LOADARM:
+ case MOTOR_DRYER_LOADARM:
F1_MOTO_DRYER_LOADARM_A1_TX_01 = Int2Short.ushort.MSB;
//Read the TX_01 register and make sure that the value was written properly.
while( Int2Short.ushort.MSB != F1_MOTO_DRYER_LOADARM_A1_TX_01);
@@ -66,7 +82,7 @@ uint8_t SPI_Transnit(SPI Spi)
//Read the TX_00 register and make sure that the value was written properly.
while( Int2Short.ushort.LSB != F1_MOTO_DRYER_LOADARM_A1_TX_00);
break;
- case F1_DRYER_DRIVING:
+ case MOTOR_DRYER_DRIVING:
F1_MOTO_DRYER_DRIVING_A1_TX_01 = Int2Short.ushort.MSB;
//Read the TX_01 register and make sure that the value was written properly.
while( Int2Short.ushort.MSB != F1_MOTO_DRYER_DRIVING_A1_TX_01);
@@ -76,7 +92,7 @@ uint8_t SPI_Transnit(SPI Spi)
//Read the TX_00 register and make sure that the value was written properly.
while( Int2Short.ushort.LSB != F1_MOTO_DRYER_DRIVING_A1_TX_00);
break;
- case F1_DH_CLEANHEAD:
+ case MOTOR_DH_CLEANHEAD:
F1_MOTO_DH_CLEANHEAD_A1_TX_01 = Int2Short.ushort.MSB;
//Read the TX_01 register and make sure that the value was written properly.
while( Int2Short.ushort.MSB != F1_MOTO_DH_CLEANHEAD_A1_TX_01);
@@ -86,7 +102,7 @@ uint8_t SPI_Transnit(SPI Spi)
//Read the TX_00 register and make sure that the value was written properly.
while( Int2Short.ushort.LSB != F1_MOTO_DH_CLEANHEAD_A1_TX_00);
break;
- case F1_DH_CLEANMECH:
+ case MOTOR_DH_CLEANMECH:
F1_MOTO_DH_CLEANMECH_A1_TX_01 = Int2Short.ushort.MSB;
//Read the TX_01 register and make sure that the value was written properly.
while( Int2Short.ushort.MSB != F1_MOTO_DH_CLEANMECH_A1_TX_01);
@@ -96,7 +112,7 @@ uint8_t SPI_Transnit(SPI Spi)
//Read the TX_00 register and make sure that the value was written properly.
while( Int2Short.ushort.LSB != F1_MOTO_DH_CLEANMECH_A1_TX_00);
break;
- case F1_SCREW:
+ case MOTOR_SCREW:
F1_MOTO_SCREW_A1_TX_01 = Int2Short.ushort.MSB;
//Read the TX_01 register and make sure that the value was written properly.
while( Int2Short.ushort.MSB != F1_MOTO_SCREW_A1_TX_01);
@@ -106,7 +122,7 @@ uint8_t SPI_Transnit(SPI Spi)
//Read the TX_00 register and make sure that the value was written properly.
while( Int2Short.ushort.LSB != F1_MOTO_SCREW_A1_TX_00);
break;
- case F1_WINDER:
+ case MOTOR_WINDER:
F1_MOTO_WINDER_A1_TX_01 = Int2Short.ushort.MSB;
//Read the TX_01 register and make sure that the value was written properly.
while( Int2Short.ushort.MSB != F1_MOTO_WINDER_A1_TX_01);
@@ -116,7 +132,7 @@ uint8_t SPI_Transnit(SPI Spi)
//Read the TX_00 register and make sure that the value was written properly.
while( Int2Short.ushort.LSB != F1_MOTO_WINDER_A1_TX_00);
break;
- case RLOADARM:
+ case MOTOR_RLOADARM:
F1_MOTO_RLOADARM_A1_TX_01 = Int2Short.ushort.MSB;
//Read the TX_01 register and make sure that the value was written properly.
while( Int2Short.ushort.MSB != F1_MOTO_RLOADARM_A1_TX_01);
@@ -126,7 +142,7 @@ uint8_t SPI_Transnit(SPI Spi)
//Read the TX_00 register and make sure that the value was written properly.
while( Int2Short.ushort.LSB != F1_MOTO_RLOADARM_A1_TX_00);
break;
- case RDANCER:
+ case MOTOR_RDANCER:
F1_MOTO_RDANCER_A1_TX_01 = Int2Short.ushort.MSB;
//Read the TX_01 register and make sure that the value was written properly.
while( Int2Short.ushort.MSB != F1_MOTO_RDANCER_A1_TX_01);
@@ -136,7 +152,7 @@ uint8_t SPI_Transnit(SPI Spi)
//Read the TX_00 register and make sure that the value was written properly.
while( Int2Short.ushort.LSB != F1_MOTO_RDANCER_A1_TX_00);
break;
- case LDANCER1:
+ case MOTOR_LDANCER1:
F1_MOTO_LDANCER1_A1_TX_01 = Int2Short.ushort.MSB;
//Read the TX_01 register and make sure that the value was written properly.
while( Int2Short.ushort.MSB != F1_MOTO_LDANCER1_A1_TX_01);
@@ -146,7 +162,7 @@ uint8_t SPI_Transnit(SPI Spi)
//Read the TX_00 register and make sure that the value was written properly.
while( Int2Short.ushort.LSB != F1_MOTO_LDANCER1_A1_TX_00);
break;
- case LDANCER2:
+ case MOTOR_LDANCER2:
F1_MOTO_LDANCER2_A1_TX_01 = Int2Short.ushort.MSB;
//Read the TX_01 register and make sure that the value was written properly.
while( Int2Short.ushort.MSB != F1_MOTO_LDANCER2_A1_TX_01);
@@ -156,7 +172,7 @@ uint8_t SPI_Transnit(SPI Spi)
//Read the TX_00 register and make sure that the value was written properly.
while( Int2Short.ushort.LSB != F1_MOTO_LDANCER2_A1_TX_00);
break;
- case DRYER_LID:
+ case MOTOR_DRYER_LID:
F1_MOTO_DRYER_LID_A1_TX_01 = Int2Short.ushort.MSB;
//Read the TX_01 register and make sure that the value was written properly.
while( Int2Short.ushort.MSB != F1_MOTO_DRYER_LID_A1_TX_01);
@@ -166,7 +182,7 @@ uint8_t SPI_Transnit(SPI Spi)
//Read the TX_00 register and make sure that the value was written properly.
while( Int2Short.ushort.LSB != F1_MOTO_DRYER_LID_A1_TX_00);
break;
- case DH_LID:
+ case MOTOR_DH_LID:
F1_MOTO_DH_LID_A1_TX_01 = Int2Short.ushort.MSB;
//Read the TX_01 register and make sure that the value was written properly.
while( Int2Short.ushort.MSB != F1_MOTO_DH_LID_A1_TX_01);
@@ -176,7 +192,7 @@ uint8_t SPI_Transnit(SPI Spi)
//Read the TX_00 register and make sure that the value was written properly.
while( Int2Short.ushort.LSB != F1_MOTO_DH_LID_A1_TX_00);
break;
- case LPIVOT1:
+ case MOTOR_LPIVOT1:
F1_MOTO_LPIVOT1_A1_TX_01 = Int2Short.ushort.MSB;
//Read the TX_01 register and make sure that the value was written properly.
while( Int2Short.ushort.MSB != F1_MOTO_LPIVOT1_A1_TX_01);
@@ -201,73 +217,73 @@ uint8_t SPI_Receive (SPI Spi)
//Check busy before trying to read RX registers.
while((F1_SPI_Busy1_D != NOTBUSY ) || (F1_SPI_Busy2_D != NOTBUSY ));
- switch(Spi.Type)
+ switch(Spi.MotID)
{
- case RLOADING:
+ case MOTOR_RLOADING:
Int2Short.ushort.LSB = F1_MOTO_RLOADING_A1_RX_00;
Int2Short.ushort.MSB = F1_MOTO_RLOADING_A1_RX_01;
break;
- case RDRIVING:
+ case MOTOR_RDRIVING:
Int2Short.ushort.LSB = F1_MOTO_RDRIVING_A1_RX_00;
Int2Short.ushort.MSB = F1_MOTO_RDRIVING_A1_RX_01;
break;
- case F1_LDRIVING:
+ case MOTOR_LDRIVING:
Int2Short.ushort.LSB = F1_MOTO_LDRIVING_A1_RX_00;
Int2Short.ushort.MSB = F1_MOTO_LDRIVING_A1_RX_01;
break;
- case F1_LLOADING:
+ case MOTOR_LLOADING:
Int2Short.ushort.LSB = F1_MOTO_LLOADING_A1_RX_00;
Int2Short.ushort.MSB = F1_MOTO_LLOADING_A1_RX_01;
break;
- case F1_DRYER_LOADARM:
+ case MOTOR_DRYER_LOADARM:
Int2Short.ushort.LSB = F1_MOTO_DRYER_LOADARM_A1_RX_00;
Int2Short.ushort.MSB = F1_MOTO_DRYER_LOADARM_A1_RX_01;
break;
- case F1_DRYER_DRIVING:
+ case MOTOR_DRYER_DRIVING:
Int2Short.ushort.LSB = F1_MOTO_DRYER_DRIVING_A1_RX_00;
Int2Short.ushort.MSB = F1_MOTO_DRYER_DRIVING_A1_RX_01;
break;
- case F1_DH_CLEANHEAD:
+ case MOTOR_DH_CLEANHEAD:
Int2Short.ushort.LSB = F1_MOTO_DH_CLEANHEAD_A1_RX_00;
Int2Short.ushort.MSB = F1_MOTO_DH_CLEANHEAD_A1_RX_01;
break;
- case F1_DH_CLEANMECH:
+ case MOTOR_DH_CLEANMECH:
Int2Short.ushort.LSB = F1_MOTO_DH_CLEANMECH_A1_RX_00;
Int2Short.ushort.MSB = F1_MOTO_DH_CLEANMECH_A1_RX_01;
break;
- case F1_SCREW:
+ case MOTOR_SCREW:
Int2Short.ushort.LSB = F1_MOTO_SCREW_A1_RX_00;
Int2Short.ushort.MSB = F1_MOTO_SCREW_A1_RX_01;
break;
- case F1_WINDER:
+ case MOTOR_WINDER:
Int2Short.ushort.LSB = F1_MOTO_WINDER_A1_RX_00;
Int2Short.ushort.MSB = F1_MOTO_WINDER_A1_RX_01;
break;
- case RLOADARM:
+ case MOTOR_RLOADARM:
Int2Short.ushort.LSB = F1_MOTO_RLOADARM_A1_RX_00;
Int2Short.ushort.MSB = F1_MOTO_RLOADARM_A1_RX_01;
break;
- case RDANCER:
+ case MOTOR_RDANCER:
Int2Short.ushort.LSB = F1_MOTO_RDANCER_A1_RX_00;
Int2Short.ushort.MSB = F1_MOTO_RDANCER_A1_RX_01;
break;
- case LDANCER1:
+ case MOTOR_LDANCER1:
Int2Short.ushort.LSB = F1_MOTO_LDANCER1_A1_RX_00;
Int2Short.ushort.MSB = F1_MOTO_LDANCER1_A1_RX_01;
break;
- case LDANCER2:
+ case MOTOR_LDANCER2:
Int2Short.ushort.LSB = F1_MOTO_LDANCER2_A1_RX_00;
Int2Short.ushort.MSB = F1_MOTO_LDANCER2_A1_RX_01;
break;
- case DRYER_LID:
+ case MOTOR_DRYER_LID:
Int2Short.ushort.LSB = F1_MOTO_DRYER_LID_A1_RX_00;
Int2Short.ushort.MSB = F1_MOTO_DRYER_LID_A1_RX_01;
break;
- case DH_LID:
+ case MOTOR_DH_LID:
Int2Short.ushort.LSB = F1_MOTO_DH_LID_A1_RX_00;
Int2Short.ushort.MSB = F1_MOTO_DH_LID_A1_RX_01;
break;
- case LPIVOT1:
+ case MOTOR_LPIVOT1:
Int2Short.ushort.LSB = F1_MOTO_LPIVOT1_A1_RX_00;
Int2Short.ushort.MSB = F1_MOTO_LPIVOT1_A1_RX_01;
break;
@@ -279,3 +295,17 @@ uint8_t SPI_Receive (SPI Spi)
return 0;
}
+
+void FPGA_GetClrMotStat(SPI MotFPGA_Spi)
+{
+ MotFPGA_Spi.TX_MOSI = x_GET_STATUS;
+ SPI_Transnit(MotFPGA_Spi);
+ SPI_Receive(MotFPGA_Spi);
+}
+
+void FPGA_GetMotSpeed(SPI MotFPGA_Spi)
+{
+ MotFPGA_Spi.TX_MOSI = x_GET_PARAM | x_SPEED;
+ SPI_Transnit(MotFPGA_Spi);
+ SPI_Receive(MotFPGA_Spi);
+}
diff --git a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.h b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.h
new file mode 100644
index 000000000..cd834748b
--- /dev/null
+++ b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.h
@@ -0,0 +1,6 @@
+//#include "FPGA_comm.h"
+
+uint8_t SPI_Transnit(SPI spi);
+uint8_t SPI_Receive (SPI spi);
+void FPGA_GetClrMotStat(SPI MotFPGA_Spi);
+void FPGA_GetMotSpeed(SPI MotFPGA_Spi);
diff --git a/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.c b/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.c
index b1c24da68..2db2247ad 100644
--- a/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.c
+++ b/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.c
@@ -19,6 +19,31 @@
#include <stdint.h>
#include <stdbool.h>
+
+#include "drivers/SPI/SPI_Comm.h"
+#include "drivers/FPGA/FPGA_SPI_Comm.h"
+#include "drivers/FPGA/FPGA_Comm.h"
+#include "Stubs_Handler/DataDef.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 ;
+extern unsigned char Stop_Command;
+
+uint32_t Global_Speed;
+
+uint32_t Global_Read_MicroSteps;
+///////////////////////////
+
+
+SPI MotFPGA_Spi;
+
+MotorDriverResponseStruct MotorDriverResponse[NUM_OF_MOTORS];
+
MotorDriverConfigStruc MotorDriverCfg[NUM_OF_MOTORS];
TimerMotors_t FastMotorToMotorId[4] = {MOTOR_RDRIVING,MOTOR_DRYER_DRIVING,MOTOR_LDRIVING,MOTOR_WINDER};
callback_fptr MotorMoveModuleCallback = 0;
@@ -28,11 +53,36 @@ uint32_t MotorMoveCallBackFunction(uint32_t deviceId, uint32_t BusyFlag);
//initialize general motors driver database
uint32_t MotorsInit(void)
{
+ //MOTOR Driver L6470 SPI
+ SPI2_Init();
+ init_BUSY_Pin();
+
+ StubMotorInitRequest *MotConfigRequest;
+
+ memset(MotConfigRequest,0,sizeof(MotConfigRequest));
+
+ setup(MotConfigRequest);
+
return OK;
}
//set the motor configuration
-uint32_t MotorConfig(TimerMotors_t _motorId, HardwareMotor *MotorConfig)
+uint32_t MotorConfig(TimerMotors_t _motorId, HardwareMotor *MotorConfig)//?
{
+
+ StubMotorInitRequest* MotConfigRequest;
+
+ memset(MotConfigRequest,0,sizeof(MotConfigRequest));
+
+ MotConfigRequest->set_max_speed = MotorConfig->has_maxfrequency;
+
+ MotConfigRequest->max_speed = MotorConfig-> maxfrequency;
+
+ MotConfigRequest->set_micro_steps = MotorConfig->has_minmicrostep;
+
+ MotConfigRequest->micro_steps = MotorConfig->minmicrostep;
+
+ setup(MotConfigRequest);
+
return OK;
}
@@ -44,16 +94,27 @@ TimerMotors_t getMotorId(int FastMotorId)
uint32_t MotorGetDirection(TimerMotors_t _motorId)
{
- return OK;
+
+ uint32_t read_status = Get_and_Clear_Status();
+
+ return ((read_status & x_STATUS_DIR)>>4);
}
uint32_t MotorSetDirection(TimerMotors_t _motorId,bool _direction)
{
- return OK;
+ Direction = _direction;
+
+ Mot_Run();
+
+ return OK;
}
uint32_t MotorSetSpeed(TimerMotors_t _motorId, uint32_t _freq, int MicroSteps)
{
+
+ Run_Value = SpdCalc(_freq);
+ Mot_Run();
+
return OK;
}
@@ -69,30 +130,48 @@ uint32_t MotorGetPositionFromFPGA(TimerMotors_t _motorId)
uint32_t MotorGetSpeedFromFPGA(TimerMotors_t _motorId)
{
- return OK;
+// MotFPGA_Spi.MotID = _motorId;
+// FPGA_GetMotSpeed(MotFPGA_Spi);
+// MotorDriverResponse[_motorId].Speed = (float)(CurrentSpdCalc(MotFPGA_Spi.RX_MISO));
+// return MotorDriverResponse[_motorId].Speed;
+ Global_Speed = (uint32_t)(CurrentSpdCalc(Get_Param(x_SPEED)));
+
+ return Global_Speed;
}
uint32_t MotorGetStatusFromFPGA(TimerMotors_t _motorId)
{
- return OK;
+
+// MotFPGA_Spi.MotID = _motorId;
+//
+// FPGA_GetClrMotStat(MotFPGA_Spi);
+//
+// MotorDriverResponse[_motorId].Status = MotFPGA_Spi.RX_MISO; //Get_and_Clear_Status();
+//
+// return MotorDriverResponse[_motorId].Status;
+
+ return Get_and_Clear_Status();
}
uint32_t MotorGetMicroSteps(TimerMotors_t _motorId)
{
- return OK;
+ return Global_Read_MicroSteps;
}
uint32_t MotorGetMicroStepsFromFPGA(TimerMotors_t _motorId)
{
- return OK;
+ Global_Read_MicroSteps = (Get_Param(x_STEP_MODE)) & 0x03;
+ return Global_Read_MicroSteps;
}
uint32_t MotorGetnBusyFromFPGA(void) // get all motors nBusy bit status from the FPGAs
{
- return OK;
+
+
+ return (uint32_t)(Check_SPI_Busy() || SSIBusy(SSI2_BASE));
}
bool MotorGetnBusyState(TimerMotors_t _motorId)
{
- return true;
+ return (uint32_t)(Check_SPI_Busy() || SSIBusy(SSI2_BASE));///
}
bool MotorControlGetnBusyState(uint32_t _motorId, uint32_t parameter)
@@ -106,11 +185,15 @@ bool MotorControlGetnBusyState(uint32_t _motorId, uint32_t parameter)
*/
uint32_t StopMotor(TimerMotors_t _motorId, STOP_TYPE_ENUM StopType)
{
+ Stop_Command = StopType;
+ Mot_Stop();
return OK;
}
uint32_t MotorMove(TimerMotors_t _motorId,bool direction, uint32_t Steps)
{
+ Move(direction,Steps );
+
return OK;
}
@@ -121,7 +204,7 @@ uint32_t MotorMoveWithCallback (TimerMotors_t _motorId,bool direction, uint32_t
//call driver action to device id with the parameter
//SetMotorSpeed (deviceId, parameter);
- MotorMove(_motorId,direction,Steps);
+ Move(direction,Steps );
MotorMoveModuleCallback = callback;
//start control:
//uint32_t AddControlCallback( ControlCBFunction Callback, CTRL_TIMING_ENUM CtrlFrequency, DataReadCBFunction DriverfPtr, uint32_t Parameter1, uint32_t Parameter2 )
@@ -132,6 +215,9 @@ uint32_t MotorMoveWithCallback (TimerMotors_t _motorId,bool direction, uint32_t
uint32_t MotorSetSpeedWithCallback (TimerMotors_t _motorId, uint32_t _freq, int MicroSteps, callback_fptr callback)
{
+ Run_Value = SpdCalc(_freq);
+
+ Mot_Run();
return OK;
}
diff --git a/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.h b/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.h
index d06c9d4db..3f7502646 100644
--- a/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.h
+++ b/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.h
@@ -78,18 +78,51 @@ typedef enum
NUM_OF_MOTORS
} TimerMotors_t;
+//typedef enum
+//{
+// SetSpeed,
+// SetPosition,
+// SetHardStop,
+// SetSoftStop,
+// SetHardStopHiz,
+// SetSoftStopHiz,
+// GetSpeed,
+// GetPosition,
+// GetStatus,
+//
+//}MotorCommand_t;
+
+//typedef struct
+//{
+// TimerMotors_t id;
+// uint32_t minfreq;
+// uint32_t maxfreq;
+// uint32_t minmicrostep;
+// uint32_t maxmicrostep;
+// double changeslope;
+// double hightimeoutusec;
+//}MotorDriverConfigStruc;
+
typedef struct
{
- TimerMotors_t id;
- uint32_t minfreq;
- uint32_t maxfreq;
- uint32_t minmicrostep;
- uint32_t maxmicrostep;
- double changeslope;
- double hightimeoutusec;
+ uint32_t ACC; //set
+ uint32_t DEC; //set
+ uint32_t MaxSpeed; //set
+ uint32_t Microstep; //set
+ bool SetGet ; //0 Set /1 Get
+ uint32_t Mode; // Run(Speed)/Mov(Position)/Stop(set only)/Status/(Get only)
+ uint32_t Value; // value
+ bool Direction_Req; //Direction
}MotorDriverConfigStruc;
+typedef struct
+{
+ uint32_t Status;
+ float Speed;
+
+}MotorDriverResponseStruct;
+extern MotorDriverResponseStruct MotorDriverResponse[NUM_OF_MOTORS];
extern MotorDriverConfigStruc MotorDriverCfg[NUM_OF_MOTORS];
diff --git a/Software/Embedded_SW/Embedded/Drivers/SPI/SPI_Comm.c b/Software/Embedded_SW/Embedded/Drivers/SPI/SPI_Comm.c
index 17f2f549b..647a3cf62 100644
--- a/Software/Embedded_SW/Embedded/Drivers/SPI/SPI_Comm.c
+++ b/Software/Embedded_SW/Embedded/Drivers/SPI/SPI_Comm.c
@@ -392,7 +392,7 @@ void setup(StubMotorInitRequest* request)
{
SetParam(x_STEP_MODE,
!x_SYNC_EN |
- x_STEP_SEL_1_8 |
+ x_STEP_SEL_1 |
x_SYNC_SEL_1);
}
@@ -413,7 +413,7 @@ void setup(StubMotorInitRequest* request)
}
else
{
- SetParam(x_MAX_SPEED, MaxSpdCalc(1120));
+ SetParam(x_MAX_SPEED, MaxSpdCalc(2500));
}
@@ -526,14 +526,14 @@ void setup(StubMotorInitRequest* request)
// There are ACC, DEC, and HOLD KVAL registers as well; you may
// need to play with those values to get acceptable performance
// for a given application.
- SetParam(x_KVAL_HOLD, /*0x0B);// */ 0x05);
- SetParam(x_KVAL_RUN, /*0x4B);// */ 0x23);
- SetParam(x_KVAL_ACC, /*0x4B);// */ 0x23);
- SetParam(x_KVAL_DEC, /*0x4B);// */ 0x23);
- SetParam(x_ST_SLP, 0x18);
- SetParam(x_INT_SPD, /*0x1A13);// */ 0x3550);
- SetParam(x_FN_SLP_ACC, /*0x48);// */ 0x23);
- SetParam(x_FN_SLP_DEC, /*0x48);// */ 0x23);
+ SetParam(x_KVAL_HOLD, /*0x0B);// */ 0x35);
+ SetParam(x_KVAL_RUN, /*0x4B);// */ 0x4B);
+ SetParam(x_KVAL_ACC, /*0x4B);// */ 0x4B);
+ SetParam(x_KVAL_DEC, /*0x4B);// */ 0x4B);
+ SetParam(x_ST_SLP, /*0x18);/ */ 0x20);
+ SetParam(x_INT_SPD, /*0x1A13);// */ 0x1A13);
+ SetParam(x_FN_SLP_ACC, /*0x48);// */ 0x50);
+ SetParam(x_FN_SLP_DEC, /*0x48);// */ 0x50);
//https://www.youtube.com/watch?v=8C7qdjPbhlg MIN 2:20
diff --git a/Software/Embedded_SW/Embedded/Drivers/SPI/SPI_Comm.h b/Software/Embedded_SW/Embedded/Drivers/SPI/SPI_Comm.h
index 5b57e44ee..7ec463f68 100644
--- a/Software/Embedded_SW/Embedded/Drivers/SPI/SPI_Comm.h
+++ b/Software/Embedded_SW/Embedded/Drivers/SPI/SPI_Comm.h
@@ -15,4 +15,4 @@ void init_BUSY_Pin(void);
#include <PMR/Stubs/StubMotorInitRequest.pb-c.h>
void setup(StubMotorInitRequest* request);
bool Check_SPI_Busy(void);
-
+byte Write_Byte(uint8_t WByte);
diff --git a/Software/Embedded_SW/Embedded/Drivers/USB_Communication/USBCDCD - Copy.new b/Software/Embedded_SW/Embedded/Drivers/USB_Communication/USBCDCD - Copy.new
deleted file mode 100644
index f8b333c8a..000000000
--- a/Software/Embedded_SW/Embedded/Drivers/USB_Communication/USBCDCD - Copy.new
+++ /dev/null
@@ -1,1063 +0,0 @@
-
-/************************************************************************************
- * this module is represents the access layer to USB STACK DRIVER
- * used to communication over USB protocol
- * the USB protocol implementation is inside the module no need for another includes
- * ======== USBCDCD.c ========
- ************************************************************************************/
-
-/* XDCtools Header files */
-#include <xdc/std.h>
-#include <xdc/runtime/Error.h>
-#include <xdc/runtime/System.h>
-
-/* BIOS Header files */
-#include <ti/sysbios/BIOS.h>
-#include <ti/sysbios/gates/GateMutex.h>
-#include <ti/sysbios/hal/Hwi.h>
-#include <ti/sysbios/knl/Semaphore.h>
-#include <ti/sysbios/knl/Task.h>
-
-#include <stdbool.h>
-#include <stdint.h>
-
-/* driverlib Header files */
-#include <inc/hw_ints.h>
-#include <inc/hw_types.h>
-
-#include <driverlib/rom.h>
-#include <driverlib/sysctl.h>
-#include <driverlib/usb.h>
-#include <inc/hw_memmap.h>
-
-/* usblib Header files */
-#include <usblib/usb-ids.h>
-#include <usblib/usblib.h>
-#include <usblib/usbcdc.h>
-#include <usblib/device/usbdevice.h>
-#include <usblib/device/usbdcdc.h>
-#include <usblib/device/usbddfu-rt.h>
-#include <usblib/device/usbdcomp.h>
-#include "Drivers/USB_Communication/USBCDCD.h"
-
-//#include "Common/Sys_Configuration/Configuration.h"
-//#include "Communication/Communication.h"
-
-#include <utils/ustdlib.h>
-#include "Common/Utilities/Utils.h"
-//#include "Communication/HostMessaging.h"
-
-#if defined(TIVAWARE)
-typedef uint32_t USBCDCDEventType;
-#else
-#define eUSBModeForceDevice USB_MODE_FORCE_DEVICE
-typedef unsigned long USBCDCDEventType;
-#endif
-
-/* Defines */
-#define USBBUFFERSIZE 256
-//****************************************************************************
-//
-// A buffer into which the composite device can write the combined config
-// descriptor.
-//
-//****************************************************************************
-#define DESCRIPTOR_BUFFER_SIZE (COMPOSITE_DDFU_SIZE + COMPOSITE_DCDC_SIZE)
-
-extern Semaphore_Handle updateSem;
-extern Semaphore_Handle ReconnectSem;
-
-uint8_t g_pui8DescriptorBuffer[DESCRIPTOR_BUFFER_SIZE];
-
-/* Typedefs */
-typedef volatile enum {
- USBCDCD_STATE_IDLE = 0,
- USBCDCD_STATE_INIT,
- USBCDCD_STATE_UNCONFIGURED
-} USBCDCD_USBState;
-
-/* Static variables and handles */
-static volatile USBCDCD_USBState state;
-static unsigned char receiveBuffer[USBBUFFERSIZE];
-static unsigned char transmitBuffer[USBBUFFERSIZE];
-
-static GateMutex_Handle gateTxSerial;
-static GateMutex_Handle gateRxSerial;
-static GateMutex_Handle gateUSBWait;
-static Semaphore_Handle semTxSerial;
-static Semaphore_Handle semRxSerial;
-static Semaphore_Handle semUSBConnected;
-extern Semaphore_Handle initConnectionSem;
-
-/* Function prototypes */
-static USBCDCDEventType cbRxHandler(void *cbData, USBCDCDEventType event,
- USBCDCDEventType _eventMsgData,
- void *eventMsgPtr);
-static USBCDCDEventType cbSerialHandler(void *cbData, USBCDCDEventType event,
- USBCDCDEventType _eventMsgData,
- void *eventMsgPtr);
-static USBCDCDEventType cbTxHandler(void *cbData, USBCDCDEventType event,
- USBCDCDEventType _eventMsgData,
- void *eventMsgPtr);
-void USBCDCD_hwiHandler(UArg arg0);
-static unsigned int rxData(unsigned char *_pBuff,
- unsigned int _length,
- unsigned int _timeout);
-static unsigned int txData(const unsigned char *_pBuff,
- int _length, unsigned int _timeout);
-void USBCDCD_init(void);
-
-unsigned int USBCDCD_receiveData(unsigned char *_pBuff,
- unsigned int _length,
- unsigned int _timeout);
-unsigned int USBCDCD_sendData(const unsigned char *_pBuff,
- unsigned int _length,
- unsigned int _timeout);
-bool USBCDCD_waitForConnect(unsigned int _timeout);
-
-uint32_t DFUDetachCallback(void *pvCBData, uint32_t ui32Event,
- uint32_t ui32MsgData, void *pvMsgData);
-
-/* The languages supported by this device. */
-const unsigned char langDescriptor[] = {
- 4,
- USB_DTYPE_STRING,
- USBShort(USB_LANG_EN_US)
-};
-
-/* The manufacturer string. */
-const unsigned char manufacturerString[] = {
- (17 + 1) * 2,
- USB_DTYPE_STRING,
- 'T', 0, 'e', 0, 'x', 0, 'a', 0, 's', 0, ' ', 0, 'I', 0, 'n', 0, 's', 0,
- 't', 0, 'r', 0, 'u', 0, 'm', 0, 'e', 0, 'n', 0, 't', 0, 's', 0,
-};
-
-/* The product string. */
-const unsigned char productString[] = {
- 2 + (13 * 2),
- USB_DTYPE_STRING,
- 'T', 0, 'w', 0, 'i', 0, 'n', 0, 'e', 0, ' ', 0, 'J', 0, 'i', 0,
- 'g', 0, ' ', 0, 'U', 0, 'S', 0, 'B', 0,
-};
-
-/* The serial number string. */
-const unsigned char serialNumberString[] = {
- (8 + 1) * 2,
- USB_DTYPE_STRING,
- '1', 0, '2', 0, '3', 0, '4', 0, '5', 0, '6', 0, '7', 0, '8', 0
-};
-
-/* The interface description string. */
-const unsigned char controlInterfaceString[] = {
- 2 + (21 * 2),
- USB_DTYPE_STRING,
- 'J', 0, 'i', 0, 'g', 0, ' ', 0, 'C', 0, 'o', 0, 'n', 0, 't', 0,
- 'r', 0, 'o', 0, 'l', 0, ' ', 0, 'I', 0, 'n', 0, 't', 0, 'e', 0,
- 'r', 0, 'f', 0, 'a', 0, 'c', 0, 'e', 0
-};
-
-/* The configuration description string. */
-const unsigned char configString[] = {
- 2 + (26 * 2),
- USB_DTYPE_STRING,
- 'S', 0, 'e', 0, 'l', 0, 'f', 0, ' ', 0, 'P', 0, 'o', 0, 'w', 0,
- 'e', 0, 'r', 0, 'e', 0, 'd', 0, ' ', 0, 'C', 0, 'o', 0, 'n', 0,
- 'f', 0, 'i', 0, 'g', 0, 'u', 0, 'r', 0, 'a', 0, 't', 0, 'i', 0,
- 'o', 0, 'n', 0
-};
-
-//*****************************************************************************
-//
-// The descriptor string table.
-//
-//*****************************************************************************
-const uint8_t * const g_ppui8StringDescriptors[] =
-{
- langDescriptor,
- manufacturerString,
- productString,
- serialNumberString,
- controlInterfaceString,
- configString
-};
-
-#define NUM_STRING_DESCRIPTORS (sizeof(g_ppui8StringDescriptors) / \
- sizeof(g_ppui8StringDescriptors[0]))
-
-/* The descriptor string table. */
-const unsigned char * const stringDescriptors[] = {
- langDescriptor,
- manufacturerString,
- productString,
- serialNumberString,
- controlInterfaceString,
- configString
-};
-
-#define STRINGDESCRIPTORSCOUNT (sizeof(stringDescriptors) / \
- sizeof(unsigned char *))
-
-#if defined(TIVAWARE)
-tUSBBuffer txBuffer;
-tUSBBuffer rxBuffer;
-static tUSBDCDCDevice g_sCDCDevice;
-
-tUSBBuffer rxBuffer =
-{
- false, /* This is a receive buffer. */
- cbRxHandler, /* pfnCallback */
- (void *)&g_sCDCDevice, /* Callback data is our device pointer. */
- USBDCDCPacketRead, /* pfnTransfer */
- USBDCDCRxPacketAvailable, /* pfnAvailable */
- (void *)&g_sCDCDevice, /* pvHandle */
- receiveBuffer, /* pcBuffer */
- USBBUFFERSIZE, /* ulBufferSize */
- {{0, 0, 0, 0}, 0, 0} /* private data workspace */
-};
-
-tUSBBuffer txBuffer =
-{
- true, /* This is a transmit buffer. */
- cbTxHandler, /* pfnCallback */
- (void *)&g_sCDCDevice, /* Callback data is our device pointer. */
- USBDCDCPacketWrite, /* pfnTransfer */
- USBDCDCTxPacketAvailable, /* pfnAvailable */
- (void *)&g_sCDCDevice, /* pvHandle */
- transmitBuffer, /* pcBuffer */
- USBBUFFERSIZE, /* ulBufferSize */
- {{0, 0, 0, 0}, 0, 0} /* private data workspace */
-};
-
-static tUSBDCDCDevice g_sCDCDevice =
-{
- USB_VID_TI_1CBE,
- USB_PID_SERIAL,
- 0,
- USB_CONF_ATTR_SELF_PWR,
-
- cbSerialHandler,
- (void *)&g_sCDCDevice,
-
- USBBufferEventCallback,
- (void *)&rxBuffer,
-
- USBBufferEventCallback,
- (void *)&txBuffer,
-
- stringDescriptors,
- STRINGDESCRIPTORSCOUNT
-};
-
-//*****************************************************************************
-//
-// The DFU runtime interface initialization and customization structures
-//
-//*****************************************************************************
-tUSBDDFUDevice g_sDFUDevice =
-{
- DFUDetachCallback,
- (void *)&g_sDFUDevice
-};
-
-//****************************************************************************
-//
-// The number of device class instances that this composite device will
-// use.
-//
-//****************************************************************************
-#define NUM_DEVICES 2
-
-//****************************************************************************
-//
-// The array of devices supported by this composite device.
-//
-//****************************************************************************
-tCompositeEntry g_psCompDevices[NUM_DEVICES];
-
-//****************************************************************************
-//
-// Additional workspace required by the composite driver to hold a lookup
-// table allowing mapping of composite interface and endpoint numbers to
-// individual device class instances.
-//
-//****************************************************************************
-uint32_t g_pui32CompWorkspace[NUM_DEVICES];
-
-//****************************************************************************
-//
-// The instance data for this composite device.
-//
-//****************************************************************************
-tCompositeInstance g_sCompInstance;
-
-//****************************************************************************
-//
-// Allocate the Device Data for the top level composite device class.
-//
-//****************************************************************************
-tUSBDCompositeDevice g_sCompDevice =
-{
- //
- // Stellaris VID.
- //
- USB_VID_TI_1CBE,
-
- //
- // Stellaris PID for composite SERIAL/DFU device.
- //
- USB_PID_COMP_SERIAL,
-
- //
- // This is in milliamps.
- //
- 250,
-
- //
- // Bus powered device.
- //
- USB_CONF_ATTR_BUS_PWR,
-
- //
- // Device event handler function pointer (receives connect, disconnect
- // and other device-level notifications).
- //
- cbSerialHandler,
-
- //
- // The string table.
- //
- g_ppui8StringDescriptors,
- NUM_STRING_DESCRIPTORS,
-
- //
- // The Composite device array.
- //
- NUM_DEVICES,
- g_psCompDevices,
-};
-
-#else
-#define USB_BUFFER_WORKSPACE_SIZE 1200
-const tUSBBuffer rxBuffer;
-const tUSBBuffer txBuffer;
-static unsigned char receiveBufferWorkspace[USB_BUFFER_WORKSPACE_SIZE];
-static unsigned char transmitBufferWorkspace[USB_BUFFER_WORKSPACE_SIZE];
-
-static tCDCSerInstance serialInstance;
-const tUSBDCDCDevice g_sCDCDevice;
-
-const tUSBBuffer rxBuffer = {
- false, /* This is a receive buffer. */
- cbRxHandler, /* pfnCallback */
- (void *)&g_sCDCDevice, /* Callback data is our device pointer. */
- USBDCDCPacketRead, /* pfnTransfer */
- USBDCDCRxPacketAvailable, /* pfnAvailable */
- (void *)&g_sCDCDevice, /* pvHandle */
- receiveBuffer, /* pcBuffer */
- USBBUFFERSIZE, /* ulBufferSize */
- receiveBufferWorkspace /* pvWorkspace */
-};
-
-const tUSBBuffer txBuffer = {
- true, /* This is a transmit buffer. */
- cbTxHandler, /* pfnCallback */
- (void *)&g_sCDCDevice, /* Callback data is our device pointer. */
- USBDCDCPacketWrite, /* pfnTransfer */
- USBDCDCTxPacketAvailable, /* pfnAvailable */
- (void *)&g_sCDCDevice, /* pvHandle */
- transmitBuffer, /* pcBuffer */
- USBBUFFERSIZE, /* ulBufferSize */
- transmitBufferWorkspace /* pvWorkspace */
-};
-
-const tUSBDCDCDevice g_sCDCDevice = {
- USB_VID_TI_1CBE,
- USB_PID_SERIAL,
- 0,
- USB_CONF_ATTR_SELF_PWR,
-
- cbSerialHandler,
- NULL,
-
- USBBufferEventCallback,
- (void *)&rxBuffer,
-
- USBBufferEventCallback,
- (void *)&txBuffer,
-
- stringDescriptors,
- STRINGDESCRIPTORSCOUNT,
-
- &serialInstance /* Old usblib stores a pointer */
-};
-#endif
-
-static tLineCoding g_sLineCoding = {
- 115200, /* 115200 baud rate. */
- 1, /* 1 Stop Bit. */
- 0, /* No Parity. */
- 8 /* 8 Bits of data. */
-};
-
-int cpt[20] = {0};
-//*****************************************************************************
-//
-//! Waits for a character from the USB port.
-//!
-//! This function gets a character from the USB receive buffer.
-//! If there are no characters available, this function waits until a
-//! character is received before returning.
-//!
-//! \return Returns the character read from the USB port.
-//
-//*****************************************************************************
-char USBGetChar(void)
-{
- uint8_t ucChar;
- int len = 0;
- //int leng;
-// char str[60];
-
- len = USBCDCD_receiveData(&ucChar, 1, BIOS_WAIT_FOREVER);
- if (len !=1)
- {
-// leng = usnprintf(str, 60, "\r\n USBGetChar len error %d",len );
-// cb_push_back (str, leng);
- Task_sleep(1);
- len = USBCDCD_receiveData(&ucChar, 1, BIOS_WAIT_FOREVER);
-// leng = usnprintf(str, 60, "\r\n USBGetChar len second %d",len );
-// cb_push_back (str, leng);
- }
- //
- // Now return the char.
- //
- return (ucChar);
-}
-
-unsigned int USBSendData(const unsigned char *_pBuff,unsigned int _length)
-{
- //StoreUSBByte ((uint8_t *)_pBuff,_length,false);
- return USBCDCD_sendData(_pBuff,_length,10/*BIOS_WAIT_FOREVER*/);
-}
-
-void USBFlush(void)
-{
- USBBufferFlush(&rxBuffer);
-}
-
-/******************************************************************************
- * ======== cbRxHandler ========
- * Callback handler for the USB stack.
- *
- * Callback handler call by the USB stack to notify us on what has happened in
- * regards to the keyboard.
- *
- * @param(_pcbData) A callback pointer provided by the client.
- *
- * @param(_event) Identifies the event that occurred in regards to
- * this device.
- *
- * @param(_eventMsgData) A data value associated with a particular event.
- *
- * @param(_pEventMsgPtr) A data pointer associated with a particular event.
- *
- ******************************************************************************/
-static USBCDCDEventType cbRxHandler(void *_pcbData, USBCDCDEventType _event,
- USBCDCDEventType _eventMsgData,
- void *_pEventMsgPtr)
-{
- cpt[0]++;
- switch (_event)
- {
- case USB_EVENT_RX_AVAILABLE:
- {
- cpt[1]++;
- Semaphore_post(semRxSerial);
- break;
- }
- case USB_EVENT_DATA_REMAINING:
- break;
-
- case USB_EVENT_REQUEST_BUFFER:
- break;
-
- default:
- break;
- }
-
- return (0);
-}
-//*****************************************************************************
-//
-// This is the callback from the USB DFU runtime interface driver.
-//
-// \param pvCBData is ignored by this function.
-// \param ui32Event is one of the valid events for a DFU device.
-// \param ui32MsgParam is defined by the event that occurs.
-// \param pvMsgData is a pointer to data that is defined by the event that
-// occurs.
-//
-// This function will be called to inform the application when a change occurs
-// during operation as a DFU device. Currently, the only event passed to this
-// callback is USBD_DFU_EVENT_DETACH which tells the recipient that they should
-// pass control to the boot loader at the earliest, non-interrupt context
-// point.
-//
-// \return This function will return 0.
-//
-//*****************************************************************************
-uint32_t
-DFUDetachCallback(void *pvCBData, uint32_t ui32Event, uint32_t ui32MsgData,
- void *pvMsgData)
-{
- if(ui32Event == USBD_DFU_EVENT_DETACH)
- {
- //
- // Set the flag that the main loop uses to determine when it is time
- // to transfer control back to the boot loader. Note that we
- // absolutely DO NOT call USBDDFUUpdateBegin() here since we are
- // currently in interrupt context and this would cause bad things to
- // happen (and the boot loader to not work).
- //
- //
- // Release updateSem
- //
- Semaphore_post(updateSem);
- }
-
- return (0);
-}
-
-/******************************************************************************
- * ======== cbSerialHandler ========
- * Callback handler for the USB stack.
- *
- * Callback handler call by the USB stack to notify us on what has happened in
- * regards to the keyboard.
- *
- * @param(_pcbData) A callback pointer provided by the client.
- *
- * @param(_event) Identifies the event that occurred in regards to
- * this device.
- *
- * @param(_eventMsgData) A data value associated with a particular event.
- *
- * @param(_pEventMsgPtr) A data pointer associated with a particular event.
- *
- *****************************************************************************/
-static USBCDCDEventType cbSerialHandler(void *_pcbData, USBCDCDEventType _event,
- USBCDCDEventType _eventMsgData,
- void *_pEventMsgPtr)
-{
- tLineCoding *psLineCoding;
- static bool initiated = false;
- cpt[2]++;
-
- /* Determine what event has happened */
- switch (_event)
- {
- case USB_EVENT_CONNECTED:
- {
- cpt[3]++;
- if(state == USBCDCD_STATE_UNCONFIGURED)
- {
- state = USBCDCD_STATE_INIT;
- //SetCommunication(USBGetChar, USBSendData,USBFlush);
- Semaphore_post(semUSBConnected);
- Semaphore_post(initConnectionSem);
- Semaphore_post(semTxSerial);
- initiated = true;
- }
- break;
- }
- case USB_EVENT_DISCONNECTED:
- {
- state = USBCDCD_STATE_UNCONFIGURED;
- break;
- }
- case USBD_CDC_EVENT_GET_LINE_CODING:
- {
- cpt[7]++;
- /* Create a pointer to the line coding information. */
- psLineCoding = (tLineCoding *)_pEventMsgPtr;
-
- /* Copy the current line coding information into the structure. */
- *(psLineCoding) = g_sLineCoding;
- break;
- }
- case USBD_CDC_EVENT_SET_LINE_CODING:
- {
- cpt[6]++;
- /* Create a pointer to the line coding information. */
- psLineCoding = (tLineCoding *)_pEventMsgPtr;
-
- /*
- * Copy the line coding information into the current line coding
- * structure.
- */
- g_sLineCoding = *(psLineCoding);
- break;
- }
- case USBD_CDC_EVENT_SET_CONTROL_LINE_STATE:
- break;
-
- case USBD_CDC_EVENT_SEND_BREAK:
- break;
-
- case USBD_CDC_EVENT_CLEAR_BREAK:
- break;
-
- case USB_EVENT_SUSPEND:
- cpt[4]++;
- if (state != USBCDCD_STATE_UNCONFIGURED)
- {
- state = USBCDCD_STATE_UNCONFIGURED;
- if (initiated == true)
- {
- Semaphore_post(ReconnectSem);
- //Semaphore_post(semTxSerial);
- }
- }
- break;
-
- case USB_EVENT_RESUME:
- cpt[5]++;
- break;
-
- default:
- break;
- }
-
- return (0);
-}
-
-/********************************************************************************
- * ======== cbTxHandler ========
- * Callback handler for the USB stack.
- *
- * Callback handler call by the USB stack to notify us on what has happened in
- * regards to the keyboard.
- *
- * @param(_pcbData) A callback pointer provided by the client.
- *
- * @param(_event) Identifies the event that occurred in regards to
- * this device.
- *
- * @param(_eventMsgData) A data value associated with a particular event.
- *
- * @param(_pEventMsgPtr) A data pointer associated with a particular event.
- *
- ********************************************************************************/
-static USBCDCDEventType cbTxHandler(void *_pcbData, USBCDCDEventType _event,
- USBCDCDEventType _eventMsgData,
- void *_pEventMsgPtr)
-{
- cpt[8]++;
- switch (_event)
- {
- case USB_EVENT_TX_COMPLETE:
- {
- cpt[9]++;
- /*
- * Data was sent, so there should be some space available on the
- * buffer
- */
- Semaphore_post(semTxSerial);
- break;
- }
- default:
- break;
- }
-
- return (0);
-}
-
-/********************************************************************
- * ======== USBCDCD_hwiHandler ========
- * This function calls the USB library's device interrupt handler.
- ********************************************************************/
-void USBCDCD_hwiHandler(UArg arg0)
-{
- USB0DeviceIntHandler();
-}
-
-/********************************************************************
- * ======== rxData ========
- *******************************************************************/
-static unsigned int rxData(unsigned char *_pBuff,
- unsigned int _length,
- unsigned int _timeout)
-{
- unsigned int read = 0;
- cpt[10]++;
-
- if (USBBufferDataAvailable(&rxBuffer) || Semaphore_pend(semRxSerial, _timeout))
- {
- read = USBBufferRead(&rxBuffer, _pBuff, _length);
- }
-
- return (read);
-}
-
-
-/********************************************************************
- * ======== txData ========
- ********************************************************************/
-static unsigned int txData(const unsigned char *_pBuff,
- int _length, unsigned int _timeout)
-{
- unsigned int bufferedCount = 0;
- unsigned int sendCount = 0;
- cpt[11]++;
-
- while (bufferedCount != _length)
- {
- /* Determine the buffer _size available */
- unsigned int buffAvailSize = USBBufferSpaceAvailable(&txBuffer);
-
- /* Determine how much needs to be sent */
- if ((_length - bufferedCount) > buffAvailSize)
- {
- sendCount = buffAvailSize;
- }
- else
- {
- sendCount = _length - bufferedCount;
- }
-
- unsigned char *sendPtr;
- /* Adjust the pointer to the data */
- sendPtr = (unsigned char *)_pBuff + bufferedCount;
-
- /* Place the contents into the USB BUffer */
- bufferedCount += USBBufferWrite(&txBuffer, sendPtr, sendCount);
-
- /* Pend until some data was sent through the USB*/
- if (!Semaphore_pend(semTxSerial, _timeout))
- {
- break;
- }
- }
-
- return (bufferedCount);
-}
-//*****************************************************************************
-//
-// Interrupt handler for the UART which we are redirecting via USB.
-//
-//*****************************************************************************
-void USB0Handler(void)
-{
- USBCDCD_init();
-}
-
-void * USBDComposite = NULL;
-/*******************************************************************
- * ======== USBCDCD_init ========
- *******************************************************************/
-void USBCDCD_init(void)
-{
- Semaphore_Params semParams;
- Error_Block eb;
-
- Error_init(&eb);
- /* Hwi_Handle hwi;
-
- // Install interrupt handler
- hwi = Hwi_create(INT_USB0, USBCDCD_hwiHandler, NULL, &eb);
- if (hwi == NULL)
- {
- System_abort("Can't create USB Hwi");
- }
-*/
- /* RTOS primitives */
- Semaphore_Params_init(&semParams);
- semParams.mode = Semaphore_Mode_BINARY;
- semTxSerial = Semaphore_create(0, &semParams, &eb);
- if (semTxSerial == NULL)
- {
- System_abort("Can't create TX semaphore");
- }
-
- semRxSerial = Semaphore_create(0, &semParams, &eb);
- if (semRxSerial == NULL)
- {
- System_abort("Can't create RX semaphore");
- }
-
- semUSBConnected = Semaphore_create(0, &semParams, &eb);
- if (semUSBConnected == NULL)
- {
- System_abort("Can't create USB semaphore");
- }
-
- gateTxSerial = GateMutex_create(NULL, &eb);
- if (gateTxSerial == NULL)
- {
- System_abort("Can't create gate");
- }
-
- gateRxSerial = GateMutex_create(NULL, &eb);
- if (gateRxSerial == NULL)
- {
- System_abort("Can't create gate");
- }
-
- gateUSBWait = GateMutex_create(NULL, &eb);
- if (gateUSBWait == NULL)
- {
- System_abort("Could not create USB Wait gate");
- }
-
- /* State specific variables */
- state = USBCDCD_STATE_UNCONFIGURED;
-
- /* Set the USB stack mode to Device mode with VBUS monitoring */
- USBStackModeSet(0, eUSBModeForceDevice, 0);
-
- //should be done here only once for supporting firmware upgrade as composite devise
- //if done several times in different places doesn't work in the upgrade.
- USBBufferInit(&txBuffer);
- USBBufferInit(&rxBuffer);
-
- //if (!USBDCDCCompositeInit(0, &g_sCDCDevice, &(g_sCompDevice.psDevices[0])))
- if (!USBDCDCInit(0, &g_sCDCDevice))
- {
- System_abort("Error initializing the serial device");
- }
-
- /*if (!USBDDFUCompositeInit(0, &g_sDFUDevice, &(g_sCompDevice.psDevices[1])))
- {
- System_abort("Error initializing the DFU device");
- }
- //
- // Pass the USB library our device information, initialize the USB
- // controller and connect the device to the bus.
- //
- g_sCompDevice.sPrivateData.sDeviceDescriptor.bcdUSB = 0X200;
- USBDComposite = USBDCompositeInit(0, &g_sCompDevice, DESCRIPTOR_BUFFER_SIZE, g_pui8DescriptorBuffer);
- if (!USBDComposite)
- {
- System_abort("Error initializing the composite device");
- }*/
-}
-
-//-----------------------------------------------------------
-void USBCDCD_Reinit(void)
-{
- Error_Block eb;
- Semaphore_Params semParams;
-
- Error_init(&eb);
-
- /* RTOS primitives */
- Semaphore_Params_init(&semParams);
- semParams.mode = Semaphore_Mode_BINARY;
- semTxSerial = Semaphore_create(0, &semParams, &eb);
- if (semTxSerial == NULL)
- {
- System_abort("Can't create TX semaphore");
- }
-
- /* State specific variables */
- state = USBCDCD_STATE_UNCONFIGURED;
-
- /* Set the USB stack mode to Device mode with VBUS monitoring */
- USBStackModeSet(0, eUSBModeForceDevice, 0);
-
- // if (!USBDCDCInit(0, &g_sCDCDevice, &(g_sCompDevice.psDevices[0])))
- if (!USBDCDCInit(0, &g_sCDCDevice))
- {
- System_abort("Error initializing the serial device");
- }
-/* if (!USBDDFUCompositeInit(0, &g_sDFUDevice, &(g_sCompDevice.psDevices[1])))
- {
- System_abort("Error initializing the DFU device");
- }
-
- // Pass the USB library our device information, initialize the USB
- // controller and connect the device to the bus.
- //
- g_sCompDevice.sPrivateData.sDeviceDescriptor.bcdUSB = 0X200;
- USBDComposite = USBDCompositeInit(0, &g_sCompDevice, DESCRIPTOR_BUFFER_SIZE, g_pui8DescriptorBuffer);
- if (!USBDComposite)
- {
- System_abort("Error initializing the composite device");
- }
-*/
-}
-
-//-----------------------------------------------------------
-void USBCDC_close(void)
-{
- uint32_t tick = 0;
- char str[60];
- uint8_t len = 0;
- tick = UsersysTickGet();
-
- USBDCompositeTerm(USBDComposite);
-
- //Semaphore_post(semTxSerial);
- //Semaphore_delete(&semTxSerial);
-
- //messageFlush();
- USBCDCD_Reinit();
-
- len = usnprintf(str, 60, "\r\n USBCDCD_Reinit tick %d state %d",tick, state );
- cb_push_back (str, len);
-}
-
-/**************************************************************
- * ======== USBCDCD_receiveData ========
-************************************************************* */
-unsigned int USBCDCD_receiveData(unsigned char *_pBuff,
- unsigned int _length,
- unsigned int _timeout)
-{
- unsigned int retValue = 0;
- unsigned int key;
-
- switch (state)
- {
- case USBCDCD_STATE_UNCONFIGURED:
- {
- USBCDCD_waitForConnect(_timeout);
- break;
- }
- case USBCDCD_STATE_INIT:
- {
- /* Acquire lock */
- key = GateMutex_enter(gateRxSerial);
-
- state = USBCDCD_STATE_IDLE;
-
- retValue = rxData(_pBuff, _length, _timeout);
-
- /* Release lock */
- GateMutex_leave(gateRxSerial, key);
- break;
- }
- case USBCDCD_STATE_IDLE:
- {
- /* Acquire lock */
- key = GateMutex_enter(gateRxSerial);
-
- retValue = rxData(_pBuff, _length, _timeout);
-
- /* Release lock */
- GateMutex_leave(gateRxSerial, key);
- break;
- }
- default:
- break;
- }
-
- return (retValue);
-}
-
-/*******************************************************
- * ======== USBCDCD_sendData ========
- *******************************************************/
-unsigned int USBCDCD_sendData(const unsigned char *_pBuff,
- unsigned int _length,
- unsigned int _timeout)
-{
- unsigned int retValue = 0;
- unsigned int key;
- cpt[13]++;
-
- switch (state)
- {
- case USBCDCD_STATE_UNCONFIGURED:
- {
- USBCDCD_waitForConnect(_timeout);
- break;
- }
- case USBCDCD_STATE_INIT:
- {
- /* Acquire lock */
- key = GateMutex_enter(gateTxSerial);
-
- state = USBCDCD_STATE_IDLE;
-
- retValue = txData(_pBuff, _length, _timeout);
-
- /* Release lock */
- GateMutex_leave(gateTxSerial, key);
- break;
- }
- case USBCDCD_STATE_IDLE:
- {
- /* Acquire lock */
- key = GateMutex_enter(gateTxSerial);
-
- retValue = txData(_pBuff, _length, _timeout);
-
- /* Release lock */
- GateMutex_leave(gateTxSerial, key);
- break;
- }
- default:
- break;
- }
-
- return (retValue);
-}
-
-/************************************************
- * ======== USBCDCD_waitForConnect ========
- *************************************************/
-bool USBCDCD_waitForConnect(unsigned int _timeout)
-{
- bool ret = true;
- unsigned int key;
- cpt[12]++;
-
- // Need exclusive access to prevent a race condition
- key = GateMutex_enter(gateUSBWait);
-
- if (state == USBCDCD_STATE_UNCONFIGURED)
- {
- if (!Semaphore_pend(semUSBConnected, _timeout))
- {
- ret = false;
- }
- }
-
- GateMutex_leave(gateUSBWait, key);
-
- return (ret);
-}
-
-uint32_t SendChars(char* buffer,size_t length)
-{
- USBSendData(buffer, length);
- return 0;
-}
-
-/******************************************************************************
- * ======== communicationTask ========
- * Task for this function is created statically. See the project's .cfg file.
- * this communication task is created statically in system initialization, in blocking mode
- * over one of the chosen ommunication methods (USB or Blutooth).
- ******************************************************************************/
-void communicationTask(UArg arg0, UArg arg1)
-{
-
-// USBCDCD_init();
- cpt[14]++;
- //UartBTInit();
- /* Block while the device is NOT connected to the USB */
- Semaphore_pend(initConnectionSem, BIOS_WAIT_FOREVER);
- cpt[15]++;
-
- // Loop forever receiving commands
- while(true)
- {
- cpt[16]++;
-// receive_callback
- //handle incoming data
- }
-}
-
diff --git a/Software/Embedded_SW/Embedded/Drivers/USB_Communication/USBCDCD.bak b/Software/Embedded_SW/Embedded/Drivers/USB_Communication/USBCDCD.bak
deleted file mode 100644
index 89f467e97..000000000
--- a/Software/Embedded_SW/Embedded/Drivers/USB_Communication/USBCDCD.bak
+++ /dev/null
@@ -1,1053 +0,0 @@
-
-/************************************************************************************
- * this module is represents the access layer to USB STACK DRIVER
- * used to communication over USB protocol
- * the USB protocol implementation is inside the module no need for another includes
- * ======== USBCDCD.c ========
- ************************************************************************************/
-
-/* XDCtools Header files */
-#include <xdc/std.h>
-#include <xdc/runtime/Error.h>
-#include <xdc/runtime/System.h>
-
-/* BIOS Header files */
-#include <ti/sysbios/BIOS.h>
-#include <ti/sysbios/gates/GateMutex.h>
-#include <ti/sysbios/hal/Hwi.h>
-#include <ti/sysbios/knl/Semaphore.h>
-#include <ti/sysbios/knl/Task.h>
-
-#include <stdbool.h>
-#include <stdint.h>
-
-/* driverlib Header files */
-#include <inc/hw_ints.h>
-#include <inc/hw_types.h>
-#include <inc/hw_uart.h>
-
-#include <driverlib/rom.h>
-#include <driverlib/sysctl.h>
-#include <driverlib/usb.h>
-#include <inc/hw_memmap.h>
-
-/* usblib Header files */
-#include <usblib/usb-ids.h>
-#include <usblib/usblib.h>
-#include <usblib/usbcdc.h>
-#include <usblib/device/usbdevice.h>
-#include <usblib/device/usbdcdc.h>
-#include <usblib/device/usbddfu-rt.h>
-#include <usblib/device/usbdcomp.h>
-#include "Drivers/USB_Communication/USBCDCD.h"
-
-
-#include <utils/ustdlib.h>
-#include "Common/Utilities/Utils.h"
-//#include "usb_serial_structs.h"
-#include "usb_serial_buffer.h"
-
-#if defined(TIVAWARE)
-typedef uint32_t USBCDCDEventType;
-#else
-#define eUSBModeForceDevice USB_MODE_FORCE_DEVICE
-typedef unsigned long USBCDCDEventType;
-#endif
-
-/* Defines */
-#define USBBUFFERSIZE 256
-//****************************************************************************
-//
-// A buffer into which the composite device can write the combined config
-// descriptor.
-//
-//****************************************************************************
-#define DESCRIPTOR_BUFFER_SIZE (COMPOSITE_DDFU_SIZE + COMPOSITE_DCDC_SIZE)
-
-extern Semaphore_Handle updateSem;
-extern Semaphore_Handle ReconnectSem;
-
-uint8_t g_pui8DescriptorBuffer[DESCRIPTOR_BUFFER_SIZE];
-
-/* Typedefs */
-typedef volatile enum {
- USBCDCD_STATE_IDLE = 0,
- USBCDCD_STATE_INIT,
- USBCDCD_STATE_UNCONFIGURED
-} USBCDCD_USBState;
-
-/* Static variables and handles */
-static volatile USBCDCD_USBState state;
-static unsigned char receiveBuffer[USBBUFFERSIZE];
-static unsigned char transmitBuffer[USBBUFFERSIZE];
-SerialBuffer inBuffer;
-int expected_message_size;
-int current_message_size;
-static volatile uint32_t g_RxCount;
-static GateMutex_Handle gateTxSerial;
-static GateMutex_Handle gateRxSerial;
-static GateMutex_Handle gateUSBWait;
-static Semaphore_Handle semTxSerial;
-static Semaphore_Handle semRxSerial;
-static Semaphore_Handle semUSBConnected;
-extern Semaphore_Handle initConnectionSem;
-
-#define FLAG_STATUS_UPDATE 0
-#define FLAG_USB_CONFIGURED 1
-#define FLAG_SENDING_BREAK 2
-static volatile uint32_t g_ui32Flags;
-
-/* Function prototypes */
-/*
-static USBCDCDEventType cbRxHandler(void *cbData, USBCDCDEventType event,
- USBCDCDEventType _eventMsgData,
- void *eventMsgPtr);
-static USBCDCDEventType cbSerialHandler(void *cbData, USBCDCDEventType event,
- USBCDCDEventType _eventMsgData,
- void *eventMsgPtr);
-static USBCDCDEventType cbTxHandler(void *cbData, USBCDCDEventType event,
- USBCDCDEventType _eventMsgData,
- void *eventMsgPtr);
- */
-uint32_t checkpoints [18] = {0};
-uint32_t TxHandler(void *pvCBData, uint32_t ui32Event, uint32_t ui32MsgValue, void *pvMsgData);
-uint32_t RxHandler(void *pvCBData, uint32_t ui32Event, uint32_t ui32MsgValue,void *pvMsgData);
-uint32_t ControlHandler(void *pvCBData, uint32_t ui32Event, uint32_t ui32MsgValue, void *pvMsgData);
-static Void USBCDCD_hwiHandler(UArg arg0);
-void USBCDCD_init(void);
-
-unsigned int USBCDCD_receiveData(unsigned char *_pBuff,
- unsigned int _length,
- unsigned int _timeout);
-bool USBCDCD_waitForConnect(unsigned int _timeout);
-
-static void (*callback)(char* buffer, size_t length);
-
-/* The languages supported by this device. */
-const unsigned char langDescriptor[] = {
- 4,
- USB_DTYPE_STRING,
- USBShort(USB_LANG_EN_US)
-};
-
-/* The manufacturer string. */
-const unsigned char manufacturerString[] = {
- (17 + 1) * 2,
- USB_DTYPE_STRING,
- 'T', 0, 'e', 0, 'x', 0, 'a', 0, 's', 0, ' ', 0, 'I', 0, 'n', 0, 's', 0,
- 't', 0, 'r', 0, 'u', 0, 'm', 0, 'e', 0, 'n', 0, 't', 0, 's', 0,
-};
-
-/* The product string. */
-const unsigned char productString[] = {
- 2 + (13 * 2),
- USB_DTYPE_STRING,
- 'T', 0, 'w', 0, 'i', 0, 'n', 0, 'e', 0, ' ', 0, 'J', 0, 'i', 0,
- 'g', 0, ' ', 0, 'U', 0, 'S', 0, 'B', 0,
-};
-
-/* The serial number string. */
-const unsigned char serialNumberString[] = {
- (8 + 1) * 2,
- USB_DTYPE_STRING,
- '1', 0, '2', 0, '3', 0, '4', 0, '5', 0, '6', 0, '7', 0, '8', 0
-};
-
-/* The interface description string. */
-const unsigned char controlInterfaceString[] = {
- 2 + (21 * 2),
- USB_DTYPE_STRING,
- 'J', 0, 'i', 0, 'g', 0, ' ', 0, 'C', 0, 'o', 0, 'n', 0, 't', 0,
- 'r', 0, 'o', 0, 'l', 0, ' ', 0, 'I', 0, 'n', 0, 't', 0, 'e', 0,
- 'r', 0, 'f', 0, 'a', 0, 'c', 0, 'e', 0
-};
-
-/* The configuration description string. */
-const unsigned char configString[] = {
- 2 + (26 * 2),
- USB_DTYPE_STRING,
- 'S', 0, 'e', 0, 'l', 0, 'f', 0, ' ', 0, 'P', 0, 'o', 0, 'w', 0,
- 'e', 0, 'r', 0, 'e', 0, 'd', 0, ' ', 0, 'C', 0, 'o', 0, 'n', 0,
- 'f', 0, 'i', 0, 'g', 0, 'u', 0, 'r', 0, 'a', 0, 't', 0, 'i', 0,
- 'o', 0, 'n', 0
-};
-
-//*****************************************************************************
-//
-// The descriptor string table.
-//
-//*****************************************************************************
-const uint8_t * const g_ppui8StringDescriptors[] =
-{
- langDescriptor,
- manufacturerString,
- productString,
- serialNumberString,
- controlInterfaceString,
- configString
-};
-
-#define NUM_STRING_DESCRIPTORS (sizeof(g_ppui8StringDescriptors) / \
- sizeof(g_ppui8StringDescriptors[0]))
-
-/* The descriptor string table. */
-const unsigned char * const stringDescriptors[] = {
- langDescriptor,
- manufacturerString,
- productString,
- serialNumberString,
- controlInterfaceString,
- configString
-};
-
-#define STRINGDESCRIPTORSCOUNT (sizeof(stringDescriptors) / \
- sizeof(unsigned char *))
-
-tUSBBuffer txBuffer;
-tUSBBuffer rxBuffer;
-static tUSBDCDCDevice g_sCDCDevice;
-
-tUSBBuffer rxBuffer =
-{
- false, /* This is a receive buffer. */
- RxHandler, /* pfnCallback */
- (void *)&g_sCDCDevice, /* Callback data is our device pointer. */
- USBDCDCPacketRead, /* pfnTransfer */
- USBDCDCRxPacketAvailable, /* pfnAvailable */
- (void *)&g_sCDCDevice, /* pvHandle */
- receiveBuffer, /* pcBuffer */
- USBBUFFERSIZE, /* ulBufferSize */
- {{0, 0, 0, 0}, 0, 0} /* private data workspace */
-};
-
-tUSBBuffer txBuffer =
-{
- true, /* This is a transmit buffer. */
- TxHandler, /* pfnCallback */
- (void *)&g_sCDCDevice, /* Callback data is our device pointer. */
- USBDCDCPacketWrite, /* pfnTransfer */
- USBDCDCTxPacketAvailable, /* pfnAvailable */
- (void *)&g_sCDCDevice, /* pvHandle */
- transmitBuffer, /* pcBuffer */
- USBBUFFERSIZE, /* ulBufferSize */
- {{0, 0, 0, 0}, 0, 0} /* private data workspace */
-};
-
-static tUSBDCDCDevice g_sCDCDevice =
-{
- USB_VID_TI_1CBE,
- USB_PID_SERIAL,
- 0,
- USB_CONF_ATTR_SELF_PWR,
-
- ControlHandler,
- (void *)&g_sCDCDevice,
-
- USBBufferEventCallback,
- (void *)&rxBuffer,
-
- USBBufferEventCallback,
- (void *)&txBuffer,
-
- stringDescriptors,
- STRINGDESCRIPTORSCOUNT
-};
-
-
-
-static tLineCoding g_sLineCoding = {
- 115200, /* 115200 baud rate. */
- 1, /* 1 Stop Bit. */
- 0, /* No Parity. */
- 8 /* 8 Bits of data. */
-};
-
-
-uint32_t SendChars(char* buffer,size_t length)
-{
- USBCDCD_sendData(buffer, length,10);
- checkpoints[4]++;
-
-}
-//*****************************************************************************
-//
-//! Waits for a character from the USB port.
-//!
-//! This function gets a character from the USB receive buffer.
-//! If there are no characters available, this function waits until a
-//! character is received before returning.
-//!
-//! \return Returns the character read from the USB port.
-//
-//*****************************************************************************
-char USBGetChar(void)
-{
- uint8_t ucChar;
- int len = 0;
- //int leng;
-// char str[60];
- checkpoints[5]++;
-
- len = USBCDCD_receiveData(&ucChar, 1, BIOS_WAIT_FOREVER);
- if (len !=1)
- {
-// leng = usnprintf(str, 60, "\r\n USBGetChar len error %d",len );
-// cb_push_back (str, leng);
- Task_sleep(1);
- len = USBCDCD_receiveData(&ucChar, 1, BIOS_WAIT_FOREVER);
-// leng = usnprintf(str, 60, "\r\n USBGetChar len second %d",len );
-// cb_push_back (str, leng);
- }
- //
- // Now return the char.
- //
- return (ucChar);
-}
-
-/*unsigned int USBSendData(const unsigned char *_pBuff,unsigned int _length)
-{
- //StoreUSBByte ((uint8_t *)_pBuff,_length,false);
- return USBCDCD_sendData(_pBuff,_length,10);
-}
-*/
-void USBFlush(void)
-{
- USBBufferFlush(&rxBuffer);
-}
-
-
-//*****************************************************************************
-//
-// Set the state of the RS232 RTS and DTR signals.
-//
-//*****************************************************************************
-void SetControlLineState(uint16_t ui16State)
-{
- //
- // TODO: If configured with GPIOs controlling the handshake lines,
- // set them appropriately depending upon the flags passed in the wValue
- // field of the request structure passed.
- //
-}
-
-//*****************************************************************************
-//
-// Get the communication parameters in use on the UART.
-//
-//*****************************************************************************
-void GetLineCoding(tLineCoding *psLineCoding)
-{
- psLineCoding->ui32Rate = 9600;
- psLineCoding->ui8Databits = 8;
- psLineCoding->ui8Parity = USB_CDC_PARITY_NONE;
- psLineCoding->ui8Stop = USB_CDC_STOP_BITS_1;
-}
-/********************************************************************
- * ======== USBCDCD_hwiHandler ========
- * This function calls the USB library's device interrupt handler.
- ********************************************************************/
-static Void USBCDCD_hwiHandler(UArg arg0)
-{
- USB0DeviceIntHandler();
- checkpoints[6]++;
-
-}
-//*****************************************************************************
-//
-// This function is called whenever serial data is received from the UART.
-// It is passed the accumulated error flags from each character received in
-// this interrupt and determines from them whether or not an interrupt
-// notification to the host is required.
-//
-// If a notification is required and the control interrupt endpoint is idle,
-// we send the notification immediately. If the endpoint is not idle, we
-// accumulate the errors in a global variable which will be checked on
-// completion of the previous notification and used to send a second one
-// if necessary.
-//
-//*****************************************************************************
-void CheckForSerialStateChange(const tUSBDCDCDevice *psDevice, uint32_t ui32Errors)
-{
- uint16_t ui16SerialState;
-
- //
- // Clear our USB serial state. Since we are faking the handshakes, always
- // set the TXCARRIER (DSR) and RXCARRIER (DCD) bits.
- //
- ui16SerialState = USB_CDC_SERIAL_STATE_TXCARRIER |
- USB_CDC_SERIAL_STATE_RXCARRIER;
-
- //
- // Are any error bits set?
- //
- if(ui32Errors)
- {
- //
- // At least one error is being notified so translate from our hardware
- // error bits into the correct state markers for the USB notification.
- //
- if(ui32Errors & UART_DR_OE)
- {
- ui16SerialState |= USB_CDC_SERIAL_STATE_OVERRUN;
- }
-
- if(ui32Errors & UART_DR_PE)
- {
- ui16SerialState |= USB_CDC_SERIAL_STATE_PARITY;
- }
-
- if(ui32Errors & UART_DR_FE)
- {
- ui16SerialState |= USB_CDC_SERIAL_STATE_FRAMING;
- }
-
- if(ui32Errors & UART_DR_BE)
- {
- ui16SerialState |= USB_CDC_SERIAL_STATE_BREAK;
- }
-
- //
- // Call the CDC driver to notify the state change.
- //
- USBDCDCSerialStateChange((void *)psDevice, ui16SerialState);
- }
-}
-
-//*****************************************************************************
-//
-// Handles CDC driver notifications related to control and setup of the device.
-//
-// \param pvCBData is the client-supplied callback pointer for this channel.
-// \param ulEvent identifies the event we are being notified about.
-// \param ulMsgValue is an event-specific value.
-// \param pvMsgData is an event-specific pointer.
-//
-// This function is called by the CDC driver to perform control-related
-// operations on behalf of the USB host. These functions include setting
-// and querying the serial communication parameters, setting handshake line
-// states and sending break conditions.
-//
-// \return The return value is event-specific.
-//
-//*****************************************************************************
-uint32_t ControlHandler(void *pvCBData, uint32_t ui32Event, uint32_t ui32MsgValue, void *pvMsgData)
-{
- checkpoints[3]++;
-
- //
- // Which event are we being asked to process?
- //
- switch(ui32Event)
- {
- //
- // We are connected to a host and communication is now possible.
- //
- case USB_EVENT_CONNECTED:
- {
- checkpoints[11]++;
- //
- // Now connected and ready for normal operation.
- //
- HWREGBITW(&g_ui32Flags, FLAG_USB_CONFIGURED) = 1;
-
- //
- // Flush our buffers.
- //
- USBBufferFlush(&txBuffer);
- USBBufferFlush(&rxBuffer);
-
- //TODO: Notify connection!
-
- //
- // Set the command status update flag.
- //
- HWREGBITW(&g_ui32Flags, FLAG_STATUS_UPDATE) = 1;
-
- break;
- }
-
- //
- // The host has disconnected.
- //
- case USB_EVENT_DISCONNECTED:
- {
- //checkpoints[12]++;
- //
- // No longer connected.
- //
- HWREGBITW(&g_ui32Flags, FLAG_USB_CONFIGURED) = 0;
-
- //TODO: Notify disconnection!
-
- //
- // Set the command status update flag.
- //
- HWREGBITW(&g_ui32Flags, FLAG_STATUS_UPDATE) = 1;
-
- break;
- }
-
- //
- // Return the current serial communication parameters.
- //
- case USBD_CDC_EVENT_GET_LINE_CODING:
- {
- //checkpoints[13]++;
- GetLineCoding(pvMsgData);
- break;
- }
-
- //
- // Set the current serial communication parameters.
- //
- case USBD_CDC_EVENT_SET_LINE_CODING:
- {
- //checkpoints[14]++;
- GetLineCoding(pvMsgData);
- break;
- }
-
- //
- // Set the current serial communication parameters.
- //
- case USBD_CDC_EVENT_SET_CONTROL_LINE_STATE:
- {
- checkpoints[15]++;
- SetControlLineState((uint16_t)ui32MsgValue);
- break;
- }
-
- //
- // Send a break condition on the serial line.
- //
- case USBD_CDC_EVENT_SEND_BREAK:
- {
- checkpoints[12]++;
- break;
- }
-
- //
- // Clear the break condition on the serial line.
- //
- case USBD_CDC_EVENT_CLEAR_BREAK:
- {
- checkpoints[13]++;
- break;
- }
-
- //
- // Ignore SUSPEND and RESUME for now.
- //
- case USB_EVENT_SUSPEND:
- case USB_EVENT_RESUME:
- {
- checkpoints[14]++;
- break;
- }
-
- //
- // We don't expect to receive any other events. Ignore any that show
- // up in a release build or hang in a debug build.
- //
- default:
- {
-#ifdef DEBUG
- while(1);
-#else
- break;
-#endif
- }
-
- }
-
- return(0);
-}
-void handleRx(void)
-{
- uint32_t ui32Read;
- uint8_t ui8Char;
- uint8_t size[4];
- int size_bar = 0;
- checkpoints[2]++;
-
- if (expected_message_size == 0)
- {
- do
- {
- ui32Read = USBBufferRead((tUSBBuffer *)&rxBuffer, &ui8Char, 1);
-
- if(ui32Read)
- {
- size[size_bar++] = ui8Char;
- }
-
- } while(size_bar < 4);
-
- expected_message_size = *(int *)size;
- }
-
- do
- {
- ui32Read = USBBufferRead((tUSBBuffer *)&rxBuffer, &ui8Char, 1);
-
- // Did we get a character?
- if(ui32Read)
- {
- insertArray(&inBuffer, ui8Char);
- current_message_size++;
- }
-
- if (current_message_size == expected_message_size)
- {
- g_RxCount += current_message_size;
- expected_message_size = 0;
- current_message_size = 0;
- break;
- }
-
- } while(ui32Read);
-}
-
-//*****************************************************************************
-//
-// Handles CDC driver notifications related to the transmit channel (data to
-// the USB host).
-//
-// \param pvCBData is the client-supplied callback pointer for this channel.
-// \param ui32Event identifies the event we are being notified about.
-// \param ui32MsgValue is an event-specific value.
-// \param pvMsgData is an event-specific pointer.
-//
-// This function is called by the CDC driver to notify us of any events
-// related to operation of the transmit data channel (the IN channel carrying
-// data to the USB host).
-//
-// \return The return value is event-specific.
-//
-//*****************************************************************************
-uint32_t TxHandler(void *pvCBData, uint32_t ui32Event, uint32_t ui32MsgValue, void *pvMsgData)
-{
- //
- // Which event have we been sent?
- //
- checkpoints[0]++;
- switch(ui32Event)
- {
- case USB_EVENT_TX_COMPLETE:
- {
- //
- // Since we are using the USBBuffer, we don't need to do anything
- // here.
- //
- break;
- }
-
- //
- // We don't expect to receive any other events. Ignore any that show
- // up in a release build or hang in a debug build.
- //
- default:
- {
-#ifdef DEBUG
- while(1);
-#else
- break;
-#endif
- }
- }
- return(0);
-}
-
-//*****************************************************************************
-//
-// Handles CDC driver notifications related to the receive channel (data from
-// the USB host).
-//
-// \param pvCBData is the client-supplied callback data value for this channel.
-// \param ui32Event identifies the event we are being notified about.
-// \param ui32MsgValue is an event-specific value.
-// \param pvMsgData is an event-specific pointer.
-//
-// This function is called by the CDC driver to notify us of any events
-// related to operation of the receive data channel (the OUT channel carrying
-// data from the USB host).
-//
-// \return The return value is event-specific.
-//
-//*****************************************************************************
-uint32_t RxHandler(void *pvCBData, uint32_t ui32Event, uint32_t ui32MsgValue,void *pvMsgData)
-{
- //
- // Which event are we being sent?
- //
- checkpoints[1]++;
-
- switch(ui32Event)
- {
- //
- // A new packet has been received.
- //
- case USB_EVENT_RX_AVAILABLE:
- {
- //
- // Feed some characters into the UART TX FIFO and enable the
- // interrupt so we are told when there is more space.
- //
- handleRx();
- break;
- }
-
- //
- // We are being asked how much unprocessed data we have still to
- // process. We return 0 if the UART is currently idle or 1 if it is
- // in the process of transmitting something. The actual number of
- // bytes in the UART FIFO is not important here, merely whether or
- // not everything previously sent to us has been transmitted.
- //
- case USB_EVENT_DATA_REMAINING:
- {
- //
- // Get the number of bytes in the buffer and add 1 if some data
- // still has to clear the transmitter.
- return(0);
- }
-
- //
- // We are being asked to provide a buffer into which the next packet
- // can be read. We do not support this mode of receiving data so let
- // the driver know by returning 0. The CDC driver should not be sending
- // this message but this is included just for illustration and
- // completeness.
- //
- case USB_EVENT_REQUEST_BUFFER:
- {
- return(0);
- }
-
- //
- // We don't expect to receive any other events. Ignore any that show
- // up in a release build or hang in a debug build.
- //
- default:
-#ifdef DEBUG
- while(1);
-#else
- break;
-#endif
- }
-
- return(0);
-}
-
-
-//Execute this function on UART0 Interrupt;
-void InitUSB(void)
-{
- checkpoints[9]++;
- CheckForSerialStateChange(&g_sCDCDevice, 0);
-}
-//*****************************************************************************
-//
-// Interrupt handler for the UART which we are redirecting via USB.
-//
-//*****************************************************************************
-void USB0Handler(void)
-{
- InitUSB();
- checkpoints[7]++;
-
-}
-
-
-
-
-void * USBDComposite = NULL;
-/*******************************************************************
- * ======== USBCDCD_init ========
- *******************************************************************/
-void USBCDCD_init(void)
-{
- Hwi_Handle hwi;
- Error_Block eb;
- Semaphore_Params semParams;
-
- Error_init(&eb);
-
- /* Install interrupt handler */
- hwi = Hwi_create(INT_USB0, USBCDCD_hwiHandler, NULL, &eb);
- if (hwi == NULL)
- {
- System_abort("Can't create USB Hwi");
- }
-
- /* RTOS primitives */
- Semaphore_Params_init(&semParams);
- semParams.mode = Semaphore_Mode_BINARY;
- semTxSerial = Semaphore_create(0, &semParams, &eb);
- if (semTxSerial == NULL)
- {
- System_abort("Can't create TX semaphore");
- }
-
- semRxSerial = Semaphore_create(0, &semParams, &eb);
- if (semRxSerial == NULL)
- {
- System_abort("Can't create RX semaphore");
- }
-
- semUSBConnected = Semaphore_create(0, &semParams, &eb);
- if (semUSBConnected == NULL)
- {
- System_abort("Can't create USB semaphore");
- }
-
- gateTxSerial = GateMutex_create(NULL, &eb);
- if (gateTxSerial == NULL)
- {
- System_abort("Can't create gate");
- }
-
- gateRxSerial = GateMutex_create(NULL, &eb);
- if (gateRxSerial == NULL)
- {
- System_abort("Can't create gate");
- }
-
- gateUSBWait = GateMutex_create(NULL, &eb);
- if (gateUSBWait == NULL)
- {
- System_abort("Could not create USB Wait gate");
- }
-
- /* State specific variables */
- state = USBCDCD_STATE_UNCONFIGURED;
-
- /* Set the USB stack mode to Device mode with VBUS monitoring */
- USBStackModeSet(0, eUSBModeForceDevice, 0);
-
- //should be done here only once for supporting firmware upgrade as composite devise
- //if done several times in different places doesn't work in the upgrade.
- USBBufferInit(&txBuffer);
- USBBufferInit(&rxBuffer);
-/*
- if (!USBDCDCCompositeInit(0, &g_sCDCDevice, &(g_sCompDevice.psDevices[0])))
- {
- System_abort("Error initializing the serial device");
- }
-
- if (!USBDDFUCompositeInit(0, &g_sDFUDevice, &(g_sCompDevice.psDevices[1])))
- {
- System_abort("Error initializing the DFU device");
- }
-
- //
- // Pass the USB library our device information, initialize the USB
- // controller and connect the device to the bus.
- //
- g_sCompDevice.sPrivateData.sDeviceDescriptor.bcdUSB = 0X200;
- USBDComposite = USBDCompositeInit(0, &g_sCompDevice, DESCRIPTOR_BUFFER_SIZE, g_pui8DescriptorBuffer);
- if (!USBDComposite)
- {
- System_abort("Error initializing the composite device");
- }
- */
- if (!USBDCDCInit(0, &g_sCDCDevice))
- {
- System_abort("Error initializing the serial device");
- }
-
-}
-
-//-----------------------------------------------------------
-void USBCDCD_Reinit(void)
-{
- Error_Block eb;
- Semaphore_Params semParams;
-
- Error_init(&eb);
-
- /* RTOS primitives */
- Semaphore_Params_init(&semParams);
- semParams.mode = Semaphore_Mode_BINARY;
- semTxSerial = Semaphore_create(0, &semParams, &eb);
- if (semTxSerial == NULL)
- {
- System_abort("Can't create TX semaphore");
- }
-
- /* State specific variables */
- state = USBCDCD_STATE_UNCONFIGURED;
-
- /* Set the USB stack mode to Device mode with VBUS monitoring */
- USBStackModeSet(0, eUSBModeForceDevice, 0);
-
- if (!USBDCDCInit(0, &g_sCDCDevice))
- {
- System_abort("Error initializing the serial device");
- }
-
-}
-
-//-----------------------------------------------------------
-void USBCDC_close(void)
-{
- uint32_t tick = 0;
- char str[60];
- uint8_t len = 0;
- tick = UsersysTickGet();
-
- USBDCompositeTerm(USBDComposite);
-
- Semaphore_post(semTxSerial);
- Semaphore_delete(&semTxSerial);
-
- USBCDCD_Reinit();
-
- len = usnprintf(str, 60, "\r\n USBCDCD_Reinit tick %d state %d",tick, state );
- cb_push_back (str, len);
-}
-
-/**************************************************************
- * ======== USBCDCD_receiveData ========
-************************************************************* */
-unsigned int USBCDCD_receiveData(unsigned char *_pBuff,
- unsigned int _length,
- unsigned int _timeout)
-{
- unsigned int retValue = 0;
- unsigned int key;
- checkpoints[9]++;
-
- switch (state)
- {
- case USBCDCD_STATE_UNCONFIGURED:
- {
- USBCDCD_waitForConnect(_timeout);
- break;
- }
- case USBCDCD_STATE_INIT:
- {
- /* Acquire lock */
- key = GateMutex_enter(gateRxSerial);
-
- state = USBCDCD_STATE_IDLE;
-
- handleRx();
- //retValue = rxData(_pBuff, _length, _timeout);
-
- /* Release lock */
- GateMutex_leave(gateRxSerial, key);
- break;
- }
- case USBCDCD_STATE_IDLE:
- {
- /* Acquire lock */
- key = GateMutex_enter(gateRxSerial);
- handleRx();
- //retValue = rxData(_pBuff, _length, _timeout);
-
- /* Release lock */
- GateMutex_leave(gateRxSerial, key);
- break;
- }
- default:
- break;
- }
-
- return (retValue);
-}
-
-/*******************************************************
- * ======== USBCDCD_sendData ========
- *******************************************************/
-unsigned int USBCDCD_sendData(char *_pBuff,
- unsigned int _length,
- unsigned int _timeout)
-{
- uint8_t size[4];
- size[3] = (_length>>24) & 0xFF;
- size[2] = (_length>>16) & 0xFF;
- size[1] = (_length>>8) & 0xFF;
- size[0] = _length & 0xFF;
- checkpoints[10]++;
-
- USBBufferWrite((tUSBBuffer *)&txBuffer, size, 4);
- return USBBufferWrite((tUSBBuffer *)&txBuffer, (uint8_t*)_pBuff, _length);
-}
-
-/************************************************
- * ======== USBCDCD_waitForConnect ========
- *************************************************/
-bool USBCDCD_waitForConnect(unsigned int _timeout)
-{
- bool ret = true;
- unsigned int key;
-
- // Need exclusive access to prevent a race condition
- key = GateMutex_enter(gateUSBWait);
- checkpoints[16]++;
-
- if (state == USBCDCD_STATE_UNCONFIGURED)
- {
- if (!Semaphore_pend(semUSBConnected, _timeout))
- {
- ret = false;
- }
- }
-
- GateMutex_leave(gateUSBWait, key);
-
- return (ret);
-}
-void RegisterReceiveCallback(void (*callback_ptr)(char* buffer, size_t length))
-{
- callback = callback_ptr;
-}
-
-extern Semaphore_Handle initConnectionSem;
-
-/******************************************************************************
- * ======== communicationTask ========
- * Task for this function is created statically. See the project's .cfg file.
- * this communication task is created statically in system initialization, in blocking mode
- * over one of the chosen ommunication methods (USB or Blutooth).
- ******************************************************************************/
-void communicationTask(UArg arg0, UArg arg1)
-{
-
- uint32_t ui32RxCount;
-
- ui32RxCount = 0;
- g_RxCount = 0;
-
- USBCDCD_init();
- //UartBTInit();
- //Clock_Params_init(&clkParams);
-
- //create clock timeout counter
- //clkParams.period = 0;
- //clkParams.startFlag = FALSE;
- //communicationTimeoutClock = Clock_create(CommunicationLoseClockHandle, 0, &clkParams, NULL);
- /* Block while the device is NOT connected to the USB */
- Semaphore_pend(initConnectionSem, BIOS_WAIT_FOREVER);
-
- // Loop forever receiving commands
- while(true)
- {
- if(ui32RxCount != g_RxCount)
- {
- ui32RxCount = g_RxCount;
- checkpoints[17]++;
-
- if (callback != NULL)
- {
- callback(inBuffer.buffer,inBuffer.used);
- }
-
- freeArray(&inBuffer);
- initArray(&inBuffer, 1);
- }
-
- }
-}
-
diff --git a/Software/Embedded_SW/Embedded/Drivers/USB_Communication/USBCDCD.c b/Software/Embedded_SW/Embedded/Drivers/USB_Communication/USBCDCD.c
index 005137f73..130518edf 100644
--- a/Software/Embedded_SW/Embedded/Drivers/USB_Communication/USBCDCD.c
+++ b/Software/Embedded_SW/Embedded/Drivers/USB_Communication/USBCDCD.c
@@ -45,7 +45,8 @@
#include <utils/ustdlib.h>
#include "Common/Utilities/Utils.h"
-#include "usb_serial_buffer.h"
+
+#include "Communication/CommunicationTask.h"
#if defined(TIVAWARE)
typedef uint32_t USBCDCDEventType;
@@ -80,15 +81,15 @@ typedef volatile enum {
static volatile USBCDCD_USBState state;
static unsigned char receiveBuffer[USBBUFFERSIZE];
static unsigned char transmitBuffer[USBBUFFERSIZE];
-SerialBuffer inBuffer;
+
int expected_message_size;
int current_message_size;
static volatile uint32_t g_RxCount;
-static GateMutex_Handle gateTxSerial;
+//static GateMutex_Handle gateTxSerial;
static GateMutex_Handle gateRxSerial;
static GateMutex_Handle gateUSBWait;
static Semaphore_Handle semTxSerial;
-static Semaphore_Handle semRxSerial;
+//static Semaphore_Handle semRxSerial;
static Semaphore_Handle semUSBConnected;
extern Semaphore_Handle initConnectionSem;
@@ -123,8 +124,6 @@ unsigned int USBCDCD_receiveData(unsigned char *_pBuff,
unsigned int _timeout);
bool USBCDCD_waitForConnect(unsigned int _timeout);
-static void (*callback)(char* buffer, size_t length);
-
/* The languages supported by this device. */
const unsigned char langDescriptor[] = {
4,
@@ -264,15 +263,10 @@ static tLineCoding g_sLineCoding = {
8 /* 8 Bits of data. */
};
-Mailbox_Handle CommunicationRxMsgQ = NULL;
-typedef struct CommRxMessage{
- uint16_t messageId;
- uint16_t msgSize;
-}CommRxMessageStruc;
uint32_t SendChars(char* buffer,size_t length)
{
- return USBCDCD_sendData(buffer, length,10);
+ return CommunicationTaskSendMessage(buffer, length);
}
//*****************************************************************************
//
@@ -561,7 +555,6 @@ void handleRx(void)
uint8_t size[4];
int size_bar = 0;
checkpoints[2]++;
- CommRxMessageStruc Message;
if (expected_message_size == 0)
{
@@ -577,7 +570,7 @@ if (expected_message_size == 0)
} while(size_bar < 4);
expected_message_size = *(int *)size;
- initArray(&inBuffer, expected_message_size);
+ initArray( expected_message_size);
}
do
@@ -587,17 +580,14 @@ if (expected_message_size == 0)
// Did we get a character?
if(ui32Read)
{
- insertArray(&inBuffer, ui8Char);
+ insertArray(ui8Char);
current_message_size++;
}
if (current_message_size == expected_message_size)
{
g_RxCount += current_message_size;
- Message.messageId = 1;
- Message.msgSize = g_RxCount;
- if (CommunicationRxMsgQ != NULL)
- /*retcode =*/ Mailbox_post(CommunicationRxMsgQ , &Message, BIOS_NO_WAIT);
+ CommunicationTaskMessageReceived(g_RxCount);
expected_message_size = 0;
current_message_size = 0;
break;
@@ -762,9 +752,7 @@ void * USBDComposite = NULL;
*******************************************************************/
void USBCDCD_init(void)
{
- Semaphore_Params semParams;
Error_Block eb;
- CommunicationRxMsgQ = Mailbox_create(sizeof(CommRxMessageStruc), 5, NULL,NULL);
Error_init(&eb);
@@ -776,7 +764,6 @@ void USBCDCD_init(void)
System_abort("Can't create USB Hwi");
}
- initArray(&inBuffer, 1);
/* RTOS primitives */
/*Semaphore_Params_init(&semParams);
@@ -968,53 +955,5 @@ bool USBCDCD_waitForConnect(unsigned int _timeout)
return (ret);
}
-void RegisterReceiveCallback(void (*callback_ptr)(char* buffer, size_t length))
-{
- callback = callback_ptr;
-}
-
-extern Semaphore_Handle initConnectionSem;
-
-/******************************************************************************
- * ======== communicationTask ========
- * Task for this function is created statically. See the project's .cfg file.
- * this communication task is created statically in system initialization, in blocking mode
- * over one of the chosen ommunication methods (USB or Blutooth).
- ******************************************************************************/
-void communicationTask(UArg arg0, UArg arg1)
-{
- uint32_t ui32RxCount;
- CommRxMessageStruc Message;
-
- ui32RxCount = 0;
- g_RxCount = 0;
-
- USBCDCD_init();
- //UartBTInit();
- /* Block while the device is NOT connected to the USB */
-// Semaphore_pend(initConnectionSem, BIOS_WAIT_FOREVER);
- cpt[15]++;
-
- while(1)
- {
- Mailbox_pend(CommunicationRxMsgQ , &Message, BIOS_WAIT_FOREVER);
- switch (Message.messageId)
- {
- case 1:
- ui32RxCount += Message.msgSize;
- if (callback != NULL)
- {
- callback(inBuffer.buffer,inBuffer.used);
- }
-
- freeArray(&inBuffer);
- initArray(&inBuffer, 1);
- break;
- default:
- break;
- }
- }
-
-}
diff --git a/Software/Embedded_SW/Embedded/Drivers/USB_Communication/USBCDCD.h b/Software/Embedded_SW/Embedded/Drivers/USB_Communication/USBCDCD.h
index 742f94b1f..c2bedce72 100644
--- a/Software/Embedded_SW/Embedded/Drivers/USB_Communication/USBCDCD.h
+++ b/Software/Embedded_SW/Embedded/Drivers/USB_Communication/USBCDCD.h
@@ -15,6 +15,7 @@ extern "C" {
#include <xdc/std.h>
#include <stdbool.h>
+#include "include.h"
/******************************************************************
* ======== USBCDCD_init ========
@@ -64,8 +65,6 @@ unsigned int USBCDCD_sendData(const unsigned char *_pBuff,
unsigned int USBCDCD_receiveData(unsigned char *_pBuff, unsigned int _length, unsigned int _timeout);
-void RegisterReceiveCallback(void (*callback_ptr)(char* buffer, size_t length));
-
uint32_t SendChars(char* buffer,size_t length);
/**********************************************************
@@ -80,8 +79,6 @@ void USBCDC_close(void);
void USBCDCD_hwiHandler(UArg arg0);
uint32_t SendChars(char* buffer,size_t length);
-void RegisterReceiveCallback(void (*callback_ptr)(char* buffer, size_t length));
-
#ifdef __cplusplus
}
#endif
diff --git a/Software/Embedded_SW/Embedded/Drivers/USB_Communication/usb_serial_buffer.c b/Software/Embedded_SW/Embedded/Drivers/USB_Communication/usb_serial_buffer.c
deleted file mode 100644
index 65ff1ddb8..000000000
--- a/Software/Embedded_SW/Embedded/Drivers/USB_Communication/usb_serial_buffer.c
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * usb_serial_buffer.c
- *
- * Created on: Sep 24, 2017
- * Author: Roy
- */
-
-#include "include.h"
-#include <stdlib.h>
-#include "usb_serial_buffer.h"
-
-char Buffer[2000];
-void initArray(SerialBuffer *a, size_t initialSize) {
- assert (initialSize < 2000);
- a->buffer = Buffer;
- a->used = 0;
- a->size = initialSize;
-}
-
-void insertArray(SerialBuffer *a, char element) {
- // a->used is the number of used entries, because a->array[a->used++] updates a->used only *after* the array has been accessed.
- // Therefore a->used can go up to a->size
- a->buffer[a->used++] = element;
-}
-
-void freeArray(SerialBuffer *a) {
- a->used = a->size = 0;
-}
-
diff --git a/Software/Embedded_SW/Embedded/Drivers/USB_Communication/usb_serial_buffer.h b/Software/Embedded_SW/Embedded/Drivers/USB_Communication/usb_serial_buffer.h
deleted file mode 100644
index 561f84b29..000000000
--- a/Software/Embedded_SW/Embedded/Drivers/USB_Communication/usb_serial_buffer.h
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * usb_serial_buffer.h
- *
- * Created on: Sep 24, 2017
- * Author: Roy
- */
-#include <stdlib.h>
-
-struct serialBuffer {
- char *buffer;
- size_t used;
- size_t size;
-} typedef SerialBuffer;
-
-void initArray(SerialBuffer *a, size_t initialSize);
-
-void insertArray(SerialBuffer *a, char element);
-
-void freeArray(SerialBuffer *a);
-
diff --git a/Software/Embedded_SW/Embedded/Drivers/Uart_Comm/Uart.c b/Software/Embedded_SW/Embedded/Drivers/Uart_Comm/Uart.c
new file mode 100644
index 000000000..07d9e01df
--- /dev/null
+++ b/Software/Embedded_SW/Embedded/Drivers/Uart_Comm/Uart.c
@@ -0,0 +1,271 @@
+
+
+#include <stdbool.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+
+#include <driverlib/gpio.h>
+#include <driverlib/pin_map.h>
+#include <driverlib/rom.h>
+#include <driverlib/sysctl.h>
+#include <driverlib/timer.h>
+#include <inc/hw_ints.h>
+#include "inc/hw_uart.h"
+#include <inc/hw_memmap.h>
+#include <driverlib/uart.h>
+
+#include "driverlib/interrupt.h"
+#include "utils/uartstdio.h"
+
+///
+/* XDCtools Header files */
+#include <xdc/std.h>
+#include <xdc/runtime/Error.h>
+#include <xdc/runtime/System.h>
+
+/* BIOS Header files */
+#include <ti/sysbios/BIOS.h>
+#include <ti/sysbios/gates/GateMutex.h>
+#include <ti/sysbios/hal/Hwi.h>
+#include <ti/sysbios/knl/Semaphore.h>
+#include <ti/sysbios/knl/Task.h>
+
+#include <stdbool.h>
+#include <stdint.h>
+
+/* driverlib Header files */
+#include <inc/hw_ints.h>
+#include <inc/hw_types.h>
+#include <inc/hw_uart.h>
+
+#include <driverlib/rom.h>
+#include <driverlib/sysctl.h>
+#include <driverlib/usb.h>
+#include <inc/hw_memmap.h>
+
+/* usblib Header files */
+#include <usblib/usb-ids.h>
+#include <usblib/usblib.h>
+#include <usblib/usbcdc.h>
+#include <usblib/device/usbdevice.h>
+#include <usblib/device/usbdcdc.h>
+#include <usblib/device/usbddfu-rt.h>
+#include <usblib/device/usbdcomp.h>
+
+#include "Communication/CommunicationTask.h"
+
+
+#include <utils/ustdlib.h>
+#include "Common/Utilities/Utils.h"
+//#include "usb_serial_buffer.h"
+///
+
+void UARTIntHandler(void);
+
+void Init_U0_Interrupt()
+{
+ //
+ // Configure and enable UART interrupts.
+ //
+ ROM_UARTIntClear(UART0_BASE, ROM_UARTIntStatus(UART0_BASE, false));
+
+ //ROM_UARTIntEnable(UART0_BASE, (UART_INT_OE | UART_INT_BE | UART_INT_PE |
+ // UART_INT_FE | UART_INT_RT | UART_INT_TX | UART_INT_RX));
+ //MAP_UARTIntRegister(INT_UART0,UARTIntHandler,0);
+
+ /* Install interrupt handler */
+ Error_Block eb;
+ Error_init(&eb);
+ Hwi_Handle hwi;
+ hwi = Hwi_create(INT_UART0, UARTIntHandler, NULL, &eb);// int number 21 Embedded.cfg
+ if (hwi == NULL)
+ {
+ System_abort("Can't create UART Hwi");
+ }
+
+ ROM_UARTIntEnable(UART0_BASE, /*UART_INT_TX |*/ UART_INT_RX );
+
+ ROM_UARTEnable(UART0_BASE);
+ //
+ // Enable interrupts now that the application is ready to start.
+ //
+ ROM_IntEnable(INT_UART0);
+
+ IntMasterEnable();
+}
+
+void Init_U0(uint32_t ui32SysClock)
+{
+
+// ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
+// SYSCTL_OSC_MAIN | SYSCTL_USE_PLL |
+// SYSCTL_CFG_VCO_480), 120000000);
+ // SysCtlClockSet(SYSCTL_SYSDIV_2_5|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ);//OK
+
+ //
+ // 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, 9600, 120000000);
+
+ UARTprintf("InitConsole_U0 1\n");
+ UARTprintf("InitConsole_U0 2\n");
+
+ Init_U0_Interrupt();
+}
+
+
+
+
+int U0_expected_message_size = 0;
+int U0_current_message_size = 0;
+int U0_size_bar = 0;
+
+//*****************************************************************************
+//
+// The UART interrupt handler.
+//
+//*****************************************************************************
+//void UART0IntHandler(void)
+void UARTIntHandler(void)
+{
+ uint32_t ui32Status;
+ uint8_t ui8Char;
+ uint8_t size[4];
+
+ #define RX_Max_Size 100
+
+ char RX[RX_Max_Size];
+
+ static unsigned int i=0;
+ unsigned int j=0;
+
+ memset(RX, 0, sizeof(RX));
+
+ //
+ // Get the interrrupt status.
+ //
+ ui32Status = ROM_UARTIntStatus(UART0_BASE, true);
+
+ //
+ // Clear the asserted interrupts.
+ //
+ ROM_UARTIntClear(UART0_BASE, ui32Status);
+
+ while(ROM_UARTCharsAvail(UART0_BASE))
+ {
+ if (U0_expected_message_size == 0)
+ {
+ size[U0_size_bar++] = (char)ROM_UARTCharGetNonBlocking(UART0_BASE);
+ if (U0_size_bar == 4)
+ {
+ U0_expected_message_size = *(int *)size;
+ if (initArray( U0_expected_message_size) == 0)
+ U0_expected_message_size = 0;
+ U0_size_bar = 0;
+ }
+ }
+ else
+ {
+ ui8Char = (char)ROM_UARTCharGetNonBlocking(UART0_BASE);
+ insertArray(ui8Char);
+ U0_current_message_size++;
+ if (U0_current_message_size == U0_expected_message_size)
+ {
+ CommunicationTaskMessageReceived(U0_current_message_size);
+ U0_expected_message_size = 0;
+ U0_current_message_size = 0;
+ break;
+ }
+
+ }
+ }
+
+}
+
+
+
+void Uart_Tx(char *buffer,size_t length)
+{
+
+ /*size_t i;
+
+ UARTprintf("Uart_TX \n");
+
+ for(i=0;i<length;i++)
+ {
+ while(UARTBusy(UART0_BASE));
+
+ UARTprintf("0x%x, ",buffer[i]);
+ SysCtlDelay(1000);
+
+ }*/
+ size_t sentlength = 0;
+ uint8_t size[4],i =0;
+ size[3] = (length>>24) & 0xFF;
+ size[2] = (length>>16) & 0xFF;
+ size[1] = (length>>8) & 0xFF;
+ size[0] = length & 0xFF;
+ while (i < 4)
+ {
+ if (ROM_UARTSpaceAvail(UART0_BASE))
+ {
+ ROM_UARTCharPut(UART0_BASE,size[i++]);
+ }
+
+ }
+
+ while (sentlength < length)
+ {
+ if (ROM_UARTSpaceAvail(UART0_BASE))
+ {
+ ROM_UARTCharPut(UART0_BASE,buffer[sentlength++]);
+ }
+
+ }
+
+}
+
+void test_Uart()
+
+{
+ #define size 16
+ char buffer[size] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
+
+ Uart_Tx(buffer,size);
+}
+
+
+
+
diff --git a/Software/Embedded_SW/Embedded/Drivers/Uart_Comm/Uart.h b/Software/Embedded_SW/Embedded/Drivers/Uart_Comm/Uart.h
new file mode 100644
index 000000000..c4e287d4a
--- /dev/null
+++ b/Software/Embedded_SW/Embedded/Drivers/Uart_Comm/Uart.h
@@ -0,0 +1,2 @@
+void Init_U0(uint32_t ui32SysClock);
+void test_Uart();
diff --git a/Software/Embedded_SW/Embedded/Drivers/twine_usblib/usb_serial_buffer.c b/Software/Embedded_SW/Embedded/Drivers/twine_usblib/usb_serial_buffer.c
deleted file mode 100644
index 5025bb772..000000000
--- a/Software/Embedded_SW/Embedded/Drivers/twine_usblib/usb_serial_buffer.c
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * usb_serial_buffer.c
- *
- * Created on: Sep 24, 2017
- * Author: Roy
- */
-
-#include <stdlib.h>
-#include "usb_serial_buffer.h"
-
-void initArray(SerialBuffer *a, size_t initialSize) {
- a->buffer = (char *)malloc(initialSize);
- a->used = 0;
- a->size = initialSize;
-}
-
-void insertArray(SerialBuffer *a, char element) {
- // a->used is the number of used entries, because a->array[a->used++] updates a->used only *after* the array has been accessed.
- // Therefore a->used can go up to a->size
- if (a->used == a->size) {
- a->size += 1;
- a->buffer = (char *)realloc(a->buffer, a->size * sizeof(char));
- }
- a->buffer[a->used++] = element;
-}
-
-void freeArray(SerialBuffer *a) {
- free(a->buffer);
- a->buffer = NULL;
- a->used = a->size = 0;
-}
-
diff --git a/Software/Embedded_SW/Embedded/Drivers/twine_usblib/usb_serial_buffer.h b/Software/Embedded_SW/Embedded/Drivers/twine_usblib/usb_serial_buffer.h
deleted file mode 100644
index 561f84b29..000000000
--- a/Software/Embedded_SW/Embedded/Drivers/twine_usblib/usb_serial_buffer.h
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * usb_serial_buffer.h
- *
- * Created on: Sep 24, 2017
- * Author: Roy
- */
-#include <stdlib.h>
-
-struct serialBuffer {
- char *buffer;
- size_t used;
- size_t size;
-} typedef SerialBuffer;
-
-void initArray(SerialBuffer *a, size_t initialSize);
-
-void insertArray(SerialBuffer *a, char element);
-
-void freeArray(SerialBuffer *a);
-
diff --git a/Software/Embedded_SW/Embedded/Drivers/twine_usblib/usb_serial_structs.c b/Software/Embedded_SW/Embedded/Drivers/twine_usblib/usb_serial_structs.c
deleted file mode 100644
index eaf5eebf4..000000000
--- a/Software/Embedded_SW/Embedded/Drivers/twine_usblib/usb_serial_structs.c
+++ /dev/null
@@ -1,211 +0,0 @@
-//*****************************************************************************
-//
-// usb_serial_structs.c - Data structures defining this CDC USB device.
-//
-// Copyright (c) 2013-2017 Texas Instruments Incorporated. All rights reserved.
-// Software License Agreement
-//
-// Texas Instruments (TI) is supplying this software for use solely and
-// exclusively on TI's microcontroller products. The software is owned by
-// TI and/or its suppliers, and is protected under applicable copyright
-// laws. You may not combine this software with "viral" open-source
-// software in order to form a larger program.
-//
-// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
-// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
-// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
-// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
-// DAMAGES, FOR ANY REASON WHATSOEVER.
-//
-// This is part of revision 2.1.4.178 of the DK-TM4C129X Firmware Package.
-//
-//*****************************************************************************
-
-#include <stdbool.h>
-#include <stdint.h>
-#include "inc/hw_types.h"
-#include "driverlib/usb.h"
-#include "usblib/usblib.h"
-#include "usblib/usbcdc.h"
-#include "usblib/usb-ids.h"
-#include "usblib/device/usbdevice.h"
-#include "usblib/device/usbdcdc.h"
-#include "usb_serial_structs.h"
-
-#define USB_BUFFER_SIZE 1024
-
-//*****************************************************************************
-//
-// The languages supported by this device.
-//
-//*****************************************************************************
-const uint8_t g_pui8LangDescriptor[] =
-{
- 4,
- USB_DTYPE_STRING,
- USBShort(USB_LANG_EN_US)
-};
-
-//*****************************************************************************
-//
-// The manufacturer string.
-//
-//*****************************************************************************
-const uint8_t g_pui8ManufacturerString[] =
-{
- (17 + 1) * 2,
- USB_DTYPE_STRING,
- 'T', 0, 'e', 0, 'x', 0, 'a', 0, 's', 0, ' ', 0, 'I', 0, 'n', 0, 's', 0,
- 't', 0, 'r', 0, 'u', 0, 'm', 0, 'e', 0, 'n', 0, 't', 0, 's', 0,
-};
-
-//*****************************************************************************
-//
-// The product string.
-//
-//*****************************************************************************
-const uint8_t g_pui8ProductString[] =
-{
- 2 + (16 * 2),
- USB_DTYPE_STRING,
- 'V', 0, 'i', 0, 'r', 0, 't', 0, 'u', 0, 'a', 0, 'l', 0, ' ', 0,
- 'C', 0, 'O', 0, 'M', 0, ' ', 0, 'P', 0, 'o', 0, 'r', 0, 't', 0
-};
-
-//*****************************************************************************
-//
-// The serial number string.
-//
-//*****************************************************************************
-const uint8_t g_pui8SerialNumberString[] =
-{
- 2 + (8 * 2),
- USB_DTYPE_STRING,
- '1', 0, '2', 0, '3', 0, '4', 0, '5', 0, '6', 0, '7', 0, '8', 0
-};
-
-//*****************************************************************************
-//
-// The control interface description string.
-//
-//*****************************************************************************
-const uint8_t g_pui8ControlInterfaceString[] =
-{
- 2 + (21 * 2),
- USB_DTYPE_STRING,
- 'A', 0, 'C', 0, 'M', 0, ' ', 0, 'C', 0, 'o', 0, 'n', 0, 't', 0,
- 'r', 0, 'o', 0, 'l', 0, ' ', 0, 'I', 0, 'n', 0, 't', 0, 'e', 0,
- 'r', 0, 'f', 0, 'a', 0, 'c', 0, 'e', 0
-};
-
-//*****************************************************************************
-//
-// The configuration description string.
-//
-//*****************************************************************************
-const uint8_t g_pui8ConfigString[] =
-{
- 2 + (26 * 2),
- USB_DTYPE_STRING,
- 'S', 0, 'e', 0, 'l', 0, 'f', 0, ' ', 0, 'P', 0, 'o', 0, 'w', 0,
- 'e', 0, 'r', 0, 'e', 0, 'd', 0, ' ', 0, 'C', 0, 'o', 0, 'n', 0,
- 'f', 0, 'i', 0, 'g', 0, 'u', 0, 'r', 0, 'a', 0, 't', 0, 'i', 0,
- 'o', 0, 'n', 0
-};
-
-//*****************************************************************************
-//
-// The descriptor string table.
-//
-//*****************************************************************************
-const uint8_t * const g_pui8StringDescriptors[] =
-{
- g_pui8LangDescriptor,
- g_pui8ManufacturerString,
- g_pui8ProductString,
- g_pui8SerialNumberString,
- g_pui8ControlInterfaceString,
- g_pui8ConfigString
-};
-
-#define NUM_STRING_DESCRIPTORS (sizeof(g_pui8StringDescriptors) / \
- sizeof(uint8_t *))
-
-//*****************************************************************************
-//
-// CDC device callback function prototypes.
-//
-//*****************************************************************************
-uint32_t RxHandler(void *pvCBData, uint32_t ui32Event, uint32_t ui32MsgValue,
- void *pvMsgData);
-uint32_t TxHandler(void *pvCBData, uint32_t ui32Event, uint32_t ui32MsgValue,
- void *pvMsgData);
-uint32_t ControlHandler(void *pvCBData, uint32_t ui32Event,
- uint32_t ui32MsgValue, void *pvMsgData);
-
-//*****************************************************************************
-//
-// The CDC device initialization and customization structures. In this case,
-// we are using USBBuffers between the CDC device class driver and the
-// application code. The function pointers and callback data values are set
-// to insert a buffer in each of the data channels, transmit and receive.
-//
-// With the buffer in place, the CDC channel callback is set to the relevant
-// channel function and the callback data is set to point to the channel
-// instance data. The buffer, in turn, has its callback set to the application
-// function and the callback data set to our CDC instance structure.
-//
-//*****************************************************************************
-tCDCSerInstance g_sCDCInstance;
-tUSBDCDCDevice g_sCDCDevice =
-{
- USB_VID_TI_1CBE,
- USB_PID_SERIAL,
- 0,
- USB_CONF_ATTR_SELF_PWR,
- ControlHandler,
- (void *)&g_sCDCDevice,
- USBBufferEventCallback,
- (void *)&g_sRxBuffer,
- USBBufferEventCallback,
- (void *)&g_sTxBuffer,
- g_pui8StringDescriptors,
- NUM_STRING_DESCRIPTORS,
-};
-
-//*****************************************************************************
-//
-// Receive buffer (from the USB perspective).
-//
-//*****************************************************************************
-uint8_t g_pui8USBRxBuffer[USB_BUFFER_SIZE];
-tUSBBuffer g_sRxBuffer =
-{
- false, // This is a receive buffer.
- RxHandler, // pfnCallback
- (void *)&g_sCDCDevice, // Callback data is our device pointer.
- USBDCDCPacketRead, // pfnTransfer
- USBDCDCRxPacketAvailable, // pfnAvailable
- (void *)&g_sCDCDevice, // pvHandle
- g_pui8USBRxBuffer, // pui8Buffer
- USB_BUFFER_SIZE, // ui32BufferSize
-};
-
-//*****************************************************************************
-//
-// Transmit buffer (from the USB perspective).
-//
-//*****************************************************************************
-uint8_t g_pui8USBTxBuffer[USB_BUFFER_SIZE];
-tUSBBuffer g_sTxBuffer =
-{
- true, // This is a transmit buffer.
- TxHandler, // pfnCallback
- (void *)&g_sCDCDevice, // Callback data is our device pointer.
- USBDCDCPacketWrite, // pfnTransfer
- USBDCDCTxPacketAvailable, // pfnAvailable
- (void *)&g_sCDCDevice, // pvHandle
- g_pui8USBTxBuffer, // pcBuffer
- USB_BUFFER_SIZE, // ulBufferSize
-};
diff --git a/Software/Embedded_SW/Embedded/Drivers/twine_usblib/usb_serial_structs.h b/Software/Embedded_SW/Embedded/Drivers/twine_usblib/usb_serial_structs.h
deleted file mode 100644
index a02ac1c75..000000000
--- a/Software/Embedded_SW/Embedded/Drivers/twine_usblib/usb_serial_structs.h
+++ /dev/null
@@ -1,49 +0,0 @@
-//*****************************************************************************
-//
-// usb_serial_structs.h - Data structures defining this USB CDC device.
-//
-// Copyright (c) 2013-2017 Texas Instruments Incorporated. All rights reserved.
-// Software License Agreement
-//
-// Texas Instruments (TI) is supplying this software for use solely and
-// exclusively on TI's microcontroller products. The software is owned by
-// TI and/or its suppliers, and is protected under applicable copyright
-// laws. You may not combine this software with "viral" open-source
-// software in order to form a larger program.
-//
-// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
-// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
-// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
-// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
-// DAMAGES, FOR ANY REASON WHATSOEVER.
-//
-// This is part of revision 2.1.4.178 of the DK-TM4C129X Firmware Package.
-//
-//*****************************************************************************
-
-#ifndef _USB_SERIAL_STRUCTS_H_
-#define _USB_SERIAL_STRUCTS_H_
-
-//*****************************************************************************
-//
-// The size of the transmit and receive buffers used for the redirected UART.
-// This number should be a power of 2 for best performance. 256 is chosen
-// pretty much at random though the buffer should be at least twice the size of
-// a maximum-sized USB packet.
-//
-//*****************************************************************************
-#define UART_BUFFER_SIZE 256
-
-extern uint32_t RxHandler(void *pvCBData, uint32_t ui32Event,
- uint32_t ui32MsgValue, void *pvMsgData);
-extern uint32_t TxHandler(void *pvlCBData, uint32_t ui32Event,
- uint32_t ui32MsgValue, void *pvMsgData);
-
-extern tUSBBuffer g_sTxBuffer;
-extern tUSBBuffer g_sRxBuffer;
-extern tUSBDCDCDevice g_sCDCDevice;
-extern uint8_t g_pui8USBTxBuffer[];
-extern uint8_t g_pui8USBRxBuffer[];
-
-#endif
diff --git a/Software/Embedded_SW/Embedded/Embedded.cfg b/Software/Embedded_SW/Embedded/Embedded.cfg
index 22ee262d8..70158a688 100644
--- a/Software/Embedded_SW/Embedded/Embedded.cfg
+++ b/Software/Embedded_SW/Embedded/Embedded.cfg
@@ -36,6 +36,7 @@ Program.global.timer0 = Hwi.create(35, "&OneMilliSecondControlInterrupt", hwi13P
var hwi20Params = new Hwi.Params();
hwi20Params.instance.name = "watchdog";
Program.global.watchdog = Hwi.create(34, "&WatchdogIntHandler", hwi20Params);
+
var hwi15Params = new Hwi.Params();
hwi15Params.instance.name = "timer2";
hwi15Params.arg = 2;
@@ -95,40 +96,53 @@ var task0Params = new Task.Params();
task0Params.instance.name = "adcProcess";
task0Params.priority = 5;
Program.global.adcProcess = Task.create("&ADCProcessTask", task0Params);
-/*var task1Params = new Task.Params();
-task1Params.instance.name = "message";
-task1Params.priority = 3;
-Program.global.message = Task.create("&messageTsk", task1Params);*/
+
var task2Params = new Task.Params();
task2Params.instance.name = "communication";
-task2Params.priority = 5;
+task2Params.priority = 4;
Program.global.communication = Task.create("&communicationTask", task2Params);
+
var task3Params = new Task.Params();
task3Params.instance.name = "update";
-task3Params.priority = 4;
+task3Params.priority = 2;
Program.global.update = Task.create("&updateTask", task3Params);
+
var task4Params = new Task.Params();
task4Params.instance.name = "Reconnect";
-task4Params.priority = 4;
+task4Params.priority = 2;
Program.global.Reconnect = Task.create("&ReconnectTask", task4Params);
+
var task5Params = new Task.Params();
task5Params.instance.name = "process";
task5Params.priority = 6;
Program.global.process = Task.create("&jobTask", task5Params);
+
var task6Params = new Task.Params();
task6Params.instance.name = "report";
task6Params.priority = 2;
Program.global.report = Task.create("&reportService", task6Params);
+
var task7Params = new Task.Params();
task7Params.instance.name = "control";
-task7Params.priority = 8;
+task7Params.priority = 11;
Program.global.control = Task.create("&controlTask", task7Params);
+
var task8Params = new Task.Params();
task8Params.instance.name = "MilliSecond";
-task8Params.priority = 8;
+task8Params.priority = 12;
Program.global.millisec = Task.create("&MillisecTask", task8Params);
+var task9Params = new Task.Params();
+task9Params.instance.name = "HeatersControl";
+task9Params.priority = 6;
+Program.global.HeatersControl = Task.create("&HeatersControlTask", task9Params);
+
+var task10Params = new Task.Params();
+task10Params.instance.name = "communicationTx";
+task10Params.priority = 3;
+Program.global.communication = Task.create("&communicationTxTask", task10Params);
+
/* ================ NDK configuration ================ */
/*var Ndk = xdc.loadPackage('ti.ndk.config');
var Global = xdc.useModule('ti.ndk.config.Global');
diff --git a/Software/Embedded_SW/Embedded/Main.c b/Software/Embedded_SW/Embedded/Main.c
index bebf71f17..866617833 100644
--- a/Software/Embedded_SW/Embedded/Main.c
+++ b/Software/Embedded_SW/Embedded/Main.c
@@ -42,6 +42,8 @@ extern Semaphore_Handle sdCardSem;
#include "drivers/Danser_SSI/SSI_Comm.h"
#include "drivers/SPI/SPI_Comm.h"
+#include "drivers/Uart_Comm/Uart.h"
+
//#define WATCHDOG
//*****************************************************************************
//
@@ -74,17 +76,21 @@ void SysTickHandler(void)
g_ui32SysTickCount++;
}
-void Init_stubs()
+void Init_stubs(uint32_t ui32SysClock)
{
- //Danser_ENC:
- SSI1_Init(); // Read dancer ENC SSI
- //Loop_SSI(); // while(1) can't use with usb
+ //UART0
+ Init_U0(ui32SysClock);
+ //test_Uart();
//MOTOR Driver L6470 SPI
SPI2_Init();
init_BUSY_Pin();
+ //Danser_ENC:
+ SSI1_Init(); // Read dancer ENC SSI
+ //Loop_SSI(); // while(1) can't use with usb
+
}
int main(void)
@@ -162,7 +168,7 @@ int main(void)
ROM_IntMasterEnable();
#ifdef Stub_Mode
- Init_stubs();
+ Init_stubs(ui32SysClock);
#endif
IDLE_TASK_package_init();
diff --git a/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c b/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c
index b69ca095b..5f8f4750d 100644
--- a/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c
+++ b/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c
@@ -341,7 +341,7 @@ uint32_t HWConfigurationFunc(MessageContainer* requestContainer)
size_t container_size = message_container__pack(&responseContainer, container_buffer);
free(responseContainer.data.data);
SendChars(container_buffer, container_size);
- free(container_buffer);
+ //free(container_buffer);
free(requestContainer);
return OK;
@@ -353,8 +353,6 @@ uint32_t HWConfigurationFunc(MessageContainer* requestContainer)
void HWSystemResetRequest(MessageContainer* requestContainer)
{
uint32_t status = FAILED;
- unsigned char Brd_ID = 0;
- unsigned char Assy_ID = 0;
MessageContainer responseContainer;
SystemResetRequest* request = system_reset_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data);
@@ -373,11 +371,13 @@ void HWSystemResetRequest(MessageContainer* requestContainer)
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(container_buffer);
free(requestContainer);
ROM_SysCtlDelay(SYS_CLK_FREQ);
+ SysCtlReset();
+
HWREG(NVIC_APINT) = NVIC_APINT_VECTKEY | NVIC_APINT_SYSRESETREQ;
}
diff --git a/Software/Embedded_SW/Embedded/Modules/General/process.c b/Software/Embedded_SW/Embedded/Modules/General/process.c
index 443905d64..fdfcdd92a 100644
--- a/Software/Embedded_SW/Embedded/Modules/General/process.c
+++ b/Software/Embedded_SW/Embedded/Modules/General/process.c
@@ -168,6 +168,6 @@ void ProcessRequestFunc(MessageContainer* requestContainer)
size_t container_size = message_container__pack(&responseContainer, container_buffer);
free(responseContainer.data.data);
SendChars(container_buffer, container_size);
- free(container_buffer);
+ //free(container_buffer);
free(requestContainer);
}
diff --git a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_init.c b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_init.c
index 70522b016..1d770acce 100644
--- a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_init.c
+++ b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_init.c
@@ -126,7 +126,7 @@ void HeatingTestRequest(MessageContainer* requestContainer)
free(responseContainer.data.data);
//USBCDCD_sendData(container_buffer, container_size,10);
SendChars(container_buffer, container_size);
- free(container_buffer);
+ //free(container_buffer);
free(requestContainer);
#else
LOG_ERROR (-1, "Heating Control not on debug");
@@ -135,7 +135,6 @@ void HeatingTestRequest(MessageContainer* requestContainer)
}
void HeatingTestPollRequest(MessageContainer* requestContainer)
{
- MessageContainer responseContainer;
//uint8_t* container_buffer;
uint32_t status = 0;
int Heater_i,PID_i;
@@ -158,7 +157,7 @@ void HeatingTestPollRequest(MessageContainer* requestContainer)
size_t container_size = message_container__pack(&responseContainer, container_buffer);
free(responseContainer.data.data);
SendChars(container_buffer, container_size);
- free(container_buffer);*/
+ //free(container_buffer);*/
free(requestContainer);
free(request);
}
@@ -217,7 +216,7 @@ container_buffer = malloc(message_container__get_packed_size(&responseContainer)
free(responseContainer.data.data);
//USBCDCD_sendData(container_buffer, container_size,10);
SendChars(container_buffer, container_size);
- free(container_buffer);
+ //free(container_buffer);
// stubToken[0] = 0;
}
diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Calculate.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Calculate.c
index df706ee69..4aabb444c 100644
--- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Calculate.c
+++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Calculate.c
@@ -34,6 +34,6 @@ void Stub_CalculateRequest(MessageContainer* requestContainer)
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(container_buffer);
free(requestContainer);
}
diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Container.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Container.c
index 96a2dbc3a..1b1db8189 100644
--- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Container.c
+++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Container.c
@@ -24,7 +24,7 @@
#include "General/GeneralHardware.h"
#include "heaters/heaters_ex.h"
#include "Drivers/USB_Communication/USBCDCD.h"
-#include "Drivers/USB_Communication/usb_serial_buffer.h"
+
#include "StateMachines/Printing/PrintingSTM.h"
#include "Modules/General/process.h"
#include "Modules/Thread/Thread_ex.h"
diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/DataDef.h b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/DataDef.h
index 67c509d33..4f0582e50 100644
--- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/DataDef.h
+++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/DataDef.h
@@ -85,6 +85,16 @@ enum
#define FALLING 2
#define RISING 3
+//SPI
+typedef struct //S_SPI
+{
+ unsigned char MotID;
+ unsigned int TX_MOSI; //32bit (Master Output Slave Input )
+ unsigned int RX_MISO; //24bit (Master Input Slave Output)
+ //unsigned int BUSY; //32bit
+
+}SPI;//SPI
+
//---------------------------------------------------------------------
#pragma diag_suppress 169 /* Avoid warnings on VOID * conversions (protobuf issue)
The warning:
diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c
index 452026962..b736a27c3 100644
--- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c
+++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c
@@ -31,7 +31,7 @@ void Stub_ProgressRequest(MessageContainer* requestContainer)
//writeLine("Sending Progress: ");
//writeFloat(response.progress);
SendChars((char*)container_buffer, container_size);
- free(container_buffer);
+ //free(container_buffer);
int co = 0;
@@ -46,7 +46,7 @@ void Stub_ProgressRequest(MessageContainer* requestContainer)
size_t container_size = message_container__pack(&responseContainer, container_buffer);
//writeLine("Progress Completed!");
SendChars((char*)container_buffer, container_size);
- free(container_buffer);
+ //free(container_buffer);
return;
diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Cartridge.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Cartridge.c
index 0f3f9dfd9..f1594bb79 100644
--- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Cartridge.c
+++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Cartridge.c
@@ -69,7 +69,7 @@ void Stub_CartridgeReadRequest(MessageContainer* requestContainer)
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(container_buffer);
free(requestContainer);
}
@@ -123,7 +123,7 @@ void Stub_CartridgeWriteRequest(MessageContainer* requestContainer)
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(container_buffer);
free(requestContainer);
}
diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Dispenser.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Dispenser.c
index 63e72c4fc..21b2bbfa9 100644
--- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Dispenser.c
+++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Dispenser.c
@@ -68,6 +68,6 @@ void Stub_DispenserRequest(MessageContainer* requestContainer)
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(container_buffer);
free(requestContainer);
}
diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_ExtFlash.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_ExtFlash.c
index 75483cf21..ca0a667e6 100644
--- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_ExtFlash.c
+++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_ExtFlash.c
@@ -72,7 +72,7 @@ void Stub_ExtFlashWriteRequest(MessageContainer* requestContainer)
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(container_buffer);
free(requestContainer);
}
@@ -155,7 +155,7 @@ void Stub_ExtFlashReadRequest(MessageContainer* requestContainer)
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(container_buffer);
free(requestContainer);
}
diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_FPGAReadBackReg.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_FPGAReadBackReg.c
index 13df055d6..ab1fc1071 100644
--- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_FPGAReadBackReg.c
+++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_FPGAReadBackReg.c
@@ -63,7 +63,7 @@ void Stub_FPGAReadBackRegRequest(MessageContainer* requestContainer)
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(container_buffer);
free(requestContainer);
}
diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_FPGAReadVersion.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_FPGAReadVersion.c
index 71ec6fc0a..bbb79d4d4 100644
--- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_FPGAReadVersion.c
+++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_FPGAReadVersion.c
@@ -75,7 +75,7 @@ void Stub_FPGAReadVersionRequest(MessageContainer* requestContainer)
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(container_buffer);
free(requestContainer);
}
diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_GPIO.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_GPIO.c
index 1858a8ddb..2ceaae26d 100644
--- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_GPIO.c
+++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_GPIO.c
@@ -222,7 +222,7 @@ void Stub_GPIOWriteBitRequest(MessageContainer* requestContainer)
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(container_buffer);
free(requestContainer);
}
@@ -359,7 +359,7 @@ void Stub_GPIOReadByteRequest(MessageContainer* requestContainer)
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(container_buffer);
free(requestContainer);
}
@@ -604,7 +604,7 @@ void Stub_GPIOReadBitRequest(MessageContainer* requestContainer)
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(container_buffer);
free(requestContainer);
}
@@ -748,7 +748,7 @@ void Stub_GPIOWriteByteRequest(MessageContainer* requestContainer)
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(container_buffer);
free(requestContainer);
}
@@ -943,6 +943,6 @@ void Stub_GPIOInputSetupRequest(MessageContainer* requestContainer)
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(container_buffer);
free(requestContainer);
}
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
index 72d935b83..147be3abf 100644
--- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_HW_Version.c
+++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_HW_Version.c
@@ -89,7 +89,7 @@ void Stub_HWVersionRequest(MessageContainer* requestContainer)
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(container_buffer);
free(requestContainer);
}
diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Heater.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Heater.c
index 0499d5d66..8a223d35d 100644
--- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Heater.c
+++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Heater.c
@@ -70,6 +70,6 @@ void Stub_HeaterRequest(MessageContainer* requestContainer)
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(container_buffer);
free(requestContainer);
}
diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_L6470.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_L6470.c
index 4b9f016de..014833473 100644
--- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_L6470.c
+++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_L6470.c
@@ -125,7 +125,7 @@ void Stub_L6470DriverRequest(MessageContainer* requestContainer)
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(container_buffer);
free(requestContainer);
diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Motor.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Motor.c
index 0c9a11723..2604f93a2 100644
--- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Motor.c
+++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Motor.c
@@ -130,7 +130,7 @@ void Stub_MotorInitRequest(MessageContainer* requestContainer)
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(container_buffer);
free(requestContainer);
}
@@ -208,7 +208,7 @@ void Stub_MotorRunRequest(MessageContainer* requestContainer)
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(container_buffer);
free(requestContainer);
}
@@ -271,7 +271,7 @@ void Stub_MotorStopRequest(MessageContainer* requestContainer)
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(container_buffer);
free(requestContainer);
}
@@ -357,7 +357,7 @@ void Stub_MotorStatusRequest(MessageContainer* requestContainer)
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(container_buffer);
free(requestContainer);
}
@@ -385,7 +385,7 @@ void Stub_MotorSpeedRequest(MessageContainer* requestContainer)
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(container_buffer);
free(requestContainer);
}
@@ -412,7 +412,7 @@ void Stub_MotorPositionRequest(MessageContainer* requestContainer)
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(container_buffer);
free(requestContainer);
}
@@ -466,7 +466,7 @@ void Stub_MotorMovRequest(MessageContainer* requestContainer)
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(container_buffer);
free(requestContainer);
}
diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_MotorEncoder.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_MotorEncoder.c
index 807fa69ab..f217d48dd 100644
--- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_MotorEncoder.c
+++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_MotorEncoder.c
@@ -80,6 +80,6 @@ void Stub_MotorEncoderRequest(MessageContainer* requestContainer)
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(container_buffer);
free(requestContainer);
}
diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_OptLimitSwitch.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_OptLimitSwitch.c
index 7c166db48..5b40a5324 100644
--- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_OptLimitSwitch.c
+++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_OptLimitSwitch.c
@@ -66,6 +66,6 @@ void Stub_OptLimitSwitchRequest(MessageContainer* requestContainer)
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(container_buffer);
free(requestContainer);
}
diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_SteperMotor.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_SteperMotor.c
index baf66af8f..cfe22a43f 100644
--- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_SteperMotor.c
+++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_SteperMotor.c
@@ -75,6 +75,6 @@ void Stub_SteperMotorRequest(MessageContainer* requestContainer)
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(container_buffer);
free(requestContainer);
}
diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Valve.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Valve.c
index c69b41d7b..cf6a910dc 100644
--- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Valve.c
+++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Valve.c
@@ -56,6 +56,6 @@ void Stub_ValveRequest(MessageContainer* requestContainer)
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(container_buffer);
free(requestContainer);
}
diff --git a/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c b/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c
index b3a8c44ea..9a1a938c0 100644
--- a/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c
+++ b/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c
@@ -340,7 +340,7 @@ void JobRequestFunc(MessageContainer* requestContainer)
size_t container_size = message_container__pack(&responseContainer, container_buffer);
free(responseContainer.data.data);
SendChars((char*)container_buffer, container_size);
- free(container_buffer);
+ //free(container_buffer);
free(requestContainer);
}