int main(int ac, char **av) { int i, l, l1, l2; USB_Open(); // We send bytes one by one - not very efficient from the USB point of view, but keeps // things simple // For commands, it's ok to send 2 bytes at once because the first one (0x00) is not sent // to the LCD module but is just there to indicate that the second byte is a command to the LCD // Remember, the PC is little-endian, so that's 0x00 followed by 0x38 !! USB_WriteWord(0x3800); // 8 bits USB_WriteWord(0x0F00); // cursor ON USB_WriteWord(0x0100); // clear screen Sleep(2); l = strlen(av[1]); l1 = (l > 20 ? 20 : l); // Send text for (i = 0 ; i < l1 ; i++) USB_WriteChar(av[1][i]); if (l > 20) { // next line USB_WriteWord(0xC000); for ( ; i < l ; i++) USB_WriteChar(av[1][i]); } USB_Close(); }
ProjectorLC4500::~ProjectorLC4500(){ // Stop pattern sequence LCR_PatternDisplay(0); USB_Close(); USB_Exit(); }
/** * Close the interface and free all allocated resources * * @param ctn Card terminal number * @return Status code \ref OK, \ref ERR_INVALID, \ref ERR_CT, \ref ERR_TRANS, \ref ERR_MEMORY, \ref ERR_HOST, \ref ERR_HTSI */ signed char CT_close(unsigned short ctn) { int rc; scr_t *ctx; if (mutex_lock(&globalmutex) != 0) { return ERR_CT; } rc = LookupReader(ctn); if (rc < 0) { mutex_unlock(&globalmutex); return ERR_CT; } ctx = readerTable[rc]; if (!ctx) { mutex_unlock(&globalmutex); return ERR_CT; } if (ctx->t1) { ccidT1Term(ctx); } USB_Close(&ctx->device); mutex_destroy(&ctx->mutex); free(ctx); readerTable[rc] = NULL; if (mutex_unlock(&globalmutex) != 0) { return ERR_CT; } mutexInitialized--; if (!mutexInitialized) { mutex_destroy(&globalmutex); } return OK; }
/** * Close the interface and free all allocated resources * * @param ctn Card terminal number * @return Status code \ref OK, \ref ERR_INVALID, \ref ERR_CT, \ref ERR_TRANS, \ref ERR_MEMORY, \ref ERR_HOST, \ref ERR_HTSI */ signed char CT_close(unsigned short ctn) { int rc; scr_t *ctx; if (mutex_lock(&mutex) != 0) { return ERR_MUTEX; } rc = LookupReader(ctn); if (rc < 0) { mutex_unlock(&mutex); return ERR_CT; } ctx = readerTable[rc]; if (!ctx) { mutex_unlock(&mutex); return ERR_CT; } if (ctx->t1) { ccidT1Term(ctx); } USB_Close(&ctx->device); mutex_destroy(&ctx->mutex); free(ctx); readerTable[rc] = NULL; if (mutex_unlock(&mutex) != 0) { return ERR_MUTEX; } if (InterlockedDecrement(&mutex_refcnt) == 0) { safe_mutex_destroy(); } return OK; }
int main() { unsigned char c = 0x55; USB_Open(); //USB_WriteWord(0x0100); //USB_WriteChar('D'); //USB_WriteChar(c); //printf("W: 0x%02x\r\n", c); while(1) { if(kbhit()) break; c = USB_Read(); printf("R: 0x%02x\r\n", c); Sleep(200); } USB_Close(); }