//////////////////////////////////////////////////////////////////////
//初始化SSD1306		
void OLED_Init(void)
{
    spi_base_address = spi_master_init(SPI0, SPI_MODE0, 0);
    if (spi_base_address == 0)
    {
        return ;
    }
    
		 nrf_gpio_cfg_output(OLED_RST); // OLED Reset pin
     nrf_gpio_cfg_output(OLED_RS);  // DC control pin
		 OLED_RST_Set();
     	OLED_RST_Clr();
    //	delay_ms(100);
		 nrf_delay_ms(100);
	   OLED_RST_Set(); 
		
	OLED_WR_Byte(0xAE,OLED_CMD); //关闭显示
	OLED_WR_Byte(0xD5,OLED_CMD); //设置时钟分频因子,震荡频率
	OLED_WR_Byte(80,OLED_CMD);   //[3:0],分频因子;[7:4],震荡频率
	OLED_WR_Byte(0xA8,OLED_CMD); //设置驱动路数
	OLED_WR_Byte(0X3F,OLED_CMD); //默认0X3F(1/64) 
	OLED_WR_Byte(0xD3,OLED_CMD); //设置显示偏移
	OLED_WR_Byte(0X00,OLED_CMD); //默认为0

	OLED_WR_Byte(0x40,OLED_CMD); //设置显示开始行 [5:0],行数.
													    
	OLED_WR_Byte(0x8D,OLED_CMD); //电荷泵设置
	OLED_WR_Byte(0x14,OLED_CMD); //bit2,开启/关闭
	OLED_WR_Byte(0x20,OLED_CMD); //设置内存地址模式
	OLED_WR_Byte(0x02,OLED_CMD); //[1:0],00,列地址模式;01,行地址模式;10,页地址模式;默认10;
	OLED_WR_Byte(0xA1,OLED_CMD); //段重定义设置,bit0:0,0->0;1,0->127;
	OLED_WR_Byte(0xC0,OLED_CMD); //设置COM扫描方向;bit3:0,普通模式;1,重定义模式 COM[N-1]->COM0;N:驱动路数
	OLED_WR_Byte(0xDA,OLED_CMD); //设置COM硬件引脚配置
	OLED_WR_Byte(0x12,OLED_CMD); //[5:4]配置
		 
	OLED_WR_Byte(0x81,OLED_CMD); //对比度设置
	//OLED_WR_Byte(0xEF,OLED_CMD); //1~255;默认0X7F (亮度设置,越大越亮)
//OLED_WR_Byte(0xFF,OLED_CMD); //1~255;默认0X7F (亮度设置,越大越亮)
   OLED_WR_Byte(OLED_Contrast,OLED_CMD); //1~255;默认0X7F (亮度设置,越大越亮)
	OLED_WR_Byte(0xD9,OLED_CMD); //设置预充电周期
	OLED_WR_Byte(0xf1,OLED_CMD); //[3:0],PHASE 1;[7:4],PHASE 2;
	OLED_WR_Byte(0xDB,OLED_CMD); //设置VCOMH 电压倍率
	OLED_WR_Byte(0x30,OLED_CMD); //[6:4] 000,0.65*vcc;001,0.77*vcc;011,0.83*vcc;

	OLED_WR_Byte(0xA4,OLED_CMD); //全局显示开启;bit0:1,开启;0,关闭;(白屏/黑屏)
	OLED_WR_Byte(0xA6,OLED_CMD); //设置显示方式;bit0:1,反相显示;0,正常显示	    						   
	OLED_WR_Byte(0xAF,OLED_CMD); //开启显示	 
	OLED_Clear();	
   

}	
Exemplo n.º 2
0
//初始化SSD1306					    
void OLED_Init(void)
{ 
//#if	(FB_OLED && FB_SPI_OLED)
//		spi_init(QN_SPI1, SPI_BITRATE(1000000), SPI_8BIT, SPI_MASTER_MOD);
//#endif
	
  oled_io_config();
	
	OLED_RST_Set();
	delay(100000);
	OLED_RST_Clr();
	delay(100000);
	OLED_RST_Set(); 
					  
	OLED_WR_Byte(0xAE,OLED_CMD);//--turn off oled panel
	OLED_WR_Byte(0x00,OLED_CMD);//---set low column address
	OLED_WR_Byte(0x10,OLED_CMD);//---set high column address
	OLED_WR_Byte(0x40,OLED_CMD);//--set start line address  Set Mapping RAM Display Start Line (0x00~0x3F)
	OLED_WR_Byte(0x81,OLED_CMD);//--set contrast control register
	OLED_WR_Byte(0xCF,OLED_CMD); // Set SEG Output Current Brightness
	OLED_WR_Byte(0xA1,OLED_CMD);//--Set SEG/Column Mapping     0xa0左右反置 0xa1正常
	OLED_WR_Byte(0xC8,OLED_CMD);//Set COM/Row Scan Direction   0xc0上下反置 0xc8正常
	OLED_WR_Byte(0xA6,OLED_CMD);//--set normal display
	OLED_WR_Byte(0xA8,OLED_CMD);//--set multiplex ratio(1 to 64)
	OLED_WR_Byte(0x3f,OLED_CMD);//--1/64 duty
	OLED_WR_Byte(0xD3,OLED_CMD);//-set display offset	Shift Mapping RAM Counter (0x00~0x3F)
	OLED_WR_Byte(0x00,OLED_CMD);//-not offset
	OLED_WR_Byte(0xd5,OLED_CMD);//--set display clock divide ratio/oscillator frequency
	OLED_WR_Byte(0x80,OLED_CMD);//--set divide ratio, Set Clock as 100 Frames/Sec
	OLED_WR_Byte(0xD9,OLED_CMD);//--set pre-charge period
	OLED_WR_Byte(0xF1,OLED_CMD);//Set Pre-Charge as 15 Clocks & Discharge as 1 Clock
	OLED_WR_Byte(0xDA,OLED_CMD);//--set com pins hardware configuration
	OLED_WR_Byte(0x12,OLED_CMD);
	OLED_WR_Byte(0xDB,OLED_CMD);//--set vcomh
	OLED_WR_Byte(0x40,OLED_CMD);//Set VCOM Deselect Level
	OLED_WR_Byte(0x20,OLED_CMD);//-Set Page Addressing Mode (0x00/0x01/0x02)
	OLED_WR_Byte(0x02,OLED_CMD);//
	OLED_WR_Byte(0x8D,OLED_CMD);//--set Charge Pump enable/disable
	OLED_WR_Byte(0x14,OLED_CMD);//--set(0x10) disable
	OLED_WR_Byte(0xA4,OLED_CMD);// Disable Entire Display On (0xa4/0xa5)
	OLED_WR_Byte(0xA6,OLED_CMD);// Disable Inverse Display On (0xa6/a7) 
	OLED_WR_Byte(0xAF,OLED_CMD);//--turn on oled panel
	
	OLED_WR_Byte(0xAF,OLED_CMD); /*display ON*/ 
	OLED_Clear();
	OLED_Set_Pos(0,0); 	
} 
Exemplo n.º 3
0
/****************************************************************************
*	函数名:oledInit
	输  入:void
	输  出:void
	功  能:OLED初始化函数
	备  注:无
*	日  期:2015.02.01
****************************************************************************/	  
void oledInit(void)
{
	oledGpioInit();
	OLED_RST_Set();
	delayMs(100);
	OLED_RST_Clr();
	delayMs(100);
	OLED_RST_Set(); 
					  
	oledWriteCmd(0xAE);//--turn off oled panel
	oledWriteCmd(0x02);//---set low column address
	oledWriteCmd(0x10);//---set high column address
	oledWriteCmd(0x40);//--set start line address  Set Mapping RAM Display Start Line (0x00~0x3F)
	oledWriteCmd(0x81);//--set contrast control register
	oledWriteCmd(0xCF); // Set SEG Output Current Brightness
	oledWriteCmd(0xA1);//--Set SEG/Column Mapping     0xa0左右反置 0xa1正常
	oledWriteCmd(0xC8);//Set COM/Row Scan Direction   0xc0上下反置 0xc8正常
	oledWriteCmd(0xA6);//--set normal display
	oledWriteCmd(0xA8);//--set multiplex ratio(1 to 64)
	oledWriteCmd(0x3f);//--1/64 duty
	oledWriteCmd(0xD3);//-set display offset	Shift Mapping RAM Counter (0x00~0x3F)
	oledWriteCmd(0x00);//-not offset
	oledWriteCmd(0xd5);//--set display clock divide ratio/oscillator frequency
	oledWriteCmd(0x80);//--set divide ratio, Set Clock as 100 Frames/Sec
	oledWriteCmd(0xD9);//--set pre-charge period
	oledWriteCmd(0xF1);//Set Pre-Charge as 15 Clocks & Discharge as 1 Clock
	oledWriteCmd(0xDA);//--set com pins hardware configuration
	oledWriteCmd(0x12);
	oledWriteCmd(0xDB);//--set vcomh
	oledWriteCmd(0x40);//Set VCOM Deselect Level
	oledWriteCmd(0x20);//-Set Page Addressing Mode (0x00/0x01/0x02)
	oledWriteCmd(0x02);//
	oledWriteCmd(0x8D);//--set Charge Pump enable/disable
	oledWriteCmd(0x14);//--set(0x10) disable
	oledWriteCmd(0xA4);// Disable Entire Display On (0xa4/0xa5)
	oledWriteCmd(0xA6);// Disable Inverse Display On (0xa6/a7) 
	oledWriteCmd(0xAF);//--turn on oled panel
	
	oledWriteCmd(0xAF); /*display ON*/ 
	oledClear();
	oledSetPosition(0,0); 	
}
Exemplo n.º 4
0
Arquivo: oled.c Projeto: tymbys/Watch
//≥х ЉїѓSSD1306					    
void OLED_Init(void)
{ 	
 
 	GPIO_InitTypeDef  GPIO_InitStructure;
 	

 	//RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC|RCC_APB2Periph_GPIOD|RCC_APB2Periph_GPIOG|RCC_APB2Periph_GPIOA|RCC_APB2Periph_GPIOB, ENABLE);

 	RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);



	//GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3|GPIO_Pin_6;	 //PD3,PD6Ќ∆Ќм д≥ц
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7|GPIO_Pin_6|GPIO_Pin_5|GPIO_Pin_4|GPIO_Pin_3;

 	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; //GPIO_Mode_Out_PP; 		 //Ќ∆Ќм д≥ц
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;//GPIO_Speed_50MHz;//Ћў∂»50MHz
 	//GPIO_Init(GPIOD, &GPIO_InitStructure);	  //≥х ЉїѓGPIOD3,6
 	GPIO_Init(GPIOA, &GPIO_InitStructure);
 	//GPIO_SetBits(GPIOD,GPIO_Pin_3|GPIO_Pin_6);	//PD3,PD6  д≥цЄя
 	GPIO_SetBits(GPIOA,GPIO_Pin_7|GPIO_Pin_6|GPIO_Pin_5|GPIO_Pin_4|GPIO_Pin_3);
