]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lib.git/commitdiff
Fixed SCI subsystem and inter-layer dependency. Untested.
authorCarlos Jenkins <carlos@jenkins.co.cr>
Thu, 30 May 2013 20:01:18 +0000 (22:01 +0200)
committerCarlos Jenkins <carlos@jenkins.co.cr>
Thu, 30 May 2013 20:01:18 +0000 (22:01 +0200)
rpp/include/sys/ti_drv_sci.h
rpp/src/drv/sci.c
rpp/src/rpp/rpp.c
rpp/src/sys/ti_drv_sci.c

index 9d2b9683e6586176339bf59a7024513f242e8c12..50048608fa922fef1827899f4c17d68a7b86f0b5 100644 (file)
@@ -187,10 +187,5 @@ typedef struct {
     uint8_t flags;         /* Flags */
 } tBuffer;
 
-/** Buffer used for sending to SCI */
-tBuffer outBuffer;
-/** Buffer used for receiving from SCI */
-tBuffer inBuffer;
-
 
 #endif
index f433bb4ebf4af56a2ba8a2b64433345ce1931e77..8f2f55d1c425cf3923750c311453b0abc2e07a7d 100644 (file)
@@ -2,37 +2,28 @@
 
 void drv_sci_init()
 {
-    // Initialize buffers
-    outBuffer.buf   = xQueueCreate(MAX_BUFFER_LEN, sizeof(uint8_t));
-    outBuffer.mutex = xSemaphoreCreateMutex();
-    outBuffer.flags = 0;
-    inBuffer.buf    = xQueueCreate(MAX_BUFFER_LEN, sizeof(uint8_t));
-    inBuffer.mutex  = xSemaphoreCreateMutex();
-    outBuffer.flags = 0;
-
-    // Initialize hal
-    spi_tms570_init();
-
     // Low level init
     sciInit();
 }
 
-
+/** Declared in ti_drv_sci.c */
+extern tBuffer sciOutBuffer;
+extern tBuffer sciInBuffer;
 int8_t drv_sci_send(uint32_t length, uint8_t *data)
 {
-    if(outBuffer.buf == NULL) {
+    if(sciOutBuffer.buf == NULL) {
         return FAILURE;
     }
 
     portBASE_TYPE ret = pdPASS;
-    xSemaphoreTake(outBuffer.mutex, portMAX_DELAY);
+    xSemaphoreTake(sciOutBuffer.mutex, portMAX_DELAY);
 
     while(length-- > 0) {
 
-        if(!outBuffer.flags & BUF_TRANSFER_IN_PROGRESS) {
+        if(!sciOutBuffer.flags & BUF_TRANSFER_IN_PROGRESS) {
                 taskENTER_CRITICAL();
-                if (!outBuffer.flags & BUF_TRANSFER_IN_PROGRESS) {
-                    outBuffer.flags |= BUF_TRANSFER_IN_PROGRESS;
+                if (!sciOutBuffer.flags & BUF_TRANSFER_IN_PROGRESS) {
+                    sciOutBuffer.flags |= BUF_TRANSFER_IN_PROGRESS;
                     sciREG->SETINT = SCI_TX_INT;    // Start new transfer by sending first byte
                     sciREG->TD     = *data++;
                 }
@@ -40,12 +31,12 @@ int8_t drv_sci_send(uint32_t length, uint8_t *data)
                 continue;
         }
 
-        ret = xQueueSend(outBuffer.buf, (void*)data++, portMAX_DELAY);
+        ret = xQueueSend(sciOutBuffer.buf, (void*)data++, portMAX_DELAY);
         if(ret != pdPASS) {
             return FAILURE;
         }
     }
 
-    xSemaphoreGive(outBuffer.mutex);
+    xSemaphoreGive(sciOutBuffer.mutex);
     return SUCCESS;
 }
index b41b53a514350ee53e773f2e8cbe6e63f1848366..9d336ef2310cd0acb334ac580adf00b135d1face 100644 (file)
@@ -106,6 +106,7 @@ int8_t rpp_init() {
     adcInit();
     linInit();
     emif_SDRAMInit();
+    spi_tms570_init();
     _enable_IRQ();
     #endif
 
index 59a43a248fa36a0c9f0ebde6e83d74078626c974..28d3ca8797267bdb54aa9918a157b141f8add4be 100644 (file)
@@ -29,6 +29,12 @@ struct g_sciTransfer
 } g_sciTransfer[2];
 
 
+/** Buffer used for sending to SCI */
+tBuffer sciOutBuffer;
+/** Buffer used for receiving from SCI */
+tBuffer sciInBuffer;
+
+
 /** @fn void sciInit(void)
 *   @brief Initializes the SCI Driver
 *
@@ -39,6 +45,14 @@ void sciInit(void)
 /* USER CODE BEGIN (2) */
 /* USER CODE END */
 
+    /** Initialise buffers */
+    sciOutBuffer.buf   = xQueueCreate(MAX_BUFFER_LEN, sizeof(uint8_t));
+    sciOutBuffer.mutex = xSemaphoreCreateMutex();
+    sciOutBuffer.flags = 0;
+    sciOutBuffer.buf    = xQueueCreate(MAX_BUFFER_LEN, sizeof(uint8_t));
+    sciOutBuffer.mutex  = xSemaphoreCreateMutex();
+    sciOutBuffer.flags = 0;
+
     /** @b intalise @b SCI */
 
     /** - bring SCI out of reset */
@@ -487,7 +501,7 @@ void sciHighLevelInterrupt(void)
     case 11:
         // receive
         {   uint8_t byte = sciREG->RD;
-            if (xQueueSendFromISR(inBuffer.buf, (void*)&byte, NULL) == errQUEUE_FULL) {
+            if (xQueueSendFromISR(sciOutBuffer.buf, (void*)&byte, NULL) == errQUEUE_FULL) {
                 receiveError++;
             }
             sciNotification(sciREG, SCI_RX_INT);
@@ -498,9 +512,9 @@ void sciHighLevelInterrupt(void)
         // transmit
         {
             uint8_t byte = 0;
-            if (xQueueReceiveFromISR(outBuffer.buf, (uint8_t *)&byte, NULL) == errQUEUE_EMPTY) {
+            if (xQueueReceiveFromISR(sciOutBuffer.buf, (uint8_t *)&byte, NULL) == errQUEUE_EMPTY) {
                 sciREG->CLRINT = SCI_TX_INT;
-                outBuffer.flags &= ~BUF_TRANSFER_IN_PROGRESS;
+                sciOutBuffer.flags &= ~BUF_TRANSFER_IN_PROGRESS;
             }
             else {
                 sciREG->TD     = byte;