コード例 #1
0
void WS2812_PrintBuffer(void){
  if(DMA_Status() != IDLE){        // handle error case where DMA channel is busy
                                   // you can wait for it to finish in the background, but this
                                   // will crash if not initialized, and even if it recovers,
    return;                        // the data will immediately follow and thus not be displayed
  }
  DMA_Transfer((uint8_t *)buffer, 1728, 2); // send 18 LEDs with each ping-pong; send 2 ping-pongs
}
コード例 #2
0
ファイル: main.c プロジェクト: mbangtri/mcuoneclipse
int main(void) {
    uint8_t red, green, blue;

    DMA_Init();
    for (;;) {
        DMA_Transfer(transmitBuf, sizeof(transmitBuf));
    }
    /* Never leave main */
    return 0;
}
コード例 #3
0
ファイル: soundblaster.c プロジェクト: Dimillian/wine
/* SB_Poll performs DMA transfers and fills the Direct Sound Buffer */
static DWORD CALLBACK SB_Poll( void *dummy )
{
    HRESULT result;
    LPBYTE lpbuf1 = NULL;
    LPBYTE lpbuf2 = NULL;
    DWORD dwsize1 = 0;
    DWORD dwsize2 = 0;
    DWORD dwbyteswritten1 = 0;
    DWORD dwbyteswritten2 = 0;
    int size;

    /* FIXME: this loop must be improved */
    while(!end_sound_loop)
    {
        Sleep(10);

        if (dma_enable) {
            size = DMA_Transfer(SB_DMA,min(DMATRFSIZE,SamplesCount),dma_buffer);
        } else
            continue;

        result = IDirectSoundBuffer_Lock(lpdsbuf,buf_off,size,(LPVOID *)&lpbuf1,&dwsize1,(LPVOID *)&lpbuf2,&dwsize2,0);
        if (result != DS_OK) {
	  ERR("Unable to lock sound buffer !\n");
          continue;
        }

        dwbyteswritten1 = min(size,dwsize1);
        memcpy(lpbuf1,dma_buffer,dwbyteswritten1);
        if (size>dwsize1) {
            dwbyteswritten2 = min(size - dwbyteswritten1,dwsize2);
            memcpy(lpbuf2,dma_buffer+dwbyteswritten1,dwbyteswritten2);
        }
        buf_off = (buf_off + dwbyteswritten1 + dwbyteswritten2) % DSBUFLEN;

        result = IDirectSoundBuffer_Unlock(lpdsbuf,lpbuf1,dwbyteswritten1,lpbuf2,dwbyteswritten2);
        if (result!=DS_OK)
	    ERR("Unable to unlock sound buffer !\n");

        SamplesCount -= size;
        if (!SamplesCount) {
            DOSVM_QueueEvent(SB_IRQ,SB_IRQ_PRI,NULL,NULL);
            dma_enable = 0;
        }
    }
    return 0;
}