/*
 #if OLED_MODE==1
 
 	GPIO_InitStructure.GPIO_Pin =0xFF; //PC0~7 OUTЌ∆Ќм д≥ц
 	GPIO_Init(GPIOC, &GPIO_InitStructure);
 	GPIO_SetBits(GPIOC,0xFF); //PC0~7 д≥цЄя

 	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13|GPIO_Pin_14|GPIO_Pin_15;				 //PG13,14,15 OUTЌ∆Ќм д≥ц
 	GPIO_Init(GPIOG, &GPIO_InitStructure);
 	GPIO_SetBits(GPIOG,GPIO_Pin_13|GPIO_Pin_14|GPIO_Pin_15);						 //PG13,14,15 OUT   д≥цЄя

 #else*/
/*
 	//GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0|GPIO_Pin_1;				 //PC0,1 OUTЌ∆Ќм д≥ц
 	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7|GPIO_Pin_6;
 	//GPIO_Init(GPIOC, &GPIO_InitStructure);
 	GPIO_Init(GPIOB, &GPIO_InitStructure);
 	//GPIO_SetBits(GPIOC,GPIO_Pin_0|GPIO_Pin_1);						 //PC0,1 OUT   д≥цЄя
 	GPIO_SetBits(GPIOB,GPIO_Pin_7|GPIO_Pin_6);

	//GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15;				 //PG15 OUTЌ∆Ќм д≥ц	  RST
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;
 	//GPIO_Init(GPIOG, &GPIO_InitStructure);
 	GPIO_Init(GPIOB, &GPIO_InitStructure);
 	//GPIO_SetBits(GPIOG,GPIO_Pin_15);						 //PG15 OUT   д≥цЄя
 	GPIO_SetBits(GPIOB,GPIO_Pin_5);
*/

 //#endif
  							  
	OLED_RST_Clr();
	delay_ms(100);
	OLED_RST_Set(); 
					  
	OLED_WR_Byte(0xAE,OLED_CMD); //єЎ±’ѕ‘ Њ
	OLED_WR_Byte(0xD5,OLED_CMD); //…и÷√ ±÷”Ј÷∆µ“т„”,’рµі∆µ¬ 
	OLED_WR_Byte(80,OLED_CMD);   //[3:0],Ј÷∆µ“т„”;[7:4],’рµі∆µ¬ 
	OLED_WR_Byte(0xA8,OLED_CMD); //…и÷√«э∂ѓ¬Ј э
	OLED_WR_Byte(0X3F,OLED_CMD); //ƒђ»ѕ0X3F(1/64) 
	OLED_WR_Byte(0xD3,OLED_CMD); //…и÷√ѕ‘ Њ∆Ђ“∆
	OLED_WR_Byte(0X00,OLED_CMD); //ƒђ»ѕќ™0

	OLED_WR_Byte(0x40,OLED_CMD); //…и÷√ѕ‘ Њњ™ Љ–– [5:0],–– э.
													    
	OLED_WR_Byte(0x8D,OLED_CMD); //µзЇ…±√…и÷√
	OLED_WR_Byte(0x14,OLED_CMD); //bit2£ђњ™∆ф/єЎ±’


	OLED_WR_Byte(0x20,OLED_CMD); //Set Memory Addressing Mode
	///
	//   Default => 0x02
		//     0x00 => Horizontal Addressing Mode
		//     0x01 => Vertical Addressing Mode
		//     0x02 => Page Addressing Mode
	//OLED_WR_Byte(0x02,OLED_CMD); //[1:0],00£ђЅ–µЎ÷Јƒ£ љ;01£ђ––µЎ÷Јƒ£ љ;10,“≥µЎ÷Јƒ£ љ;ƒђ»ѕ10;
	OLED_WR_Byte(0x02,OLED_CMD);
	///


	//OLED_WR_Byte(0xA1,OLED_CMD); //∂ќ÷Ў∂®“е…и÷√,bit0:0,0->0;1,0->127;
	//OLED_WR_Byte(0xC0,OLED_CMD); //…и÷√COM…®√иЈљѕт;bit3:0,∆’Ќ®ƒ£ љ;1,÷Ў∂®“еƒ£ љ COM[N-1]->COM0;N:«э∂ѓ¬Ј э
	//OLED_WR_Byte(0xDA,OLED_CMD); //Set COM Pins Hardware Configuration
	//OLED_WR_Byte(0x12,OLED_CMD); //[5:4]≈д÷√

	///---------------
	OLED_WR_Byte(0xA0,OLED_CMD); //отзеркалить 0xA0/0xA1 лево-право
	OLED_WR_Byte(0xC8,OLED_CMD); //Set COM Output Scan Direction отзеркалить ветх-низ C0h/C8h
	OLED_WR_Byte(0xDA,OLED_CMD); //Set COM Pins Hardware Configuration
	OLED_WR_Byte(0x18,OLED_CMD); //[5:4] отзеркалить ветх-низ
	//-----------------
		 
	OLED_WR_Byte(0x81,OLED_CMD); //∂‘±»∂»…и÷√
	OLED_WR_Byte(0xEF,OLED_CMD); //1~255;ƒђ»ѕ0X7F (ЅЅ∂»…и÷√,‘љіу‘љЅЅ)
	OLED_WR_Byte(0xD9,OLED_CMD); //…и÷√‘§≥дµз÷№∆Џ
	OLED_WR_Byte(0xf1,OLED_CMD); //[3:0],PHASE 1;[7:4],PHASE 2;
	OLED_WR_Byte(0xDB,OLED_CMD); //…и÷√VCOMH µз—є±∂¬ 
	OLED_WR_Byte(0x30,OLED_CMD); //[6:4] 000,0.65*vcc;001,0.77*vcc;011,0.83*vcc;

	OLED_WR_Byte(0xA4,OLED_CMD); //включить дисплей

	OLED_WR_Byte(0xA6,OLED_CMD); //нормальное отображение
	//OLED_WR_Byte(0xA7,OLED_CMD); //инвертированое отображение

	//OLED_WR_Byte(0xC8,OLED_CMD);

	OLED_WR_Byte(0xAF,OLED_CMD); //њ™∆фѕ‘ Њ	 
	OLED_Clear();
}  
Exemplo n.º 5
0
/*
*@功能:初始化SSD1106					    
*/
void OLED_Init(void)
{ 	
 
 	 
 	GPIO_InitTypeDef  GPIO_InitStructure;
 	
 	RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA|RCC_APB2Periph_GPIOB|RCC_APB2Periph_GPIOC, ENABLE);	 //使能PC,D,G端口时钟

	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9|GPIO_Pin_10|GPIO_Pin_11|GPIO_Pin_12|GPIO_Pin_13|GPIO_Pin_14|GPIO_Pin_15;	 //PD3,PD6推挽输出  
 	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; 		 //推挽输出
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;//速度50MHz
 	GPIO_Init(GPIOB, &GPIO_InitStructure);	  //初始化GPIOD3,6
 	GPIO_SetBits(GPIOB,GPIO_Pin_9|GPIO_Pin_10|GPIO_Pin_11|GPIO_Pin_12|GPIO_Pin_13|GPIO_Pin_14|GPIO_Pin_15);	//PD3,PD6 输出高

  //串口
 	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0|GPIO_Pin_1;				 //PC0,1 OUT推挽输出
 	GPIO_Init(GPIOC, &GPIO_InitStructure);
 	GPIO_SetBits(GPIOC,GPIO_Pin_0|GPIO_Pin_1);						 //PC0,1 OUT  输出高

	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15;				 //PG15 OUT推挽输出	  RST
 	GPIO_Init(GPIOG, &GPIO_InitStructure);
 	GPIO_SetBits(GPIOG,GPIO_Pin_15);						 //PG15 OUT  输出高




 
  OLED_RST_Set();
	delay_ms(100);
	OLED_RST_Clr();
	delay_ms(100);
	OLED_RST_Set(); 
					  
	OLED_WR_Byte(0xAE,OLED_CMD);//--turn off oled panel  cmd11
	
	OLED_WR_Byte(0x02,OLED_CMD);//---set low column address cmd1
	OLED_WR_Byte(0x10,OLED_CMD);//---set high column address cmd2
	
	OLED_WR_Byte(0x40,OLED_CMD);//--set start line address  Set Mapping RAM Display Start Line (0x00~0x3F) cmd4
	
	OLED_WR_Byte(0x81,OLED_CMD);//--set contrast control register
	OLED_WR_Byte(0xCF,OLED_CMD);// Set SEG Output Current Brightness
	OLED_WR_Byte(0xA1,OLED_CMD);//--Set SEG/Column Mapping     0xa0左右反置 0xa1正常
	OLED_WR_Byte(0xC8,OLED_CMD);//Set COM/Row Scan Direction   0xc0上下反置 0xc8正常
	OLED_WR_Byte(0xA6,OLED_CMD);//--set normal display
	OLED_WR_Byte(0xA8,OLED_CMD);//--set multiplex ratio(1 to 64)
	OLED_WR_Byte(0x3f,OLED_CMD);//--1/64 duty
	OLED_WR_Byte(0xD3,OLED_CMD);//-set display offset	Shift Mapping RAM Counter (0x00~0x3F)
	OLED_WR_Byte(0x00,OLED_CMD);//-not offset
	OLED_WR_Byte(0xd5,OLED_CMD);//--set display clock divide ratio/oscillator frequency
	OLED_WR_Byte(0x80,OLED_CMD);//--set divide ratio, Set Clock as 100 Frames/Sec
	OLED_WR_Byte(0xD9,OLED_CMD);//--set pre-charge period
	OLED_WR_Byte(0xF1,OLED_CMD);//Set Pre-Charge as 15 Clocks & Discharge as 1 Clock
	
	OLED_WR_Byte(0xDA,OLED_CMD);//--set com pins hardware configuration  cmd17
	OLED_WR_Byte(0x12,OLED_CMD);
	
	OLED_WR_Byte(0xDB,OLED_CMD);//--set vcomh
	OLED_WR_Byte(0x40,OLED_CMD);//Set VCOM Deselect Level
	OLED_WR_Byte(0x20,OLED_CMD);//-Set Page Addressing Mode (0x00/0x01/0x02)
	OLED_WR_Byte(0x02,OLED_CMD);//
	OLED_WR_Byte(0x8D,OLED_CMD);//--set Charge Pump enable/disable
	OLED_WR_Byte(0x14,OLED_CMD);//--set(0x10) disable
	OLED_WR_Byte(0xA4,OLED_CMD);// Disable Entire Display On (0xa4/0xa5)
	OLED_WR_Byte(0xA6,OLED_CMD);// Disable Inverse Display On (0xa6/a7) 
	OLED_WR_Byte(0xAF,OLED_CMD);//--turn on oled panel
	
	OLED_WR_Byte(0xAF,OLED_CMD); /*display ON*/ 
	OLED_Clear();
	OLED_Set_Pos(0,0); 	
}  
Exemplo n.º 6
0
//初始化SSD1306					    
void OLED_Init(void)
{ 	
  
  /*	 
  GPIO_InitTypeDef  GPIO_InitStructure;
  
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB|RCC_APB2Periph_GPIOD|RCC_APB2Periph_GPIOG, ENABLE);	 //使能PC,D,G端口时钟
  
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4|GPIO_Pin_5|GPIO_Pin_6|GPIO_Pin_7|GPIO_Pin_3|GPIO_Pin_8;	 //PD3,PD6推挽输出  
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; 		 //推挽输出
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;//速度50MHz
  GPIO_Init(GPIOD, &GPIO_InitStructure);	  //初始化GPIOD3,6
  GPIO_SetBits(GPIOD,GPIO_Pin_4|GPIO_Pin_5|GPIO_Pin_6|GPIO_Pin_7|GPIO_Pin_3|GPIO_Pin_8);	//PD3,PD6 输出高
  
#if OLED_MODE==1
  
  GPIO_InitStructure.GPIO_Pin =0xFF; //PC0~7 OUT推挽输出
  GPIO_Init(GPIOC, &GPIO_InitStructure);
  GPIO_SetBits(GPIOC,0xFF); //PC0~7输出高
  
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13|GPIO_Pin_14|GPIO_Pin_15;				 //PG13,14,15 OUT推挽输出
  GPIO_Init(GPIOG, &GPIO_InitStructure);
  GPIO_SetBits(GPIOG,GPIO_Pin_13|GPIO_Pin_14|GPIO_Pin_15);						 //PG13,14,15 OUT  输出高
  
#else
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0|GPIO_Pin_1;				 //PC0,1 OUT推挽输出
  GPIO_Init(GPIOC, &GPIO_InitStructure);
  GPIO_SetBits(GPIOC,GPIO_Pin_0|GPIO_Pin_1);						 //PC0,1 OUT  输出高
  
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15;				 //PG15 OUT推挽输出	  RST
  GPIO_Init(GPIOG, &GPIO_InitStructure);
  GPIO_SetBits(GPIOG,GPIO_Pin_15);						 //PG15 OUT  输出高
  
  
#endif
  */
//  MicoGpioInitialize( (mico_gpio_t)OLED_SPI_SCK, OUTPUT_PUSH_PULL );
//  MicoGpioInitialize( (mico_gpio_t)OLED_SPI_DIN, OUTPUT_PUSH_PULL );
//  MicoGpioInitialize( (mico_gpio_t)OLED_SPI_DC, OUTPUT_PUSH_PULL );
//  MicoGpioInitialize( (mico_gpio_t)OLED_SPI_CS, OUTPUT_PUSH_PULL );
//  
//  OLED_CS_Set();
  
  OSStatus err = kUnknownErr;
  err = MicoSpiInitialize(&micokit_spi_oled);
  UNUSED_PARAMETER(err);
  
  MicoGpioInitialize( (mico_gpio_t)OLED_SPI_DC, OUTPUT_PUSH_PULL );
    
  OLED_DC_Clr();
  OLED_RST_Clr();
  

  
  OLED_RST_Set();
  delay_ms(100);
  OLED_RST_Clr();
  delay_ms(100);
  OLED_RST_Set(); 
  
  OLED_WR_Byte(0xAE,OLED_CMD);//--turn off oled panel
  OLED_WR_Byte(0x00,OLED_CMD);//---set low column address
  OLED_WR_Byte(0x10,OLED_CMD);//---set high column address
  OLED_WR_Byte(0x40,OLED_CMD);//--set start line address  Set Mapping RAM Display Start Line (0x00~0x3F)
  OLED_WR_Byte(0x81,OLED_CMD);//--set contrast control register
  OLED_WR_Byte(0xCF,OLED_CMD); // Set SEG Output Current Brightness
  OLED_WR_Byte(0xA1,OLED_CMD);//--Set SEG/Column Mapping     0xa0左右反置 0xa1正常
  OLED_WR_Byte(0xC8,OLED_CMD);//Set COM/Row Scan Direction   0xc0上下反置 0xc8正常
  OLED_WR_Byte(0xA6,OLED_CMD);//--set normal display
  OLED_WR_Byte(0xA8,OLED_CMD);//--set multiplex ratio(1 to 64)
  OLED_WR_Byte(0x3f,OLED_CMD);//--1/64 duty
  OLED_WR_Byte(0xD3,OLED_CMD);//-set display offset	Shift Mapping RAM Counter (0x00~0x3F)
  OLED_WR_Byte(0x00,OLED_CMD);//-not offset
  OLED_WR_Byte(0xd5,OLED_CMD);//--set display clock divide ratio/oscillator frequency
  OLED_WR_Byte(0x80,OLED_CMD);//--set divide ratio, Set Clock as 100 Frames/Sec
  OLED_WR_Byte(0xD9,OLED_CMD);//--set pre-charge period
  OLED_WR_Byte(0xF1,OLED_CMD);//Set Pre-Charge as 15 Clocks & Discharge as 1 Clock
  OLED_WR_Byte(0xDA,OLED_CMD);//--set com pins hardware configuration
  OLED_WR_Byte(0x12,OLED_CMD);
  OLED_WR_Byte(0xDB,OLED_CMD);//--set vcomh
  OLED_WR_Byte(0x40,OLED_CMD);//Set VCOM Deselect Level
  OLED_WR_Byte(0x20,OLED_CMD);//-Set Page Addressing Mode (0x00/0x01/0x02)
  OLED_WR_Byte(0x02,OLED_CMD);//
  OLED_WR_Byte(0x8D,OLED_CMD);//--set Charge Pump enable/disable
  OLED_WR_Byte(0x14,OLED_CMD);//--set(0x10) disable
  OLED_WR_Byte(0xA4,OLED_CMD);// Disable Entire Display On (0xa4/0xa5)
  OLED_WR_Byte(0xA6,OLED_CMD);// Disable Inverse Display On (0xa6/a7) 
  OLED_WR_Byte(0xAF,OLED_CMD);//--turn on oled panel
  
  OLED_WR_Byte(0xAF,OLED_CMD); /*display ON*/ 
  OLED_Clear();
  OLED_Set_Pos(0,0); 	
}