コード例 #1
0
ファイル: SSD1351.cpp プロジェクト: JenEdw/arducordermini
void SSD1351::writeCommand(uint8_t c) {
  while(mIsPMPBusy());                // Wait for PMP to be free
  //digitalWrite(SSD1351_DC, 0);        // Low -- command mode 
  mPORTCClearBits(OLED_DC);           // Low -- command mode 
  
//  PMPMasterWrite( c );                // write character   

  mPORTEWrite( (uint16_t)c );    // Setup data
  mPORTDClearBits(OLED_RW);      // RW# 0 (write mode)
  mPORTDSetBits(OLED_EN);      // EN 1 (enable)
  mPORTDClearBits(OLED_CS);      // CS active   
//  delay(1);
  mPORTDSetBits(OLED_CS);      // CS inactive  
  mPORTDClearBits(OLED_EN);      // EN 0 (disable) 
  
}
コード例 #2
0
ファイル: app.c プロジェクト: sidwarkd/waterworx-device
void InitializeSystem()
{
	SYSTEMConfigWaitStatesAndPB(CLOCK_FREQ);
	mOSCSetPBDIV(OSC_PB_DIV_4);  // Set to get 20MHz PB clock
  //mOSCSetPBDIV(OSC_PB_DIV_2);
	CheKseg0CacheOn();
	mJTAGPortEnable(0);

	// Initialize the pins to all digital output and driven to ground.
	// Exception is RE7 and RE6 which are switch inputs
	PORTSetPinsDigitalIn(IOPORT_E, BIT_6);
	PORTSetPinsDigitalIn(IOPORT_E, BIT_7);

	mPORTASetPinsDigitalOut(0xFFFF);
	mPORTBSetPinsDigitalOut(0xFFFF);
	mPORTCSetPinsDigitalOut(0xFFFF);
	mPORTDSetPinsDigitalOut(0xFFFF);
	mPORTESetPinsDigitalOut(0xFF3F);
	mPORTFSetPinsDigitalOut(0xFFFF);
	mPORTGSetPinsDigitalOut(0xFFFF);

	mPORTAClearBits(0xFFFF);
	mPORTBClearBits(0xFFFF);
	mPORTCClearBits(0xFFFF);
	mPORTDClearBits(0xFFFF);
	mPORTEClearBits(0xFF3F);
	mPORTESetBits(0x000F);		// LED latches need to be set high for off
	mPORTFClearBits(0xFFFF);
	mPORTGClearBits(0xFFFF);

	INTEnableSystemMultiVectoredInt();

  #ifdef SANITY_CHECK
  mLED_Green_On();
  #endif
	
	//LCD_Initialize();
	//WIFI_Initialize();
	//SPRINKLER_Initialize();
	//RTCC_Initialize(); 
  //SERIALUSB_Initialize();
	SDCARD_Initialize();

  TCPIP_Initialize();
}
コード例 #3
0
ファイル: main.c プロジェクト: hightower70/tvc-usb-keyboard
//******************************************************************************
//******************************************************************************
// Main
//******************************************************************************
//******************************************************************************
int main (void)
{
	BYTE i;
	DWORD temp;

	int  value;

	value = SYSTEMConfigWaitStatesAndPB( GetSystemClock() );

	mJTAGPortEnable(DEBUG_JTAGPORT_OFF);

	// Enable the cache for the best performance
	CheKseg0CacheOn();

	value = OSCCON;
	while (!(value & 0x00000020))
	{
		value = OSCCON;    // Wait for PLL lock to stabilize
	}

	InitKeyboardDriver();

	INTEnableSystemMultiVectoredInt();

	// Init status LED
	mPORTCSetBits(BIT_0);
	mPORTCSetPinsDigitalOut(BIT_0);

	//DBINIT();

	// Initialize USB layers
	USBInitialize(0);

	while (1)
	{
		USBTasks();
		App_Detect_Device();
		switch (App_State_Keyboard)
		{
			case DEVICE_NOT_CONNECTED:
				mPORTCSetBits(BIT_0);
				USBTasks();
				if (DisplayDeatachOnce == FALSE)
				{
					DBPRINTF("Device Detached\n");
					DisplayDeatachOnce = TRUE;
				}
				if (USBHostHID_ApiDeviceDetect()) /* True if report descriptor is parsed with no error */
				{
					DBPRINTF("Device Attached\n");
					App_State_Keyboard = DEVICE_CONNECTED;
					DisplayConnectOnce = FALSE;
				}
				break;
			case DEVICE_CONNECTED:
				mPORTCClearBits(BIT_0);
				App_State_Keyboard = READY_TO_TX_RX_REPORT;
				if (DisplayConnectOnce == FALSE)
				{
					DisplayConnectOnce = TRUE;
					DisplayDeatachOnce = FALSE;
				}
				InitializeTimer(); // start 10ms timer to schedule input reports

				break;
			case READY_TO_TX_RX_REPORT:
				if (!USBHostHID_ApiDeviceDetect())
				{
					App_State_Keyboard = DEVICE_NOT_CONNECTED;
					//                                DisplayOnce = FALSE;
				}
				break;
			case GET_INPUT_REPORT:
				if (USBHostHID_ApiGetReport(Appl_raw_report_buffer.Report_ID, Appl_ModifierKeysDetails.interfaceNum,
																		Appl_raw_report_buffer.ReportSize, Appl_raw_report_buffer.ReportData))
				{
					/* Host may be busy/error -- keep trying */
				}
				else
				{
					App_State_Keyboard = INPUT_REPORT_PENDING;
				}
				USBTasks();
				break;
			case INPUT_REPORT_PENDING:
				if (USBHostHID_ApiTransferIsComplete(&ErrorDriver, &NumOfBytesRcvd))
				{
					if (ErrorDriver || (NumOfBytesRcvd !=     Appl_raw_report_buffer.ReportSize ))
					{
						ErrorCounter++ ;
						if (MAX_ERROR_COUNTER <= ErrorDriver)
							App_State_Keyboard = ERROR_REPORTED;
						else
							App_State_Keyboard = READY_TO_TX_RX_REPORT;
					}
					else
					{
						ErrorCounter = 0;
						ReportBufferUpdated = TRUE;
						App_State_Keyboard = READY_TO_TX_RX_REPORT;

						if (DisplayConnectOnce == TRUE)
						{
							for (i = 0; i < Appl_raw_report_buffer.ReportSize; i++)
							{
								if (Appl_raw_report_buffer.ReportData[i] != 0)
								{
									//LCDClear();
									//LCDL1Home();
									DisplayConnectOnce = FALSE;
								}
							}
						}

						App_ProcessInputReport();
						App_PrepareOutputReport();
					}
				}
				break;

			case SEND_OUTPUT_REPORT: /* Will be done while implementing Keyboard */
				if (USBHostHID_ApiSendReport(Appl_LED_Indicator.reportID, Appl_LED_Indicator.interfaceNum, Appl_LED_Indicator.reportLength,
																		(BYTE*) & Appl_led_report_buffer))
				{
					/* Host may be busy/error -- keep trying */
				}
				else
				{
					App_State_Keyboard = OUTPUT_REPORT_PENDING;
				}
				USBTasks();

				break;
			case OUTPUT_REPORT_PENDING:
				if (USBHostHID_ApiTransferIsComplete(&ErrorDriver, &NumOfBytesRcvd))
				{
					if (ErrorDriver)
					{
						ErrorCounter++ ;
						if (MAX_ERROR_COUNTER <= ErrorDriver)
							App_State_Keyboard = ERROR_REPORTED;

						//                                App_State_Keyboard = READY_TO_TX_RX_REPORT;
					}
					else
					{
						ErrorCounter = 0;
						App_State_Keyboard = READY_TO_TX_RX_REPORT;
					}
				}
				break;

			case ERROR_REPORTED:
				break;
			default:
				break;
		}
	}
}