/* * The DeviceControl function should not need to be changed * except to remove ErrorFs */ static Bool DeviceControl (DeviceIntPtr dev, int mode) { Bool RetValue; /* ErrorF ("DeviceControl called mode = %d\n", mode);*/ switch (mode) { case DEVICE_INIT: /* ErrorF ("\tINIT\n");*/ DeviceInit (dev); RetValue = Success; break; case DEVICE_ON: /* ErrorF ("\tON\n");*/ RetValue = DeviceOn( dev ); break; case DEVICE_OFF: /* ErrorF ("\tOFF\n");*/ RetValue = DeviceOff( dev ); break; case DEVICE_CLOSE: /* ErrorF ("\tCLOSE\n");*/ RetValue = DeviceClose( dev ); break; default: ErrorF ("\tBAD MODE\n"); RetValue = BadValue; } return( RetValue ); }
int main(void) { BYTE stBtn1; BYTE stBtn2; DeviceInit(); AppInit(); while(stBtn1!=stPressed && stBtn2!=stPressed) { mT5IntEnable(fFalse); stBtn1 = btnBtn1.stBtn; stBtn2 = btnBtn2.stBtn; mT5IntEnable(fTrue); } RightReverse; LeftReverse; SetLeftSpeed(dtcMtrMedium); SetRightSpeed(dtcMtrMedium); mCNIntEnable(fTrue); //Sensors will trigger while(fTrue); }
int FTDIDevice_Open(FTDIDevice *dev) { int err; memset(dev, 0, sizeof *dev); if ((err = libusb_init(&dev->libusb))) { return err; } libusb_set_debug(dev->libusb, 2); dev->handle = libusb_open_device_with_vid_pid(dev->libusb, OV_VENDOR, OV_PRODUCT); if (!dev->handle) { dev->handle = libusb_open_device_with_vid_pid(dev->libusb, FTDI_VENDOR, FTDI_PRODUCT_FT2232H); } if (!dev->handle) { return LIBUSB_ERROR_NO_DEVICE; } return DeviceInit(dev); }
void KernelMain() { EarlyConsoleInit(); ArchInit(); ThrEarlyInit(); TimeInit(); ShutdownInit(); /* Set up the device-related subsystems. */ IcInit(); /* Once we've set up the ICFS framework, there are several * areas of Whitix (like the slab code) that need to expose * their internal information. */ SlabInfoInit(); ModuleInfoInit(); ThrInit(); VfsInit(); DevFsInit(); DeviceInit(); MiscInit(); LoadInit(); StartInit(); /* This is where the idle thread idles, after returning from StartInit in startup.c */ ThrIdleFunc(); }
int main() { //Set LD1 through LD4 as digital output DeviceInit(); //initialize timer for delay DelayInit(); /* Perform the main application loop. */ while (1) { //drive LD1 high PORTWrite (IOPORT_B, BIT_10); DelayMs(1); //drive LD2 high PORTWrite (IOPORT_B, BIT_11); DelayMs(1); //drive LD3 high PORTWrite (IOPORT_B, BIT_12); DelayMs(1); //drive LD4 high PORTWrite (IOPORT_B, BIT_13); DelayMs(1); } }
NTSTATUS CUsbDkFilterDevice::Create(PWDFDEVICE_INIT DevInit) { CUsbDkFilterDeviceInit DeviceInit(DevInit); TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_FILTERDEVICE, "%!FUNC! Entry"); auto status = DeviceInit.Configure(GetInstanceNumber()); if (!NT_SUCCESS(status)) { TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_FILTERDEVICE, "%!FUNC! Failed to create device init"); return status; } WDF_OBJECT_ATTRIBUTES attr; WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attr, USBDK_FILTER_DEVICE_EXTENSION); attr.EvtCleanupCallback = CUsbDkFilterDevice::ContextCleanup; status = CWdfDevice::Create(DeviceInit, attr); if (!NT_SUCCESS(status)) { TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_FILTERDEVICE, "%!FUNC! Failed to create device"); return status; } auto deviceContext = UsbDkFilterGetContext(m_Device); deviceContext->UsbDkFilter = this; return STATUS_SUCCESS; }
Hameg8143::Hameg8143( const ioport_t ioPort ) :VHameg8143(ioPort), isDeviceAvailable_(false) { comHandler_ = new HO820ComHandler( ioPort ); DeviceInit(); }
ViStatus _VI_FUNC viOpen (ViSession sesn, ViRsrc name, ViAccessMode mode, ViUInt32 timeout, ViPSession vi) { PLX_DEVICE_KEY DevKey; PLX_DEVICE_OBJECT *Device=malloc(sizeof(PLX_DEVICE_OBJECT)); BOOLEAN IsInitOk; PLX_STATUS rc; IsInitOk = DeviceInit(&DevKey); if(IsInitOk) { rc = PlxPci_DeviceOpen(&DevKey, Device); if(rc != ApiSuccess) return VI_ERROR_ALLOC; else { *vi = (ViSession)Device; return VI_SUCCESS; } } else { return VI_ERROR_ALLOC; } }
int main(void) { int PWM_Freq = 1000; DeviceInit(); while(1) { if((read(button_fd, read_button, sizeof(read_button))) != sizeof(read_button)) { printf("Can not read buttons device\n"); exit(1); } else { if(read_button[0]=='1') { PWM_Freq += 50; SetBuzzerFrequency(PWM_Freq); } else if (read_button[1] == '1') { PWM_Freq -= 50; SetBuzzerFrequency(PWM_Freq); } } } close(pwm_fd); close(button_fd); }
KeyenceFake::KeyenceFake( const ioport_t ioPort ) :VKeyence(ioPort), isDeviceAvailable_(false) { samplingRate_ = 20; averagingRate_ = 1; comHandler_ = new KeyenceComHandler( ioPort ); DeviceInit(); }
void DeviceBoxDisplay() { char templine[256]; HWND itemptr; int itemcount; // Adjust Window Position? SetDlgItemText(deviceboxwindow, IDC_0302, conf.devicename); // DeviceBoxDeviceEvent(); // Needed? GetDlgItemText(mainboxwindow, IDC_0202, templine, 256); SetDlgItemText(deviceboxwindow, IDC_0305, templine); // DeviceBoxFileEvent(); // Needed? itemptr = GetDlgItem(deviceboxwindow, IDC_0309); // Compression Combo itemcount = 0; while(compressnames[itemcount] != NULL) { ComboBox_AddString(itemptr, compressnames[itemcount]); itemcount++; } // ENDWHILE- loading compression types into combo box ComboBox_SetCurSel(itemptr, 0); // First Selection? itemptr = NULL; CheckDlgButton(deviceboxwindow, IDC_0311, FALSE); // Start unchecked DeviceInit(); // Initialize device access } // END DeviceBoxDisplay()
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ret = DeviceInit(); BroadCast(); ui->setupUi(this); //addTableItem("test", 0, 0, "tfc"); MainListSet(); }
int FTDIDevice_Reset(FTDIDevice *dev) { int err; err = libusb_reset_device(dev->handle); if (err) return err; return DeviceInit(dev); }
LeyboldGraphixThree::LeyboldGraphixThree( const ioport_t ioPort ) :VLeyboldGraphixThree(ioPort), isDeviceAvailable_(false) { comHandler_ = new LeyboldComHandler( ioPort ); DeviceInit(); sensorStatus_[0] = SensorStatus_unknown; sensorStatus_[1] = SensorStatus_unknown; sensorStatus_[2] = SensorStatus_unknown; }
int FTDIDevice_Reset(FTDIDevice *dev) { int err; int interface; err = libusb_reset_device(dev->handle); if (!err) err = DeviceRelease(dev); if (err) return err; return DeviceInit(dev); }
GRSurface* MinuiBackendAdf::Init() { #if defined(RECOVERY_ABGR) format = DRM_FORMAT_ABGR8888; #elif defined(RECOVERY_BGRA) format = DRM_FORMAT_BGRA8888; #elif defined(RECOVERY_RGBX) format = DRM_FORMAT_RGBX8888; #else format = DRM_FORMAT_RGB565; #endif adf_id_t* dev_ids = nullptr; ssize_t n_dev_ids = adf_devices(&dev_ids); if (n_dev_ids == 0) { return nullptr; } else if (n_dev_ids < 0) { fprintf(stderr, "enumerating adf devices failed: %s\n", strerror(-n_dev_ids)); return nullptr; } intf_fd = -1; for (ssize_t i = 0; i < n_dev_ids && intf_fd < 0; i++) { int err = adf_device_open(dev_ids[i], O_RDWR, &dev); if (err < 0) { fprintf(stderr, "opening adf device %u failed: %s\n", dev_ids[i], strerror(-err)); continue; } err = DeviceInit(&dev); if (err < 0) { fprintf(stderr, "initializing adf device %u failed: %s\n", dev_ids[i], strerror(-err)); adf_device_close(&dev); } } free(dev_ids); if (intf_fd < 0) return nullptr; GRSurface* ret = Flip(); Blank(true); Blank(false); return ret; }
void setup(){ //run once initialization code here, i.e. OledInit() will probably go here DeviceInit(); score=0; showStrtScrn(); calibratedAccel=getAccelY(); switch(CheckSwitches()){ case 0: maxBullet=5;break; case 1: maxBullet=4;break; case 2:maxBullet=3;break; case 3: maxBullet=2;break; default: maxBullet=5; }; lives=4; updateLED(lives); initStuff(); OrbitOledClear(); OrbitOledSetFillPattern(OrbitOledGetStdPattern(1)); }
/********************************************************************* * Function: void ResetDevice() * * PreCondition: none * * Input: none * * Output: none * * Side Effects: none * * Overview: resets LCD, initializes PMP * * Note: none * ********************************************************************/ void ResetDevice(void) { // Initialize device DeviceInit(); // Enable LCD DeviceSelect(); // Setup display DeviceSetCommand() DeviceWrite(CMD_DISPON); DeviceWrite(CMD_MODE); DeviceSetData(); DeviceWrite(0x74); DeviceSetCommand(); DeviceWrite(CMD_SRTLINE); DeviceSetData(); DeviceWrite(128); // Disable LCD DeviceDeselect(); }
/* * Main */ int main(int argc, char* argv[]) { GetOpts(argc, argv); Fork(); SetProcessFlags(); rand_initialize(); DeviceInit(); FdInit(); AttachPrefix("/dev/random", UNIT_RANDOM); AttachPrefix("/dev/urandom", UNIT_URANDOM); HookIrqs(); Daemonize(); return Loop(); }
//###########################################################################// // MAIN ROUTINE // //###########################################################################// // void main(void) { // --- Initialisation // _SOURCE_ DeviceInit(); // DeviceInit.c GpioInit(); // GpioInit.c PwmInit(); // PwmInit.c CpuTimer0Regs.PRD.all = mSec100; // Flag CpuTimer0 every 100ms [100ms*2 (# of LED states) = 0.2s blink rate] // --- Infinite Loop while(1) { if(CpuTimer0Regs.TCR.bit.TIF == 1) // Flag check { CpuTimer0Regs.TCR.bit.TIF = 1; // Clear flag GpioDataRegs.GPBTOGGLE.bit.GPIO34 = 1; // Toggle GPIO34 (LED) } } }
void main(void) { EALLOW; DeviceInit(); // Device Life support & GPIO mux settings initControlValueStructures(); // Enable ADCINT1 in PIE IER |= M_INT1; // Enable CPU Interrupt 1 PieCtrlRegs.PIEIER1.bit.INTx1 = 1; // Enable INT 1.1 in the PIE PieCtrlRegs.PIEIER1.bit.INTx7 = 1; // Enable TINT0 in the PIE: Group 1 interrupt 7 EINT; // Enable Global interrupt INTM ERTM; // Enable Global realtime interrupt DBGM i2c_force_stop(); InitTermVars(); for(;;) { Serial_mng(); bbx_background(); } }
/* user main function, called by AppFramework after system init done && wifi * station on in user_main thread. */ OSStatus user_main( app_context_t * const app_context ) { user_log_trace(); OSStatus err = kUnknownErr; unsigned char rdata[64]; unsigned char sdata[64]; uint16_t datalen; require(app_context, exit); // platform initialize AaSysComInit(); AaSysLogInit(); // application initialize ControllerBusInit(); OuterTriggerInit(NULL); TemperatureInit(); // will be support in release 2 BatteryInit(); // reset f411 and wait until it startup ResetF411(); #if 1 MOInit(); #endif err = SntpInit(app_context); if(kNoErr != err) { AaSysLogPrint(LOGLEVEL_ERR, "SntpInit finished with err code %d", err); } else { AaSysLogPrint(LOGLEVEL_INF, "SntpInit success"); } #if 1 DeviceInit(app_context); HealthInit(app_context); LightsInit(app_context); MusicInit(app_context); // start the downstream thread to handle user command err = mico_rtos_create_thread(&user_downstrem_thread_handle, MICO_APPLICATION_PRIORITY, "user_downstream", user_downstream_thread, STACK_SIZE_USER_DOWNSTREAM_THREAD, app_context ); require_noerr_action( err, exit, user_log("ERROR: create user_downstream thread failed!") ); #endif user_log("[DBG]net_main: Appilcation Initialize success @"SOFTWAREVERSION); // user_main loop, update oled display every 1s while(1){ #if 1 mico_thread_sleep(MICO_WAIT_FOREVER); #else mico_thread_sleep(5); datalen = user_uartRecv(rdata, 5); if(datalen) { user_log("[DBG]user_main: Usart recevice datalen %d", datalen); user_log("[DBG]user_main: receive %.*s", datalen, rdata); } else { user_log("[DBG]user_main: Usart didn't recevice data"); } mico_thread_sleep(2); sprintf(sdata, "hello, world!\r\n"); user_uartSend(sdata, strlen(sdata)); #endif } exit: if(kNoErr != err){ user_log("[ERR]user_main: user_main thread exit with err=%d", err); } mico_rtos_delete_thread(NULL); // delete current thread return err; }
/********************************************************************* * Function: void ResetDevice() * * PreCondition: none * * Input: none * * Output: none * * Side Effects: none * * Overview: resets LCD, initializes PMP * * Note: none * ********************************************************************/ void ResetDevice(void) { // Initialize the device DeviceInit(); #if (DISPLAY_CONTROLLER == HX8347A) // Gamma for CMO 2.8 SetReg(0x46, 0x95); // SetReg(0x47, 0x51); // SetReg(0x48, 0x00); // SetReg(0x49, 0x36); // SetReg(0x4A, 0x11); // SetReg(0x4B, 0x66); // SetReg(0x4C, 0x14); // SetReg(0x4D, 0x77); // SetReg(0x4E, 0x13); // SetReg(0x4F, 0x4C); // SetReg(0x50, 0x46); // SetReg(0x51, 0x46); // // Display SetReg(0x90, 0x7F); // SAP=0111 1111 SetReg(0x01, 0x06); // IDMON=0, INVON=1, NORON=1, PTLON=0 #if (DISP_ORIENTATION == 0) SetReg(0x16, 0xC8); // MY=1, MX=1, MV=0, BGR=1 #else SetReg(0x16, 0xA8); // MY=1, MX=0, MV=1, BGR=1 #endif SetReg(0x23, 0x95); // N_DC=1001 0101 SetReg(0x24, 0x95); // P_DC=1001 0101 SetReg(0x25, 0xFF); // I_DC=1111 1111 SetReg(0x27, 0x06); // N_BP=0000 0110 SetReg(0x28, 0x06); // N_FP=0000 0110 SetReg(0x29, 0x06); // P_BP=0000 0110 SetReg(0x2A, 0x06); // P_FP=0000 0110 SetReg(0x2C, 0x06); // I_BP=0000 0110 SetReg(0x2D, 0x06); // I_FP=0000 0110 SetReg(0x3A, 0x01); // N_RTN=0000, N_NW=001 SetReg(0x3B, 0x01); // P_RTN=0000, P_NW=001 SetReg(0x3C, 0xF0); // I_RTN=1111, I_NW=000 SetReg(0x3D, 0x00); // DIV=00 DelayMs(20); SetReg(0x10, 0xA6); // SS=0,GS=0 CSEL=110 // Power Supply Setting SetReg(0x19, 0x49); // OSCADJ=10 0000, OSD_EN=1 //60Hz SetReg(0x93, 0x0C); // RADJ=1100, DelayMs(10); SetReg(0x20, 0x40); // BT=0100 SetReg(0x1D, 0x07); // VC1=111 SetReg(0x1E, 0x00); // VC3=000 SetReg(0x1F, 0x04); // VRH=0100 4.12V SetReg(0x44, 0x4D); // VCM=101 0000 3.21V SetReg(0x45, 0x11); // VDV=1 0001 -1.19V DelayMs(10); SetReg(0x1C, 0x04); // AP=100 DelayMs(20); SetReg(0x43, 0x80); //set VCOMG=1 DelayMs(5); SetReg(0x1B, 0x18); // GASENB=0, PON=1, DK=1, XDK=0, DDVDH_TRI=0, STB=0 DelayMs(40); SetReg(0x1B, 0x10); // GASENB=0, PON=1, DK=0, XDK=0, DDVDH_TRI=0, STB=0 DelayMs(40); // Display ON Setting SetReg(0x26, 0x04); // GON=0, DTE=0, D=01 DelayMs(40); SetReg(0x26, 0x24); // GON=1, DTE=0, D=01 SetReg(0x26, 0x2C); // GON=1, DTE=0, D=11 DelayMs(40); SetReg(0x26, 0x3C); // GON=1, DTE=1, D=11 SetReg(0x35, 0x38); // EQS=38h SetReg(0x36, 0x78); // EQP=78h SetReg(0x3E, 0x38); // SON=38h SetReg(0x40, 0x0F); // GDON=0Fh SetReg(0x41, 0xF0); // GDOFF // Set spulse & rpulse SetReg(0x57, 0x02); // Test mode='1' SetReg(0x56, 0x84); // set Rpulse='1000',spulse='0100' SetReg(0x57, 0x00); // Test mode= '0' #if (DISP_ORIENTATION == 0) SetReg(0x04, 0x00); SetReg(0x05, 0xEF); SetReg(0x08, 0x01); SetReg(0x09, 0x3F); #else SetReg(0x04, 0x01); SetReg(0x05, 0x3F); SetReg(0x08, 0x00); SetReg(0x09, 0xEF); #endif DelayMs(20); #elif (DISPLAY_CONTROLLER == HX8347D) // Driving ability setting SetReg(0xEA,0x00); // PTBA[15:8] SetReg(0xEB,0x20); // PTBA[7:0] SetReg(0xEC,0x0C); // STBA[15:8] SetReg(0xED,0xC4); // STBA[7:0] SetReg(0xE8,0x40); // OPON[7:0] SetReg(0xE9,0x38); // OPON1[7:0] SetReg(0xF1,0x01); // OTPS1B SetReg(0xF2,0x10); // GEN SetReg(0x27,0xA3); // // Gamma 2.8 setting SetReg(0x40,0x00); // SetReg(0x41,0x00); // SetReg(0x42,0x01); // SetReg(0x43,0x13); // SetReg(0x44,0x10); // SetReg(0x45,0x26); // SetReg(0x46,0x08); // SetReg(0x47,0x51); // SetReg(0x48,0x02); // SetReg(0x49,0x12); // SetReg(0x4A,0x18); // SetReg(0x4B,0x19); // SetReg(0x4C,0x14); // SetReg(0x50,0x19); // SetReg(0x51,0x2F); // SetReg(0x52,0x2C); // SetReg(0x53,0x3E); // SetReg(0x54,0x3F); // SetReg(0x55,0x3F); // SetReg(0x56,0x2E); // SetReg(0x57,0x77); // SetReg(0x58,0x0B); // SetReg(0x59,0x06); // SetReg(0x5A,0x07); // SetReg(0x5B,0x0D); // SetReg(0x5C,0x1D); // SetReg(0x5D,0xCC); // // Window setting #if (DISP_ORIENTATION == 0) SetReg(0x04,0x00); SetReg(0x05,0xEF); SetReg(0x08,0x01); SetReg(0x09,0x3F); #else SetReg(0x04,0x01); SetReg(0x05,0x3F); SetReg(0x08,0x00); SetReg(0x09,0xEF); #endif // Display Setting //SetReg(0x01,0x06); // IDMON=0, INVON=1, NORON=1, PTLON=0 #if (DISP_ORIENTATION == 0) SetReg(0x16,0x08); // MY=0, MX=0, MV=0, BGR=1 #else SetReg(0x16,0x68); // MY=0, MX=1, MV=1, BGR=1 #endif // Power Voltage Setting SetReg(0x1B,0x1B); // VRH = 4.65 SetReg(0x1A,0x01); // BT SetReg(0x24,0x2F); // VMH SetReg(0x25,0x57); // VML // Vcom offset SetReg(0x23,0x8D); // FLICKER ADJUST // Power ON Setting SetReg(0x18,0x36); // SetReg(0x19,0x01); // SetReg(0x01,0x00); // SetReg(0x1F,0x88); // DelayMs(5); SetReg(0x1F,0x80); // DelayMs(5); SetReg(0x1F,0x90); // DelayMs(5); SetReg(0x1F,0xD0); // DelayMs(5); // 65K Color Selection SetReg(0x17,0x05); // // Set Panel SetReg(0x36,0x00); // // Display ON Setting SetReg(0x28,0x38); // DelayMs( 40); SetReg(0x28,0x3C); // #endif }
//***************************************************************************** // // Capture one sequence of DEVCTL register values during a session request. // //***************************************************************************** int main(void) { tRectangle sRect; // // Set the clocking to run directly from the crystal. // ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); // // Set the pinout appropriately for this board. // PinoutSet(); // // Initialize the display driver. // Kitronix320x240x16_SSD2119Init(); // // Initialize the graphics context. // GrContextInit(&g_sContext, &g_sKitronix320x240x16_SSD2119); // // Fill the top 15 rows of the screen with blue to create the banner. // sRect.sXMin = 0; sRect.sYMin = 0; sRect.sXMax = GrContextDpyWidthGet(&g_sContext) - 1; sRect.sYMax = 14; GrContextForegroundSet(&g_sContext, ClrDarkBlue); GrRectFill(&g_sContext, &sRect); // // Put a white box around the banner. // GrContextForegroundSet(&g_sContext, ClrWhite); GrRectDraw(&g_sContext, &sRect); // // Put the application name in the middle of the banner. // GrContextFontSet(&g_sContext, g_pFontFixed6x8); GrStringDrawCentered(&g_sContext, "OTG Example", -1, GrContextDpyWidthGet(&g_sContext) / 2, 7, 0); #ifdef DEBUG // // Configure the relevant pins such that UART0 owns them. // ROM_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1); // // Open the UART for I/O // UARTStdioInit(0); #endif // // Determine the number of SysCtlDelay loops required to delay 1mS. // g_ulClockMS = ROM_SysCtlClockGet() / (3 * 1000); // // Configure the required pins for USB operation. // ROM_GPIOPinTypeUSBDigital(GPIO_PORTA_BASE, GPIO_PIN_6 | GPIO_PIN_7); ROM_GPIOPinTypeUSBDigital(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1); // // Initialize the USB stack mode and pass in a mode callback. // USBStackModeSet(0, USB_MODE_OTG, ModeCallback); // // Initialize the host stack. // HostInit(); // // Initialize the device stack. // DeviceInit(); // // Initialize the USB controller for dual mode operation with a 2ms polling // rate. // USBOTGModeInit(0, 2000, g_pHCDPool, HCD_MEMORY_SIZE); // // Set the new state so that the screen updates on the first // pass. // g_ulNewState = 1; // // Loop forever. // while(1) { // // Tell the OTG library code how much time has passed in milliseconds // since the last call. // USBOTGMain(GetTickms()); // // Handle deferred state change. // if(g_ulNewState) { g_ulNewState =0; // // Update the status area of the screen. // ClearMainWindow(); // // Update the status bar with the new mode. // switch(g_eCurrentUSBMode) { case USB_MODE_HOST: { UpdateStatus("Host Mode", 0, true); break; } case USB_MODE_DEVICE: { UpdateStatus("Device Mode", 0, true); break; } case USB_MODE_NONE: { UpdateStatus("Idle Mode", 0, true); break; } default: { break; } } } if(g_eCurrentUSBMode == USB_MODE_DEVICE) { DeviceMain(); } else if(g_eCurrentUSBMode == USB_MODE_HOST) { HostMain(); } } }
//***************************************************************************** // // main routine. // //***************************************************************************** int main(void) { tLPMFeature sLPMFeature; // // Run from the PLL at 120 MHz. // g_ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120000000); // // Configure the device pins. // PinoutSet(); // // Configure the UART. // UARTStdioConfig(0, 115200, g_ui32SysClock); // // Initialize the display driver. // Kentec320x240x16_SSD2119Init(g_ui32SysClock); // // Initialize the graphics context. // GrContextInit(&g_sContext, &g_sKentec320x240x16_SSD2119); // // Draw the application frame. // FrameDraw(&g_sContext, "usb-otg-mouse"); // // Configure USB for OTG operation. // USBOTGInit(g_ui32SysClock, ModeCallback); sLPMFeature.ui32HIRD = 500; sLPMFeature.ui32Features = USBLIB_FEATURE_LPM_EN | USBLIB_FEATURE_LPM_RMT_WAKE; USBHCDFeatureSet(0, USBLIB_FEATURE_LPM, &sLPMFeature); // // Initialize the host stack. // HostInit(); // // Initialize the device stack. // DeviceInit(); // // Initialize the USB controller for dual mode operation with a 2ms polling // rate. // USBOTGModeInit(0, 2000, g_pui8HCDPool, HCD_MEMORY_SIZE); // // Set the new state so that the screen updates on the first // pass. // g_ui32NewState = 1; // // Loop forever. // while(1) { // // Tell the OTG library code how much time has passed in milliseconds // since the last call. // USBOTGMain(GetTickms()); // // Handle deferred state change. // if(g_ui32NewState) { g_ui32NewState =0; // // Update the status area of the screen. // ClearMainWindow(); // // Update the status bar with the new mode. // switch(g_iCurrentMode) { case eUSBModeHost: { UpdateStatus("Host Mode", 0, true); break; } case eUSBModeDevice: { UpdateStatus("Device Mode", 0, true); break; } case eUSBModeNone: { UpdateStatus("Idle Mode\n", 0, true); break; } default: { break; } } } if(g_iCurrentMode == eUSBModeDevice) { DeviceMain(); } else if(g_iCurrentMode == eUSBModeHost) { HostMain(); } } }
void main(void) { DeviceInit(); // Device Life support & GPIO // Only used if running from FLASH // Note that the variable FLASH is defined by the compiler #ifdef FLASH // Copy time critical code and Flash setup code to RAM // The RamfuncsLoadStart, RamfuncsLoadEnd, and RamfuncsRunStart // symbols are created by the linker. Refer to the linker files. MemCopy(&RamfuncsLoadStart, &RamfuncsLoadEnd, &RamfuncsRunStart); // Call Flash Initialization to setup flash waitstates // This function must reside in RAM InitFlash(); // Call the flash wrapper init function #endif //(FLASH) // Waiting for enable flag set while (EnableFlag==FALSE) { BackTicker++; } // Timing sync for slow background tasks // Timer period definitions found in device specific PeripheralHeaderIncludes.h CpuTimer0Regs.PRD.all = mSec1; // A tasks CpuTimer1Regs.PRD.all = mSec5; // B tasks CpuTimer2Regs.PRD.all = mSec50; // C tasks // Tasks State-machine init Alpha_State_Ptr = &A0; A_Task_Ptr = &A1; B_Task_Ptr = &B1; C_Task_Ptr = &C1; // Initialize PWM module pwm1.PeriodMax = SYSTEM_FREQUENCY*1000000*T/2; // Prescaler X1 (T1), ISR period = T x 1 PWM_INIT_MACRO(pwm1) pwm2.PeriodMax = SYSTEM_FREQUENCY*1000000*T/2; // Prescaler X1 (T1), ISR period = T x 1 PWM_INIT_MACRO(pwm2) // Initialize PWMDAC module pwmdac1.PeriodMax = 500; // @60Mhz: 1500->20kHz, 1000-> 30kHz, 500->60kHz pwmdac1.PwmDacInPointer0 = &PwmDacCh1; pwmdac1.PwmDacInPointer1 = &PwmDacCh2; PWMDAC_INIT_MACRO(pwmdac1) // Initialize DATALOG module dlog.iptr1 = &DlogCh1; dlog.iptr2 = &DlogCh2; dlog.iptr3 = &DlogCh3; dlog.iptr4 = &DlogCh4; dlog.trig_value = 0x1; dlog.size = 0x00c8; dlog.prescalar = 5; dlog.init(&dlog); // Initialize ADC module ADC_MACRO_INIT() // Initialize the PID_REG3 module for I pid1_i.Kp = _IQ(0.318); //for 24V DC bus pid1_i.Ki = _IQ(T/0.0005); pid1_i.Kd = _IQ(0/T); pid1_i.Kc = _IQ(0.2); pid1_i.OutMax = _IQ(0.95); pid1_i.OutMin = _IQ(-0.95); pid2_i.Kp = _IQ(0.318); //for 24V DC bus pid2_i.Ki = _IQ(T/0.0005); pid2_i.Kd = _IQ(0/T); pid2_i.Kc = _IQ(0.2); pid2_i.OutMax = _IQ(0.95); pid2_i.OutMin = _IQ(-0.95); // Reassign ISRs. EALLOW; // This is needed to write to EALLOW protected registers PieVectTable.EPWM1_INT = &MainISR; EDIS; // Enable PIE group 3 interrupt 1 for EPWM1_INT PieCtrlRegs.PIEIER3.bit.INTx1 = 1; // Enable CNT_zero interrupt using EPWM1 Time-base EPwm1Regs.ETSEL.bit.INTEN = 1; // Enable EPWM1INT generation EPwm1Regs.ETSEL.bit.INTSEL = 1; // Enable interrupt CNT_zero event EPwm1Regs.ETPS.bit.INTPRD = 1; // Generate interrupt on the 1st event EPwm1Regs.ETCLR.bit.INT = 1; // Enable more interrupts // Enable CPU INT3 for EPWM1_INT: IER |= M_INT3; // Enable global Interrupts and higher priority real-time debug events: EINT; // Enable Global interrupt INTM ERTM; // Enable Global realtime interrupt DBGM // IDLE loop. Just sit and loop forever: for(;;) //infinite loop { // State machine entry & exit point //=========================================================== (*Alpha_State_Ptr)(); // jump to an Alpha state (A0,B0,...) //=========================================================== //Put the DRV chip in RESET if we want the power stage inactive if(DRV_RESET) { GpioDataRegs.GPACLEAR.bit.GPIO19 = 1; GpioDataRegs.GPBCLEAR.bit.GPIO32 = 1; } else { GpioDataRegs.GPASET.bit.GPIO19 = 1; GpioDataRegs.GPBSET.bit.GPIO32 = 1; } } } //END MAIN CODE
void DeviceBoxDisplay() { GtkWidget *item; GtkWidget *hbox1; GtkWidget *vbox1; int nameptr; devicebox.window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_container_set_border_width(GTK_CONTAINER(devicebox.window), 5); gtk_window_set_title(GTK_WINDOW(devicebox.window), "CDVDisoEFP ISO Creation"); gtk_window_set_position(GTK_WINDOW(devicebox.window), GTK_WIN_POS_CENTER); g_signal_connect(G_OBJECT(devicebox.window), "delete_event", G_CALLBACK(DeviceBoxCancelEvent), NULL); vbox1 = gtk_vbox_new(FALSE, 5); gtk_container_add(GTK_CONTAINER(devicebox.window), vbox1); gtk_container_set_border_width(GTK_CONTAINER(vbox1), 5); gtk_widget_show(vbox1); hbox1 = gtk_hbox_new(FALSE, 10); gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0); gtk_widget_show(hbox1); item = gtk_label_new("Source CD/DVD Device:"); gtk_box_pack_start(GTK_BOX(hbox1), item, FALSE, FALSE, 0); gtk_widget_show(item); item = NULL; devicebox.device = gtk_entry_new(); gtk_box_pack_start(GTK_BOX(hbox1), devicebox.device, TRUE, TRUE, 0); gtk_widget_show(devicebox.device); g_signal_connect(G_OBJECT(devicebox.device), "changed", G_CALLBACK(DeviceBoxDeviceEvent), NULL); hbox1 = NULL; devicebox.devicedesc = gtk_label_new("Device Type: ---"); gtk_box_pack_start(GTK_BOX(vbox1), devicebox.devicedesc, FALSE, FALSE, 0); gtk_widget_show(devicebox.devicedesc); item = gtk_hseparator_new(); gtk_box_pack_start(GTK_BOX(vbox1), item, TRUE, TRUE, 0); gtk_widget_show(item); item = NULL; hbox1 = gtk_hbox_new(FALSE, 10); gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0); gtk_widget_show(hbox1); item = gtk_label_new("Iso File:"); gtk_box_pack_start(GTK_BOX(hbox1), item, FALSE, FALSE, 0); gtk_widget_show(item); item = NULL; devicebox.file = gtk_entry_new(); gtk_box_pack_start(GTK_BOX(hbox1), devicebox.file, TRUE, TRUE, 0); gtk_widget_show(devicebox.file); g_signal_connect(G_OBJECT(devicebox.file), "changed", G_CALLBACK(DeviceBoxFileEvent), NULL); devicebox.selectbutton = gtk_button_new_with_label("Browse"); gtk_box_pack_start(GTK_BOX(hbox1), devicebox.selectbutton, FALSE, FALSE, 0); gtk_widget_show(devicebox.selectbutton); g_signal_connect(G_OBJECT(devicebox.selectbutton), "clicked", G_CALLBACK(DeviceBoxBrowseEvent), NULL); hbox1 = NULL; devicebox.filedesc = gtk_label_new("File Type: ---"); gtk_box_pack_start(GTK_BOX(vbox1), devicebox.filedesc, FALSE, FALSE, 0); gtk_widget_show(devicebox.filedesc); hbox1 = gtk_hbox_new(FALSE, 10); gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0); gtk_widget_show(hbox1); item = gtk_label_new("New File Compression:"); gtk_box_pack_start(GTK_BOX(hbox1), item, FALSE, FALSE, 0); gtk_widget_show(item); item = NULL; devicebox.compress = gtk_combo_box_new_text(); gtk_box_pack_start(GTK_BOX(hbox1), devicebox.compress, FALSE, FALSE, 0); nameptr = 0; while (compressnames[nameptr] != NULL) { gtk_combo_box_append_text(GTK_COMBO_BOX(devicebox.compress), compressnames[nameptr]); nameptr++; } // ENDWHILE- loading compression types into combo box gtk_combo_box_set_active(GTK_COMBO_BOX(devicebox.compress), 0); // Temp Line gtk_widget_show(devicebox.compress); hbox1 = NULL; hbox1 = gtk_hbox_new(FALSE, 10); gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0); gtk_widget_show(hbox1); item = gtk_label_new("Multiple Files (all under 2 GB):"); gtk_box_pack_start(GTK_BOX(hbox1), item, FALSE, FALSE, 0); gtk_widget_show(item); item = NULL; devicebox.multi = gtk_check_button_new(); gtk_box_pack_start(GTK_BOX(hbox1), devicebox.multi, FALSE, FALSE, 0); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(devicebox.multi), FALSE); gtk_widget_show(devicebox.multi); hbox1 = NULL; hbox1 = gtk_hbutton_box_new(); gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0); gtk_widget_show(hbox1); devicebox.okbutton = gtk_button_new_with_label("Make File"); gtk_box_pack_start(GTK_BOX(hbox1), devicebox.okbutton, TRUE, TRUE, 0); gtk_widget_show(devicebox.okbutton); g_signal_connect(G_OBJECT(devicebox.okbutton), "clicked", G_CALLBACK(DeviceBoxOKEvent), NULL); devicebox.cancelbutton = gtk_button_new_with_label("Cancel"); gtk_box_pack_start(GTK_BOX(hbox1), devicebox.cancelbutton, TRUE, TRUE, 0); gtk_widget_show(devicebox.cancelbutton); g_signal_connect(G_OBJECT(devicebox.cancelbutton), "clicked", G_CALLBACK(DeviceBoxCancelEvent), NULL); hbox1 = NULL; vbox1 = NULL; // Device text not set until now to get the correct description. gtk_entry_set_text(GTK_ENTRY(devicebox.device), conf.devicename); DeviceInit(); // Initialize device access } // END DeviceBoxDisplay()
/********************************************************************* * Function: void ResetDevice() * * PreCondition: none * * Input: none * * Output: none * * Side Effects: none * * Overview: resets LCD, initializes PMP * * Note: none * ********************************************************************/ void ResetDevice(void) { // Initialize the device DeviceInit(); // Gamma for CMO 2.8 SetReg(0x46, 0x95); // SetReg(0x47, 0x51); // SetReg(0x48, 0x00); // SetReg(0x49, 0x36); // SetReg(0x4A, 0x11); // SetReg(0x4B, 0x66); // SetReg(0x4C, 0x14); // SetReg(0x4D, 0x77); // SetReg(0x4E, 0x13); // SetReg(0x4F, 0x4C); // SetReg(0x50, 0x46); // SetReg(0x51, 0x46); // // Display SetReg(0x90, 0x7F); // SAP=0111 1111 SetReg(0x01, 0x06); // IDMON=0, INVON=1, NORON=1, PTLON=0 #if (DISP_ORIENTATION == 0) SetReg(0x16, 0xC8); // MY=1, MX=1, MV=0, BGR=1 #else SetReg(0x16, 0xA8); // MY=1, MX=0, MV=1, BGR=1 #endif SetReg(0x23, 0x95); // N_DC=1001 0101 SetReg(0x24, 0x95); // P_DC=1001 0101 SetReg(0x25, 0xFF); // I_DC=1111 1111 SetReg(0x27, 0x06); // N_BP=0000 0110 SetReg(0x28, 0x06); // N_FP=0000 0110 SetReg(0x29, 0x06); // P_BP=0000 0110 SetReg(0x2A, 0x06); // P_FP=0000 0110 SetReg(0x2C, 0x06); // I_BP=0000 0110 SetReg(0x2D, 0x06); // I_FP=0000 0110 SetReg(0x3A, 0x01); // N_RTN=0000, N_NW=001 SetReg(0x3B, 0x01); // P_RTN=0000, P_NW=001 SetReg(0x3C, 0xF0); // I_RTN=1111, I_NW=000 SetReg(0x3D, 0x00); // DIV=00 DelayMs(20); SetReg(0x10, 0xA6); // SS=0,GS=0 CSEL=110 // Power Supply Setting SetReg(0x19, 0x49); // OSCADJ=10 0000, OSD_EN=1 //60Hz SetReg(0x93, 0x0C); // RADJ=1100, DelayMs(10); SetReg(0x20, 0x40); // BT=0100 SetReg(0x1D, 0x07); // VC1=111 SetReg(0x1E, 0x00); // VC3=000 SetReg(0x1F, 0x04); // VRH=0100 4.12V SetReg(0x44, 0x4D); // VCM=101 0000 3.21V SetReg(0x45, 0x11); // VDV=1 0001 -1.19V DelayMs(10); SetReg(0x1C, 0x04); // AP=100 DelayMs(20); SetReg(0x43, 0x80); //set VCOMG=1 DelayMs(5); SetReg(0x1B, 0x18); // GASENB=0, PON=1, DK=1, XDK=0, DDVDH_TRI=0, STB=0 DelayMs(40); SetReg(0x1B, 0x10); // GASENB=0, PON=1, DK=0, XDK=0, DDVDH_TRI=0, STB=0 DelayMs(40); // Display ON Setting SetReg(0x26, 0x04); // GON=0, DTE=0, D=01 DelayMs(40); SetReg(0x26, 0x24); // GON=1, DTE=0, D=01 SetReg(0x26, 0x2C); // GON=1, DTE=0, D=11 DelayMs(40); SetReg(0x26, 0x3C); // GON=1, DTE=1, D=11 SetReg(0x35, 0x38); // EQS=38h SetReg(0x36, 0x78); // EQP=78h SetReg(0x3E, 0x38); // SON=38h SetReg(0x40, 0x0F); // GDON=0Fh SetReg(0x41, 0xF0); // GDOFF // Set spulse & rpulse SetReg(0x57, 0x02); // Test mode='1' SetReg(0x56, 0x84); // set Rpulse='1000',spulse='0100' SetReg(0x57, 0x00); // Test mode= '0' #if (DISP_ORIENTATION == 0) SetReg(0x04, 0x00); SetReg(0x05, 0xEF); SetReg(0x08, 0x01); SetReg(0x09, 0x3F); #else SetReg(0x04, 0x01); SetReg(0x05, 0x3F); SetReg(0x08, 0x00); SetReg(0x09, 0xEF); #endif DelayMs(20); /* RST_LAT_BIT=0; delayms(20); RST_LAT_BIT=1; delayms(100); */ /* //WriteDirect(CMD_MODE,0x46); // WriteDirect(DATA_MODE,0x00D2); SetReg(0x46,0x00D2); // WriteDirect(CMD_MODE,0x47); // WriteDirect(DATA_MODE,0x0050); SetReg(0x47,0x0050); // WriteDirect(CMD_MODE,0x48); // WriteDirect(DATA_MODE,0x0007); SetReg(0x48,0x0007); // WriteDirect(CMD_MODE,0x49); // WriteDirect(DATA_MODE,0x0043); SetReg(0x49,0x0043); // WriteDirect(CMD_MODE,0x4A); // WriteDirect(DATA_MODE,0x0044); SetReg(0x4A,0x0044); // WriteDirect(CMD_MODE,0x4B); // WriteDirect(DATA_MODE,0x0077); SetReg(0x4B,0x0077); // WriteDirect(CMD_MODE,0x4C); // WriteDirect(DATA_MODE,0x0066); SetReg(0x4C,0x0066); // WriteDirect(CMD_MODE,0x4D); // WriteDirect(DATA_MODE,0x0016); SetReg(0x4D,0x0016); // WriteDirect(CMD_MODE,0x4E); // WriteDirect(DATA_MODE,0x0012); SetReg(0x4E,0x0012); // WriteDirect(CMD_MODE,0x4F); // WriteDirect(DATA_MODE,0x004C); SetReg(0x4F,0x004C); // WriteDirect(CMD_MODE,0x50); // WriteDirect(DATA_MODE,0x0046); SetReg(0x50,0x0046); // WriteDirect(CMD_MODE,0x51); // WriteDirect(DATA_MODE,0x0044); SetReg(0x51,0x0044); //240*320window setting SetReg(0x0002,0x0000); // Column address start2 SetReg(0x0003,0x0000); // Column address start1 SetReg(0x0004,0x0000); // Column address end2 SetReg(0x0005,0x00EF); // Column address end1 SetReg(0x0006,0x0000); // Row address start2 SetReg(0x0007,0x0000); // Row address start1 SetReg(0x0008,0x0001); // Row address end2 SetReg(0x0009,0x003F); // Row address end1 //WriteDirect(CMD_MODE,0x22); //Display setting // WriteDirect(CMD_MODE,0x01); // WriteDirect(DATA_MODE,0x0006); //0x0006 SetReg(0x01,0x0006); // WriteDirect(CMD_MODE,0x16); // WriteDirect(DATA_MODE,0x00A8);//0X48//0x00C8//0x0068//0x0008//0x00A8 SetReg(0x16,0x00A8); // WriteDirect(CMD_MODE,0x23); // WriteDirect(DATA_MODE,0x0095); SetReg(0x23,0x0095); // WriteDirect(CMD_MODE,0x24); // WriteDirect(DATA_MODE,0x0095); SetReg(0x24,0x0095); // WriteDirect(CMD_MODE,0x25); // WriteDirect(DATA_MODE,0x00FF); SetReg(0x25,0x00FF); // WriteDirect(CMD_MODE,0x27); // WriteDirect(DATA_MODE,0x0002); SetReg(0x27,0x0002); // WriteDirect(CMD_MODE,0x28); // WriteDirect(DATA_MODE,0x0002); SetReg(0x28,0x0002); // WriteDirect(CMD_MODE,0x29); // WriteDirect(DATA_MODE,0x0002); SetReg(0x29,0x0002); // WriteDirect(CMD_MODE,0x2A); // WriteDirect(DATA_MODE,0x0002); SetReg(0x2A,0x0002); // WriteDirect(CMD_MODE,0x2C); // WriteDirect(DATA_MODE,0x0002); SetReg(0x2C,0x0002); // WriteDirect(CMD_MODE,0x2D); // WriteDirect(DATA_MODE,0x0002); SetReg(0x2D,0x0002); // WriteDirect(CMD_MODE,0x3A); // WriteDirect(DATA_MODE,0x0001); SetReg(0x3A,0x0001); // WriteDirect(CMD_MODE,0x3B); // WriteDirect(DATA_MODE,0x0001); SetReg(0x3B,0x0001); // WriteDirect(CMD_MODE,0x3C); // WriteDirect(DATA_MODE,0x00F0); SetReg(0x3C,0x00F0); // WriteDirect(CMD_MODE,0x3D); // WriteDirect(DATA_MODE,0x0000); SetReg(0x3D,0x0000); delay(20); // WriteDirect(CMD_MODE,0x35); // WriteDirect(DATA_MODE,0x0038); SetReg(0x35,0x0038); // WriteDirect(CMD_MODE,0x36); // WriteDirect(DATA_MODE,0x0078); SetReg(0x36,0x0078); // WriteDirect(CMD_MODE,0x3E); // WriteDirect(DATA_MODE,0x0038); SetReg(0x3E,0x0038); // WriteDirect(CMD_MODE,0x40); // WriteDirect(DATA_MODE,0x000F); SetReg(0x40,0x000F); // WriteDirect(CMD_MODE,0x41); // WriteDirect(DATA_MODE,0x00F0); SetReg(0x41,0x00F0); // WriteDirect(CMD_MODE,0x19); // WriteDirect(DATA_MODE,0x0049); SetReg(0x19,0x0049); // WriteDirect(CMD_MODE,0x93); // WriteDirect(DATA_MODE,0x0003); SetReg(0x93,0x0003); delay(10); // WriteDirect(CMD_MODE,0x20); // WriteDirect(DATA_MODE,0x0020); SetReg(0x20,0x0020); // WriteDirect(CMD_MODE,0x1D); // WriteDirect(DATA_MODE,0x0005); SetReg(0x1D,0x0005); delay(10); // WriteDirect(CMD_MODE,0x1E); // WriteDirect(DATA_MODE,0x0006); SetReg(0x1E,0x0006); // WriteDirect(CMD_MODE,0x1F); // WriteDirect(DATA_MODE,0x0008); SetReg(0x1F,0x0008); //VCOM setting // WriteDirect(CMD_MODE,0x44); // WriteDirect(DATA_MODE,0x0040); SetReg(0x44,0x0040); // WriteDirect(CMD_MODE,0x45); // WriteDirect(DATA_MODE,0x0012); SetReg(0x45,0x0012); delay(10); // WriteDirect(CMD_MODE,0x1C); // WriteDirect(DATA_MODE,0x0004); SetReg(0x1C,0x0004); delay(20); // WriteDirect(CMD_MODE,0x43); // WriteDirect(DATA_MODE,0x0080); SetReg(0x43,0x0080); delay(5); // WriteDirect(CMD_MODE,0x1B); // WriteDirect(DATA_MODE,0x0008);//0X00,0X08 SetReg(0x1B,0x0008); delay(40); // WriteDirect(CMD_MODE,0x1B); // WriteDirect(DATA_MODE,0x0010);//0X00,0X10 SetReg(0x1B,0x0010); delay(40); // WriteDirect(CMD_MODE,0x43); // WriteDirect(DATA_MODE,0x0080); SetReg(0x43,0x0080); delay(10); //Display ON setting // WriteDirect(CMD_MODE,0x90); // WriteDirect(DATA_MODE,0x007F); SetReg(0x90,0x007F); // WriteDirect(CMD_MODE,0x26); // WriteDirect(DATA_MODE,0x0004); SetReg(0x26,0x0004); delay(40); // WriteDirect(CMD_MODE,0x26); // WriteDirect(DATA_MODE,0x0024); SetReg(0x26,0x0024); delay(40); // WriteDirect(CMD_MODE,0x26); // WriteDirect(DATA_MODE,0x002C); SetReg(0x26,0x002C); delay(40); // WriteDirect(CMD_MODE,0x26); // WriteDirect(DATA_MODE,0x003C); SetReg(0x26,0x003C); //Set internal VDDD voltage // WriteDirect(CMD_MODE,0x57); // WriteDirect(DATA_MODE,0x0002); SetReg(0x57,0x0002); // WriteDirect(CMD_MODE,0x55); // WriteDirect(DATA_MODE,0x0000); SetReg(0x55,0x0000); // WriteDirect(CMD_MODE,0x57); // WriteDirect(DATA_MODE,0x0000); SetReg(0x57,0x0000); */ /* // Gamma for CMO 3.2¡± SetReg(0x0046,0x00A4); SetReg(0x0047,0x0053); SetReg(0x0048,0x0000); SetReg(0x0049,0x0044); SetReg(0x004A,0x0004); SetReg(0x004B,0x0067); SetReg(0x004C,0x0033); SetReg(0x004D,0x0077); SetReg(0x004E,0x0012); SetReg(0x004F,0x004C); SetReg(0x0050,0x0046); SetReg(0x0051,0x0044); //240x320 window setting //SetReg(0x001a,0x0001); SetReg(0x0002,0x0000); // Column address start2 SetReg(0x0003,0x0000); // Column address start1 SetReg(0x0004,0x0000); // Column address end2 SetReg(0x0005,0x00EF); // Column address end1 SetReg(0x0006,0x0000); // Row address start2 SetReg(0x0007,0x0000); // Row address start1 SetReg(0x0008,0x0001); // Row address end2 SetReg(0x0009,0x003F); // Row address end1 // Display Setting SetReg(0x0001,0x0006); // IDMON=0, INVON=1, NORON=1, PTLON=0 SetReg(0x0016,0x00c8); // MY=0, MX=0, MV=0, ML=1, BGR=0, TEON=0 SetReg(0x0038,0x0000); // RGB_EN=0, use MPU Interface SetReg(0x0023,0x0095); // N_DC=1001 0101 SetReg(0x0024,0x0095); // PI_DC=1001 0101 SetReg(0x0025,0x00FF); // I_DC=1111 1111 SetReg(0x0027,0x0002); // N_BP=0000 0010 SetReg(0x0028,0x0002); // N_FP=0000 0010 SetReg(0x0029,0x0002); // PI_BP=0000 0010 SetReg(0x002A,0x0002); // PI_FP=0000 0010 SetReg(0x002C,0x0002); // I_BP=0000 0010 SetReg(0x002D,0x0002); // I_FP=0000 0010 SetReg(0x003A,0x0001); // N_RTN=0000, N_NW=001 SetReg(0x003B,0x0000); // PI_RTN=0000, PI_NW=000 SetReg(0x003C,0x00F0); // I_RTN=1111, I_NW=000 SetReg(0x003D,0x0000); // DIV=00 delayms(20); SetReg(0x0035,0x0038); // EQS=38h SetReg(0x0036,0x0078); // EQP=78h SetReg(0x003E,0x0038); // SON=38h SetReg(0x0040,0x000F); // GDON=0Fh SetReg(0x0041,0x00F0); // GDOFF // Power Supply Setting SetReg(0x0019,0x0049); // CADJ=0100, CUADJ=100(FR:60Hz),, OSD_EN=1 SetReg(0x0093,0x000F); // RADJ=1111, 100% delayms(10); SetReg(0x0020,0x0040); // BT=0100 SetReg(0x001D,0x0007); // VC1=111 SetReg(0x001E,0x0000); // VC3=000 SetReg(0x001F,0x0004); // VRH=0100 // VCOM Setting for CMO 3.2¡± Panel SetReg(0x0044,0x004D); // VCM=100 1101 SetReg(0x0045,0x0011); // VDV=1 0001 delayms(10); SetReg(0x001C,0x0004); // AP=100 delayms(20); SetReg(0x001B,0x0018); // GASENB=0, PON=1, DK=1, XDK=0, VLCD_TRI=0, STB=0 delayms(40); SetReg(0x001B,0x0010); // GASENB=0, PON=1, DK=0, XDK=0, VLCD_TRI=0, STB=0 delayms(40); SetReg(0x0043,0x0080); //Set VCOMG=1 delayms(100); // Display ON Setting SetReg(0x0090,0x007F); // SAP=0111 1111 SetReg(0x0026,0x0004); //GON=0, DTE=0, D=01 delayms(40); SetReg(0x0026,0x0024); //GON=1, DTE=0, D=01 SetReg(0x0026,0x002C); //GON=1, DTE=0, D=11 delayms(40); SetReg(0x0026,0x003C); //GON=1, DTE=1, D=11 // Internal register setting SetReg(0x0057,0x0002); //Test_Mode Enable SetReg(0x0095,0x0001); // Set Display clock and Pumping clock to synchronize SetReg(0x0057,0x0000); // Test_Mode Disable */ /* // Gamma for CMO 2.4 SetReg(0x0046,0x0094); SetReg(0x0047,0x0041); SetReg(0x0048,0x0000); SetReg(0x0049,0x0033); SetReg(0x004A,0x0023); SetReg(0x004B,0x0045); SetReg(0x004C,0x0044); SetReg(0x004D,0x0077); SetReg(0x004E,0x0012); SetReg(0x004F,0x00CC); SetReg(0x0050,0x0046); SetReg(0x0051,0x0082); //240x320 window setting SetReg(0x0002,0x0000); // Column address start2 SetReg(0x0003,0x0000); // Column address start1 SetReg(0x0004,0x0000); // Column address end2 SetReg(0x0005,0x00EF); // Column address end1 SetReg(0x0006,0x0000); // Row address start2 SetReg(0x0007,0x0000); // Row address start1 SetReg(0x0008,0x0001); // Row address end2 SetReg(0x0009,0x003F); // Row address end1 // Display Setting SetReg(0x0001,0x0006); // IDMON=0, INVON=1, NORON=1, PTLON=0 SetReg(0x0016,0x0008); // MY=0, MX=0, MV=0, ML=1, BGR=0, TEON=0 SetReg(0x0070,0x00C6); // SS=1, GS=1, MV=0, ML=1, BGR=0, TEON=0 SetReg(0x0038,0x0000); // RGB_EN=0, use MPU Interface SetReg(0x0023,0x0095); // N_DC=1001 0101 SetReg(0x0024,0x0095); // PI_DC=1001 0101 SetReg(0x0025,0x00FF); // I_DC=1111 1111 SetReg(0x0027,0x0002); // N_BP=0000 0010 SetReg(0x0028,0x0002); // N_FP=0000 0010 SetReg(0x0029,0x0002); // PI_BP=0000 0010 SetReg(0x002A,0x0002); // PI_FP=0000 0010 SetReg(0x002C,0x0002); // I_BP=0000 0010 SetReg(0x002D,0x0002); // I_FP=0000 0010 SetReg(0x003A,0x0001); // N_RTN=0000, N_NW=001 SetReg(0x003B,0x0000); // PI_RTN=0000, PI_NW=000 SetReg(0x003C,0x00F0); // I_RTN=1111, I_NW=000 SetReg(0x003D,0x0000); // DIV=00 delayms(20); SetReg(0x0035,0x0038); // EQS=38h SetReg(0x0036,0x0078); // EQP=78h SetReg(0x003E,0x0038); // SON=38h SetReg(0x0040,0x000F); // GDON=0Fh SetReg(0x0041,0x00F0); // GDOFF // Power Supply Setting SetReg(0x0019,0x006B); // CADJ=0100, CUADJ=100(FR:60Hz),, OSD_EN=1 SetReg(0x0093,0x000A); // RADJ=1111, 100% delayms(10); SetReg(0x0020,0x0040); // BT=0100 SetReg(0x001D,0x0007); // VC1=111 SetReg(0x001E,0x0000); // VC3=000 SetReg(0x001F,0x0004); // VRH=0100 // VCOM Setting for CMO 2.4¡± Panel SetReg(0x0044,0x003c); // VCM=100 0000 38 SetReg(0x0045,0x0011); // VDV=1 0001 13 delayms(10); SetReg(0x001C,0x0004); // AP=100 delayms(20); SetReg(0x001B,0x0018); // GASENB=0, PON=1, DK=1, XDK=0, VLCD_TRI=0, STB=0 delayms(40); SetReg(0x001B,0x0010); // GASENB=0, PON=1, DK=0, XDK=0, VLCD_TRI=0, STB=0 delayms(40); SetReg(0x0043,0x0080); //Set VCOMG=1 delayms(100); // Display ON Setting SetReg(0x0090,0x007F); // SAP=0111 1111 SetReg(0x0026,0x0004); //GON=0, DTE=0, D=01 delayms(40); SetReg(0x0026,0x0024); //GON=1, DTE=0, D=01 SetReg(0x0026,0x002C); //GON=1, DTE=0, D=11 delayms(40); SetReg(0x0026,0x003C); //GON=1, DTE=1, D=11 // Internal register setting SetReg(0x0057,0x0002); //Test_Mode Enable SetReg(0x0095,0x0001); // Set Display clock and Pumping clock to synchronize SetReg(0x0057,0x0000); // Test_Mode Disable */ /* DeviceSelect(); DeviceSetCommand(); DeviceWrite(0x72); DeviceSetData(); registed=DeviceRead(); DeviceDeselect(); */ }
/********************************************************************* * Function: void ResetDevice() * * PreCondition: none * * Input: none * * Output: none * * Side Effects: none * * Overview: resets LCD, initializes PMP * * Note: none * ********************************************************************/ void ResetDevice(void) { // Initialize the device DeviceInit(); // Setup display #if (DISPLAY_CONTROLLER == SSD1289) ///////////////////////////////////////////////////////// SetReg(0x00, 0x0001); SetReg(0x03, 0xAAAC); SetReg(0x0C, 0x0002); DelayMs(15); SetReg(0x0D, 0x000A); SetReg(0x0E, 0x2D00); SetReg(0x1E, 0x00BC); SetReg(0x01, 0x1A0C); DelayMs(15); #if (DISP_ORIENTATION == 0) SetReg(0x01, 0x2B3F); #else SetReg(0x01, 0x293F); #endif SetReg(0x02, 0x0600); SetReg(0x10, 0x0000); #if (DISP_ORIENTATION == 0) SetReg(0x11, 0x60B0); #else SetReg(0x11, 0x60B8); #endif SetReg(0x05, 0x0000); SetReg(0x06, 0x0000); DelayMs(100); SetReg(0x16, 0xEF1C); SetReg(0x17, 0x0003); SetReg(0x07, 0x0233); SetReg(0x0B, 0x0000); SetReg(0x0F, 0x0000); SetReg(0x41, 0x0000); SetReg(0x42, 0x0000); SetReg(0x48, 0x0000); SetReg(0x49, 0x013F); SetReg(0x44, 0xEF00); SetReg(0x45, 0x0000); SetReg(0x46, 0x013F); SetReg(0x4A, 0x0000); SetReg(0x4B, 0x0000); SetReg(0x30, 0x0707); SetReg(0x31, 0x0704); SetReg(0x32, 0x0204); SetReg(0x33, 0x0502); SetReg(0x34, 0x0507); SetReg(0x35, 0x0204); SetReg(0x36, 0x0204); SetReg(0x37, 0x0502); SetReg(0x3A, 0x0302); SetReg(0x3B, 0x1f00); SetReg(0x23, 0x0000); SetReg(0x24, 0x0000); #elif (DISPLAY_CONTROLLER == SSD2119) SetReg(0x0028, 0x0006); // VCOM OTP, page 55-56 of datasheet SetReg(0x0000, 0x0001); // start Oscillator, page 36 of datasheet SetReg(0x0010, 0x0000); // Sleep mode, page 49 of datasheet #if (DISP_ORIENTATION == 0) SetReg(0x0001, 0x72EF); // Driver Output Control, page 36-39 of datasheet #else SetReg(0x0001, 0x32EF); // Driver Output Control, page 36-39 of datasheet #endif SetReg(0x0002, 0x0600); // LCD Driving Waveform Control, page 40-42 of datasheet SetReg(0x0003, 0x6A38); // Power Control 1, page 43-44 of datasheet #if (DISP_ORIENTATION == 0) SetReg(0x0011, 0x6870); // Entry Mode, page 50-52 of datasheet #else SetReg(0x0011, 0x6878); // Entry Mode, page 50-52 of datasheet #endif SetReg(0x000F, 0x0000); // Gate Scan Position, page 49 of datasheet SetReg(0x000B, 0x5308); // Frame Cycle Control, page 45 of datasheet SetReg(0x000C, 0x0003); // Power Control 2, page 47 of datasheet SetReg(0x000D, 0x000A); // Power Control 3, page 48 of datasheet SetReg(0x000E, 0x2E00); // Power Control 4, page 48 of datasheet SetReg(0x001E, 0x00BE); // Power Control 5, page 53 of datasheet SetReg(0x0025, 0x8000); // Frame Frequency Control, page 53 of datasheet SetReg(0x0026, 0x7800); // Analog setting, page 54 of datasheet SetReg(0x004E, 0x0000); // Ram Address Set, page 58 of datasheet SetReg(0x004F, 0x0000); // Ram Address Set, page 58 of datasheet SetReg(0x0012, 0x08D9); // Sleep mode, page 49 of datasheet // Gamma Control (R30h to R3Bh) -- page 56 of datasheet SetReg(0x0030, 0x0000); SetReg(0x0031, 0x0104); SetReg(0x0032, 0x0100); SetReg(0x0033, 0x0305); SetReg(0x0034, 0x0505); SetReg(0x0035, 0x0305); SetReg(0x0036, 0x0707); SetReg(0x0037, 0x0300); SetReg(0x003A, 0x1200); SetReg(0x003B, 0x0800); SetReg(0x0007, 0x0033); // Display Control, page 45 of datasheet #endif DelayMs(50); }
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // MAIN CODE - starts here //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% void main(void) { //================================================================================= // INITIALISATION - General //================================================================================= //-------------------------------- FRAMEWORK -------------------------------------- DeviceInit(); // Device Life support & GPIO SCIA_Init(); // Initalize the Serial Comms A peripheral // Only used if running from FLASH // Note that the variable FLASH is defined by the compiler with -d FLASH // (see TwoChannelBuck.pjt file) #ifdef FLASH // Copy time critical code and Flash setup code to RAM // The RamfuncsLoadStart, RamfuncsLoadEnd, and RamfuncsRunStart // symbols are created by the linker. Refer to the linker files. MemCopy(&RamfuncsLoadStart, &RamfuncsLoadEnd, &RamfuncsRunStart); // Call Flash Initialization to setup flash waitstates // This function must reside in RAM InitFlash(); // Call the flash wrapper init function #endif //(FLASH) // Timing sync for background loops // Timer period definitions found in PeripheralHeaderIncludes.h CpuTimer0Regs.PRD.all = mSec1; // A tasks CpuTimer1Regs.PRD.all = mSec50; // B tasks CpuTimer2Regs.PRD.all = mSec100; // C tasks // Tasks State-machine init Alpha_State_Ptr = &A0; A_Task_Ptr = &A1; B_Task_Ptr = &B1; C_Task_Ptr = &C1; BlinkStatePtr = 0; VTimer0[0] = 0; VTimer1[0] = 0; VTimer2[0] = 0; CommsOKflg = 0; SerialCommsTimer = 0; HRmode = 1; // Default to HR mode enabled LED_TaskPtr = 0; // ---------------------------------- USER ----------------------------------------- // put common initialization/variable definitions here Gui_LEDPrd = 1000; //Default to 1 blink every second (Q0) temp_LEDDelay = 0; //================================================================================= // INITIALISATION - GUI connections //================================================================================= // Use this section only if you plan to "Instrument" your application using the // Microsoft C# freeware GUI Template provided by TI //"Set" variables //--------------------------------------- // assign GUI variable Textboxes to desired "setable" parameter addresses //varSetTxtList[0] = &Var1; // assign GUI Buttons to desired flag addresses //varSetBtnList[0] = &Var2; // assign GUI Sliders to desired "setable" parameter addresses varSetSldrList[0] = &Gui_LEDPrd; //"Get" variables //--------------------------------------- // assign a GUI "getable" parameter address //varGetList[0] = &Var3; // assign a GUI "getable" parameter array address // only need to set initial position of array, program will run through it // based on the array length specified in the GUI //arrayGetList[0] = &Var4[0]; //================================================================================== // INITIALISATION - Peripherals used for support //================================================================================== // ---------------------------------- USER ----------------------------------------- // Put peripheral initialisation here //================================================================================== // INITIALISATION - BUILD OPTIONS - NOTE: select via ProjectSettings.h //================================================================================== // ---------------------------------- USER ----------------------------------------- // Put build specific initialisation here //================================================================================= // BACKGROUND (BG) LOOP //================================================================================= //--------------------------------- FRAMEWORK ------------------------------------- for(;;) //infinite loop { // State machine entry & exit point //=========================================================== (*Alpha_State_Ptr)(); // jump to an Alpha state (A0,B0,...) //=========================================================== } } //END MAIN CODE