Subversion Repositories LedShow

Rev

Rev 5 | Rev 7 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5 Rev 6
Line 21... Line 21...
21
 
21
 
22
/* Includes ------------------------------------------------------------------*/
22
/* Includes ------------------------------------------------------------------*/
23
#include "usbd_cdc_if.h"
23
#include "usbd_cdc_if.h"
24
 
24
 
25
/* USER CODE BEGIN INCLUDE */
25
/* USER CODE BEGIN INCLUDE */
26
#include "leds.h"
26
#include "dmx.h"
27
 
27
 
28
/* USER CODE END INCLUDE */
28
/* USER CODE END INCLUDE */
29
 
29
 
30
/* Private typedef -----------------------------------------------------------*/
30
/* Private typedef -----------------------------------------------------------*/
31
/* Private define ------------------------------------------------------------*/
31
/* Private define ------------------------------------------------------------*/
Line 264... Line 264...
264
  * @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL
264
  * @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL
265
  */
265
  */
266
static int8_t CDC_Receive_FS(uint8_t* Buf, uint32_t *Len)
266
static int8_t CDC_Receive_FS(uint8_t* Buf, uint32_t *Len)
267
{
267
{
268
  /* USER CODE BEGIN 6 */
268
  /* USER CODE BEGIN 6 */
269
  switch (DMX_State)
-
 
270
  {
-
 
271
  case  DMX_IDLE:  // nothing happening
-
 
272
          break;
-
 
273
  case DMX_BREAK://
-
 
274
          if(*Len > 0)
-
 
275
          {
-
 
276
                  if( Buf[0] != 0)
-
 
277
                  DMX_State = DMX_IDLE;
-
 
278
                  else
-
 
279
                  {
-
 
280
                          memcpy(DMX_Buffer,Buf+1,*Len-1);
-
 
281
                          DMX_Pointer = *Len-1;
-
 
282
                          DMX_State = DMX_BYTES;
-
 
283
                  }
-
 
284
          }
-
 
285
          break;
-
 
286
  case  DMX_BYTES:
-
 
287
  {
-
 
288
      int count = *Len;
269
   dmx_state(Buf,Len);
289
      int newPointer  = DMX_Pointer + count;
-
 
290
      if(newPointer >= 512)
-
 
291
          count = 512-count;
-
 
292
 
-
 
293
      memcpy(DMX_Buffer+ DMX_Pointer, Buf, count);
-
 
294
      DMX_Pointer += count;
-
 
295
      if (DMX_Pointer == 512)
-
 
296
      {
-
 
297
         DMX_State = DMX_DATA;
-
 
298
      }
-
 
299
  }
-
 
300
  break;
-
 
301
  case DMX_DATA:
-
 
302
  case DMX_DONE:
-
 
303
     break;
-
 
304
  }
-
 
305
 
270
 
306
  USBD_CDC_SetRxBuffer(&hUsbDeviceFS, &Buf[0]);
271
  USBD_CDC_SetRxBuffer(&hUsbDeviceFS, &Buf[0]);
307
  Len =  USBD_CDC_ReceivePacket(&hUsbDeviceFS);
272
  Len =  USBD_CDC_ReceivePacket(&hUsbDeviceFS);
308
  return (USBD_OK);
273
  return (USBD_OK);
309
  /* USER CODE END 6 */
274
  /* USER CODE END 6 */