예제 #1
0
////////LCM reset
void LCD_Reset(void)
{
	RESET = 0;
	Delay1ms(1);
	RESET = 1;
	Delay1ms(1);
}
예제 #2
0
void Soft_Reset(void)
{
	xSemaphoreTake(xDispSemaphore, portMAX_DELAY);
	{
		LCD_Reset();
		Delay1ms(500);
		LCD_Initial();
		Two_Layers();
		Delay1ms(100);
		Active_Window(0,479,0,271);
		Background_color(color_black);
		Text_color(color_white);
		Text_Cursor_Disable();
		Layer1_Visible();
		Write_To_Bank1();
		Clear_Active_Window();
		Write_To_Bank2();
		Clear_Full_Window();
		Display_ON();

		//backlight on for RAiO RA8875_demo_board_V2
		PWM1_enable();
		PWM1_duty_cycle(0xff);

		Text_color(color_white);
		Background_color(color_black);
		xSemaphoreGive(xDispSemaphore);
	}
}
예제 #3
0
파일: main.c 프로젝트: GhaziAMOR/HeartBlock
// 3. Subroutines Section
// MAIN: Mandatory for a C Program to be executable
int main(void){
  TExaS_Init(SW_PIN_PF40, LED_PIN_PF31,ScopeOn);  // activate grader and set system clock to 80 MHz
  PortF_Init();                            // Init port PF4 PF3 PF1    
  EnableInterrupts();                      // enable interrupts for the grader  
  while(1){  
     SetReady();
		WaitForASLow();
		ClearReady();
		Delay1ms(10);
		WaitForASHigh();
		Delay1ms(250);
		SetVT();
		Delay1ms(250);
		ClearVT();
      		
		// Follows the nine steps list above
    // a) Ready signal goes high
    // b) wait for switch to be pressed
    // c) Ready signal goes low
    // d) wait 10ms
    // e) wait for switch to be released
    // f) wait 250ms
    // g) VT signal goes high
    // h) wait 250ms
    // i) VT signal goes low
  }
}
예제 #4
0
/////////////PLL setting
void PLL_ini(void)
{
    LCD_CmdWrite(0x88);
    LCD_DataWrite(0x0C);
    Delay1ms(1);
    LCD_CmdWrite(0x89);
    LCD_DataWrite(0x02);
    Delay1ms(1);
}
예제 #5
0
static void RA8875_PLL_ini(void)
{
#ifdef P800x480
    LCD_CmdWrite(0x88);
    LCD_DataWrite(0x0c);
    Delay1ms(1);
    LCD_CmdWrite(0x89);
    LCD_DataWrite(0x02);
    Delay1ms(1);
#endif
}
예제 #6
0
void Init_Display(void)
{
	xSemaphoreTake(xDispSemaphore, portMAX_DELAY);
	{
		Delay1ms(1000);
		LowLevel_Init();
		Delay1ms(100);
		bDisplayInitialized = 0x01;
		xSemaphoreGive(xDispSemaphore);
	}

}
예제 #7
0
파일: i2c.c 프로젝트: antijiang/jiu2
//////////////////////////////////////////////////////////////////////////
// I2C access start.
//
// Arguments: ucSlaveAdr - slave address
//            trans_t - I2C_TRANS_WRITE/I2C_TRANS_READ
//////////////////////////////////////////////////////////////////////////
BOOL i2c_AccessStart(BYTE ucSlaveAdr, I2C_Direction trans_t)
{
    BYTE ucDummy; // loop dummy

    if (trans_t == I2C_READ) // check i2c read or write
        ucSlaveAdr = I2C_DEVICE_ADR_READ(ucSlaveAdr); // read
    else
        ucSlaveAdr = I2C_DEVICE_ADR_WRITE(ucSlaveAdr); // write

    ucDummy = I2C_ACCESS_DUMMY_TIME;
    while (ucDummy--)
    {    
	i2c_Delay();
        if (i2c_Start() == FALSE)
            continue;

        if (i2c_SendByte(ucSlaveAdr) == I2C_ACKNOWLEDGE) // check acknowledge
            return TRUE;
		//printf("ucSlaveAdr====%x", ucSlaveAdr);
        i2c_Stop();
        Delay1ms(1);
    }

    return FALSE;
}
예제 #8
0
파일: ST7735.c 프로젝트: howlanjo/Project-2
// Initialization code common to both 'B' and 'R' type displays
void static commonInit(const uint8_t *cmdList) {
  ColStart  = RowStart = 0; // May be overridden in init func

  // toggle RST low to reset; CS low so it'll listen to us
  // UCA3STE is temporarily used as GPIO
  P9SEL0 &= ~0x0C;
  P9SEL1 &= ~0x0C;                      // configure P9.2 (D/C), P9.3 (Reset), and P9.4 (TFT_CS) as GPIO
  P9DIR |= 0x1C;                        // make P9.2 (D/C), P9.3 (Reset), and P9.4 (TFT_CS) out
  TFT_CS &= ~TFT_CS_BIT;
  RESET |= RESET_BIT;
  Delay1ms(500);
  RESET &= ~RESET_BIT;
  Delay1ms(500);
  RESET |= RESET_BIT;
  Delay1ms(500);

  // initialize eUSCI
  UCA3CTLW0 = 0x0001;                   // hold the eUSCI module in reset mode
  // configure UCA3CTLW0 for:
  // bit15      UCCKPH = 1; data shifts in on first edge, out on following edge
  // bit14      UCCKPL = 0; clock is low when inactive
  // bit13      UCMSB = 1; MSB first
  // bit12      UC7BIT = 0; 8-bit data
  // bit11      UCMST = 1; master mode
  // bits10-9   UCMODEx = 00; UCSTE active low
  // bit8       UCSYNC = 1; synchronous mode
  // bits7-6    UCSSELx = 2; eUSCI clock SMCLK
  // bits5-2    reserved
  // bit1       UCSTEM = 0; UCSTE pin enables slave
  // bit0       UCSWRST = 1; reset enabled
  UCA3CTLW0 = 0xA981;
  // set the baud rate for the eUSCI which gets its clock from SMCLK
  // Clock_Init48MHz() from ClockSystem.c sets SMCLK = HFXTCLK/4 = 12 MHz
  // if the SMCLK is set to 12 MHz, divide by 3 for 4 MHz baud clock
  UCA3BRW = 3;
  // modulation is not used in SPI mode, so clear UCA3MCTLW
  UCA3MCTLW = 0;
  P9SEL0 |= 0xE0;
  P9SEL1 &= ~0xE0;
  P9SEL0 &= ~0x0C;
  P9SEL1 &= ~0x0C;                      // configure P9.7, P9.5, and P9.4 as primary module function
  UCA3CTLW0 &= ~0x0001;                 // enable eUSCI module
  UCA3IE &= ~0x0003;                    // disable interrupts

  if(cmdList) commandList(cmdList);
}
예제 #9
0
파일: ASP-LFC.c 프로젝트: jpwright/asp-lfc
void Delay100ms(uint8_t x)
{
	uint8_t i;
	for (i=0;i<x;i++)
	{
		Delay1ms(100);
	}
}
예제 #10
0
/////////////LCM initial
void LCD_Initial(void)
{
    PLL_ini();
	LCD_CmdWrite(0x10);	 //
	LCD_DataWrite(0x0C);   //     65k   8bit mcu interface

	LCD_CmdWrite(0x04);    //PCLK
	LCD_DataWrite(0x81);   //
	Delay1ms(1);

	 //Horizontal set
	LCD_CmdWrite(0x14); //HDWR//Horizontal Display Width Setting Bit[6:0]
	LCD_DataWrite(0x63);//Horizontal display width(pixels) = (HDWR + 1)*8
	LCD_CmdWrite(0x15);//Horizontal Non-Display Period Fine Tuning Option Register (HNDFTR)
	LCD_DataWrite(0x00);//Horizontal Non-Display Period Fine Tuning(HNDFT) [3:0]
	LCD_CmdWrite(0x16); //HNDR//Horizontal Non-Display Period Bit[4:0]
	LCD_DataWrite(0x03);//Horizontal Non-Display Period (pixels) = (HNDR + 1)*8
	LCD_CmdWrite(0x17); //HSTR//HSYNC Start Position[4:0]
	LCD_DataWrite(0x03);//HSYNC Start Position(PCLK) = (HSTR + 1)*8
	LCD_CmdWrite(0x18); //HPWR//HSYNC Polarity ,The period width of HSYNC.
	LCD_DataWrite(0x0B);//HSYNC Width [4:0]   HSYNC Pulse width(PCLK) = (HPWR + 1)*8
	 //Vertical set
	LCD_CmdWrite(0x19); //VDHR0 //Vertical Display Height Bit [7:0]
	LCD_DataWrite(0xdf);//Vertical pixels = VDHR + 1
	LCD_CmdWrite(0x1a); //VDHR1 //Vertical Display Height Bit [8]
	LCD_DataWrite(0x01);//Vertical pixels = VDHR + 1
	LCD_CmdWrite(0x1b); //VNDR0 //Vertical Non-Display Period Bit [7:0]
	LCD_DataWrite(0x20);//Vertical Non-Display area = (VNDR + 1)
	LCD_CmdWrite(0x1c); //VNDR1 //Vertical Non-Display Period Bit [8]
	LCD_DataWrite(0x00);//Vertical Non-Display area = (VNDR + 1)
	LCD_CmdWrite(0x1d); //VSTR0 //VSYNC Start Position[7:0]
	LCD_DataWrite(0x16);//VSYNC Start Position(PCLK) = (VSTR + 1)
	LCD_CmdWrite(0x1e); //VSTR1 //VSYNC Start Position[8]
	LCD_DataWrite(0x00);//VSYNC Start Position(PCLK) = (VSTR + 1)
	LCD_CmdWrite(0x1f); //VPWR //VSYNC Polarity ,VSYNC Pulse Width[6:0]
	LCD_DataWrite(0x01);//VSYNC Pulse Width(PCLK) = (VPWR + 1)



	Active_Window(0,799,0,479);

	LCD_CmdWrite(0x8a);//PWM setting
	LCD_DataWrite(0x80);
	LCD_CmdWrite(0x8a);//PWM setting
	LCD_DataWrite(0x81);//open PWM
	LCD_CmdWrite(0x8b);//Backlight brightness setting
	LCD_DataWrite(0xff);//Brightness parameter 0xff-0x00
}
예제 #11
0
파일: ST7735.c 프로젝트: howlanjo/Project-2
// Companion code to the above tables.  Reads and issues
// a series of LCD commands stored in ROM byte array.
void static commandList(const uint8_t *addr) {

  uint8_t numCommands, numArgs;
  uint16_t ms;

  numCommands = *(addr++);               // Number of commands to follow
  while(numCommands--) {                 // For each command...
    writecommand(*(addr++));             //   Read, issue command
    numArgs  = *(addr++);                //   Number of args to follow
    ms       = numArgs & DELAY;          //   If hibit set, delay follows args
    numArgs &= ~DELAY;                   //   Mask out delay bit
    while(numArgs--) {                   //   For each argument...
      writedata(*(addr++));              //     Read, issue argument
    }

    if(ms) {
      ms = *(addr++);             // Read post-command delay time (ms)
      if(ms == 255) ms = 500;     // If 255, delay for 500 ms
      Delay1ms(ms);
    }
  }
}
예제 #12
0
void Delay100ms(uint i)
{
    while(i--)
	Delay1ms(100);
}
예제 #13
0
파일: ST7735.c 프로젝트: howlanjo/Project-2
void DelayWait10ms(uint32_t n)
{
  Delay1ms(n*10);
}
예제 #14
0
static void LCD_Initial(void)
{
    RA8875_PLL_ini();
    LCD_CmdWrite(0x10);  //SYSR   bit[4:3]=00 256 color  bit[2:1]=  00 8bit MPU interface
    LCD_DataWrite(0x0f);   /* [3:2]-256/65K [1:0]-8/18bit */

#ifdef P800x480
//AT070TN92  setting
//==============	Display Window	800x480 ==================
    LCD_CmdWrite(0x04);  //PCLK inverse
    LCD_DataWrite(0x81);
    Delay1ms(1);

    //Horizontal set
    LCD_CmdWrite(0x14); //HDWR//Horizontal Display Width Setting Bit[6:0]
    LCD_DataWrite(0x63);//Horizontal display width(pixels) = (HDWR + 1)*8
    LCD_CmdWrite(0x15);//Horizontal Non-Display Period Fine Tuning Option Register (HNDFTR)
    LCD_DataWrite(0x03);//Horizontal Non-Display Period Fine Tuning(HNDFT) [3:0]
    LCD_CmdWrite(0x16); //HNDR//Horizontal Non-Display Period Bit[4:0]
    LCD_DataWrite(0x03);//Horizontal Non-Display Period (pixels) = (HNDR + 1)*8
    LCD_CmdWrite(0x17); //HSTR//HSYNC Start Position[4:0]
    LCD_DataWrite(0x02);//HSYNC Start Position(PCLK) = (HSTR + 1)*8
    LCD_CmdWrite(0x18); //HPWR//HSYNC Polarity ,The period width of HSYNC.
    LCD_DataWrite(0x00);//HSYNC Width [4:0]   HSYNC Pulse width(PCLK) = (HPWR + 1)*8

    //Vertical set
    LCD_CmdWrite(0x19); //VDHR0 //Vertical Display Height Bit [7:0]
    LCD_DataWrite(0xdf);//Vertical pixels = VDHR + 1
    LCD_CmdWrite(0x1a); //VDHR1 //Vertical Display Height Bit [8]
    LCD_DataWrite(0x01);//Vertical pixels = VDHR + 1
    LCD_CmdWrite(0x1b); //VNDR0 //Vertical Non-Display Period Bit [7:0]
    LCD_DataWrite(0x14);//Vertical Non-Display area = (VNDR + 1)
    LCD_CmdWrite(0x1c); //VNDR1 //Vertical Non-Display Period Bit [8]
    LCD_DataWrite(0x00);//Vertical Non-Display area = (VNDR + 1)
    LCD_CmdWrite(0x1d); //VSTR0 //VSYNC Start Position[7:0]
    LCD_DataWrite(0x06);//VSYNC Start Position(PCLK) = (VSTR + 1)
    LCD_CmdWrite(0x1e); //VSTR1 //VSYNC Start Position[8]
    LCD_DataWrite(0x00);//VSYNC Start Position(PCLK) = (VSTR + 1)
    LCD_CmdWrite(0x1f); //VPWR //VSYNC Polarity ,VSYNC Pulse Width[6:0]
    LCD_DataWrite(0x01);//VSYNC Pulse Width(PCLK) = (VPWR + 1)

    //Active window  set
    //setting active window X
    LCD_CmdWrite(0x30); //Horizontal Start Point 0 of Active Window (HSAW0)
    LCD_DataWrite(0x00); //Horizontal Start Point of Active Window [7:0]
    LCD_CmdWrite(0x31); //Horizontal Start Point 1 of Active Window (HSAW1)
    LCD_DataWrite(0x00); //Horizontal Start Point of Active Window [9:8]
    LCD_CmdWrite(0x34); //Horizontal End Point 0 of Active Window (HEAW0)
    LCD_DataWrite(0x1F); //Horizontal End Point of Active Window [7:0]
    LCD_CmdWrite(0x35); //Horizontal End Point 1 of Active Window (HEAW1)
    LCD_DataWrite(0x03); //Horizontal End Point of Active Window [9:8]

    //setting active window Y
    LCD_CmdWrite(0x32); //Vertical Start Point 0 of Active Window (VSAW0)
    LCD_DataWrite(0x00); //Vertical Start Point of Active Window [7:0]
    LCD_CmdWrite(0x33); //Vertical Start Point 1 of Active Window (VSAW1)
    LCD_DataWrite(0x00); //Vertical Start Point of Active Window [8]
    LCD_CmdWrite(0x36); //Vertical End Point of Active Window 0 (VEAW0)
    LCD_DataWrite(0xdf); //Vertical End Point of Active Window [7:0]
    LCD_CmdWrite(0x37); //Vertical End Point of Active Window 1 (VEAW1)
    LCD_DataWrite(0x01); //Vertical End Point of Active Window [8]

#endif
}
예제 #15
0
main()
{
        char idx ;              //宣告字元變數 idx
        unsigned int interval ; //宣告無號數整數變數 interval
        unsigned char color ;   //宣告無號數字元變數 color ,color=0(紅)color=1(綠),color=2(黃)
        idx=0 ;                 //令 idx = 0
        interval=0 ;            //令 interval = 0
        color=0 ;               //令 color = 0

        for( ; ;){
            CTRLLED=1 ;                         //關閉所有矩陣LED
            if((color== 0) || (color== 2)){     //若color=0(紅)或color=2(黃) 則
                P0=hwan[idx*2] ;                //取得資料表中第 idx*2 之資料,並輸出至P0
                LRED1=0 ;                       //使P0之資料輸出至上半部的矩陣LED(制能紅色)
                LRED1=1 ;
                P0=hwan[idx*2+1] ;              //取得資料表中第 idx*2+1 之資料,並輸出至P0
                LRED2=0 ;                       //使P0之資料輸出至下半部的矩陣LED(制能紅色)
                LRED2=1 ;
            }
            else{
                P0=0xff ;                       //否則 P0 輸出 11111111
                LRED1=0 ;                       //使P0之資料 11111111 輸出至上半部的矩陣LED
                LRED1=1 ;                               
                LRED2=0 ;                       //使P0之資料 11111111 輸出至下半部的矩陣LED
                LRED2=1 ;                       //使輸出為綠色
            }
            if((color== 1) || (color== 2)){     //若color=1(綠)或color=2(黃) 則
                P0=hwan[idx*2] ;                //取得資料表中第 idx*2 之資料,並輸出至P0
                LGREEN1=0 ;                     //使P0之資料輸出至上半部的矩陣LED(制能綠色)
                LGREEN1=1 ;
                P0=hwan[idx*2+1] ;              //取得資料表中第 idx*2 之資料,並輸出至P0
                LGREEN2=0 ;                     //使P0之資料輸出至下半部的矩陣LED(制能綠色)
                LGREEN2=1 ;                     //           (若紅色和綠色都被制能則會輸出黃色)
            }
            else{
                P0=0xff ;                       //否則 P0 輸出 11111111
                LGREEN1=0 ;                     //使P0之資料 11111111 輸出至上半部的矩陣LED
                LGREEN1=1 ;
                LGREEN2=0 ;                     //使P0之資料 11111111 輸出至下半部的矩陣LED
                LGREEN2=1 ;                     //使輸出為紅色
            }
            P1 &=0xf0 ;                         //令 P1 = P1 and 11110000 
            P1 |=idx ;                          //再取得掃描值輸出
            CTRLLED=0 ;                         //啟動矩陣LED
            idx++ ;                             //令 idx = idx + 1
            if(idx >=16){                       //若 idx 大於等於 16 (矩陣以顯示一次),則
                interval++ ;                    //設 interval = interval + 1
                idx=0 ;                         //令 idx = 0 ,重新在顯示一次
            }
                                                //延遲時間
            if(interval ==  INTERVAL3){         //如果 interval 等於 INTERVAL3(75) (再延遲 25 * 1ms) 則
                interval=0 ;                    //設 interval = 0 重新計算延遲時間
                color=0 ;                       //設 color = 0 轉換成紅色
            }
            else if(interval == INTERVAL2){     //否則如果 interval 等於 INTERVAL2(50) (再延遲 25 * 1ms) 則
                color=2 ;                       //設 color = 2 轉換成黃色
            }
            else if(interval == INTERVAL1){     //否則如果 interval 等於 INTERVAL1(25) (延遲 25 * 1ms) 則
                color=1 ;                       //設 color = 1 轉換成綠色
            }
            Delay1ms() ;                        //呼叫延遲 1 毫秒副程式
        }
}
예제 #16
0
delay3ms()              //延遲 3 毫秒之副程式
{
        Delay1ms() ;    //呼叫延遲 1 毫秒
        Delay1ms() ;    //呼叫延遲 1 毫秒
        Delay1ms() ;    //呼叫延遲 1 毫秒
}
예제 #17
0
파일: main.c 프로젝트: mwei0321/STCode
void delay_ms(unsigned int i)
{
   while(i--)Delay1ms();
}
예제 #18
0
파일: main.c 프로젝트: 44670/MagicLed
void delayms(unsigned int a) {
	unsigned int i;
	for (i=0;i<a;i++) Delay1ms();
}
예제 #19
0
파일: main.c 프로젝트: junstrix/car
void main(void)
{
	motor_fan_con(0);
	buzzer_led(0);
	init_sys();
	LcdInitiate();         //调用LCD初始化函数  
	Delay1ms(2);
	WriteInstruction(0x01);//清显示:清屏幕指令
	DisMenuInit();
	mo_forword_slow(); //调用慢速档
	while(!CarTurnLeft) { //AB段行驶
		if (DeviateLeftTrack) {
			mo_R_forword_slow();
		}
		if(DeviateRightTrack) {
			mo_L_forword_slow();
		}
		if (CHECK_COIN) { //检测硬币
			Delay1ms(5);
			if (CHECK_COIN) {
				mo_stop();
				buzzer_led(1);
				Delay1ms(500);
				mo_forword_slow();
				buzzer_led(0);
				Delay1ms(130);      //不能太小,不能太大,太小会冲出跑道,小了会多次检测!
				if (!CHECK_COIN) {
					count_coin++;
				}
			}
		}
		if (count_kk>=50&&count_kk<51) { //变量显示稳定控制
			ClearVarData();
			WriteVarData(0x05,mo_time);
			WriteVarData(0x0d,total_length);
			WriteVarData(0x45,count_coin);
			WriteVarData(0x4d,count_bottle);
		}
	}
	while(1){
		if (DeviateLeftTrack) {
			mo_R_forword();
		}
		if(DeviateRightTrack)	
		{
			mo_L_forword();
		}
		/*转角声控报警之奇淫巧技*/
		if((total_length >= 80 && total_length <= 110) ||\
				(total_length >= 190 && total_length <= 230) ||\
				(total_length >= 300 && total_length <= 360)){
			if(CarTurnLeft){
				mo_left();
				buzzer_led(1);
				Delay1ms(20);
				buzzer_led(0);
			}
			if (CarTurnRight) {
				mo_right();
				buzzer_led(1);
				Delay1ms(20);
				buzzer_led(0);
			}
		}
		else {
			if(CarTurnLeft){
				mo_left();
				Delay1ms(20);
				buzzer_led(0);
			}
			if (CarTurnRight) {
				mo_right();
				Delay1ms(20);
				buzzer_led(0);
			}
		}
		if (UpBottle) { //瓶子检测
			motor_fan_con(0);
			buzzer_led(1);
			Delay1ms(200);
			buzzer_led(0);
			if (NoBottle) {
				count_bottle++;
			}
		}
		if (DownBottle) {
			Delay1ms(2);
			if (DownBottle) {
				mo_stop();
				motor_fan_con(1);
				Delay1ms(250);
				mo_forword();
				motor_fan_con(0);
			}
			if (NoBottle) {
				count_bottle++;
				motor_fan_con(0);
			}
		}
		if (total_length>=430||mo_time>=90) { //终点
			mo_stop();
			Delay1ms(20);
			ClearVarData();
			WriteVarData(0x05,mo_time);
			WriteVarData(0x0d,total_length);
			WriteVarData(0x45,count_coin);
			WriteVarData(0x4d,count_bottle);
			EA = 0;
			while (1) {
				mo_stop();
			}
		}
		if (count_kk>=50&&count_kk<51) { //变量显示稳定控制
			ClearVarData();
			WriteVarData(0x05,mo_time);
			WriteVarData(0x0d,total_length);
			WriteVarData(0x45,count_coin);
			WriteVarData(0x4d,count_bottle);
		}
	}
}
예제 #20
0
void Delaynms(uint a)
{	uint i=a;
	while(i--)
		Delay1ms();
}