Пример #1
0
OSStatus user_modules_init(void)
{
  OSStatus err = kUnknownErr;
  
  // init DC Motor(GPIO)
  dc_motor_init();
  dc_motor_set(0);   // off
  
  // init RGB LED(P9813)
  hsb2rgb_led_init();
  hsb2rgb_led_open(0, 0, 0);  // off
  
  // init OLED
  OLED_Init();
  //OLED_Clear();
  LCD_Clear(0x00);
  OLED_ShowString(20,0,"M X C H I P");
  OLED_ShowString(20,3,(uint8_t*)DEFAULT_DEVICE_NAME); 
  OLED_ShowString(0,6,"T: 0C  H: 0%");
  
  // init Light sensor(ADC)
  light_sensor_init();
  
  // init infrared sensor(ADC)
  infrared_reflective_init();
  
  // init user key1 && key2
  user_key1_init();
  user_key2_init();
  
  err = kNoErr;
 
  return err;
}
Пример #2
0
int main(void)
{
	SysTick_init();
	NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);	
	uart_init(115200);
	
	Struct_Init();
	Pid_Init();
	
	MotoPwm_Init();
	
	OLED_Init();
	Key_Init();
	
	I2cMaster_Init();
  mpu_dmp_init();	
	GPIO_Config();
	
	Filter_Init();
	
//	NRF_Usart_Pin_Init();//无线初始化
//	NRF_Read_Live_Init();//无线在线传输	
//  ReadData_Init();
	
	Scheduler_Init();
	
  while(1)
	{
		Scheduler_Loop();
	}
}
/*******************************************************************************
 * @fn      userAppInit
 *
 * @brief   user Application init
 *
 * @param   void
 *
 * @return  none
 */
void userAppInit(void)
{
	OLED_Init();
// 电池状态读初始化I2C	
    SMB_Init(); 
// 串口初始化	
	bspUartInit();  
	
// 按键初始化要等系统稳定后,防止外部中断引起系统死机
	KEY_Init();

//电池状态检测初始化
	chargeDetection_Init();

	//OLED_ShowString(40,32, "WiCore"); 
	OLED_Clear();
	
	// Create one-shot clocks for internal periodic events.
	Util_constructClock(&periodicClock_10ms, userApp_clockHandler,
	                  10, 0, false, USER_10MS_EVT);
#ifndef INCLUDE_CLKSTOP	
	systemState.powerOffFlag = 1;
	Util_startClock(&periodicClock_10ms);
#else
	Util_stopClock(&periodicClock_10ms);

#endif	
}
Пример #4
0
int main(void)
{
	delay_init();	    	
	NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); 
	uart_init(115200);	 //串口初始化为115200
	Uart2_Init(115200);
	OLED_Init();
	LED_Init();
	OLED_Clear(); 	
	KEY_Init();//IO初始化
	TIM3_Int_Init(499,7199);//10Khz的计数频率,计数到500为50ms  
	NET_Init();
	ConnectToDevice();
	delay_ms(300);
	LED2 = 0;
	delay_ms(100);
	LED2 = 1;
	EEPROM_Init();
	// ReadLedStatusFromFlash();
	StartToUploadFlag = 1;
	while(1) 
	{		
		MainMenuIntoSubMenu();
		SwitchDetect();
	}
}
Пример #5
0
void sys_driver_init()
{
  //open screen
  gpio_setup(SCREES_DC, GPIO_OUTPUT);
  gpio_write(SCREES_DC, 0);
  //screen reset
  gpio_setup(SCREES_RES, GPIO_OUTPUT);
  gpio_write(SCREES_RES, 1);
  
  //rgb led
  uint8_t led_pin[] = {28, 29, 30};
  light_setup(led_pin, 0);
  

  //init screen
  SSD1306_Init_Struct init_struct;
  init_struct.SCL = 9;
  init_struct.SDA = 8;

  ssd1306_config(&init_struct);
  
  OLED_Init();    
  OLED_Clear();
  
  gfx_init_screen((uint8_t *)&screen, 128, 32, 1);
  gfx_clear();
  OLED_Refresh_all();
  
  //hall task
  gpio_change_point = NULL;
  gpio_watch(HALL, GPIO_FALLING);
  
  //button
  gpio_setup(BUTTON, GPIO_INPUT_PULLUP);
}
Пример #6
0
/*************************************************************************
*                             野火嵌入式开发工作室
*
*  函数名称:Task_Start
*  功能说明:启动任务,初始化滴答时钟
*  参数说明:p_arg       没用
*  函数返回:无
*  修改时间:2012-2-10
*  备    注:
*************************************************************************/
void Task_Start(void *p_arg)
{
  /**************** 初始化 系统滴答时钟 :用于定时任务调度****************/
  u32  cnts;
  cnts = core_clk_mhz * ( (u32)1000000u / (u32)OS_TICKS_PER_SEC );       /* Determine nbr SysTick increments.                    */
  OS_CPU_SysTickInit(cnts);                                                     /* Init uC/OS periodic time src (SysTick).              */


#if (OS_TASK_STAT_EN > 0)
  /*       开启统计任务           */
  OSStatInit();
#endif


  (void)p_arg;    // 'p_arg' 并没有用到,防止编译器提示警告
  

  /******************* 用户任务区 ************************/
  u32 i = 0;
  
  OLED_Init(); 
  OLED_P6x8Str(0,0,"This is a test",0);
  
  while(1)
  {
    sprintf(mystr,"count:%d",i++); 
    OLED_P6x8Str(0,3,mystr,0);
    OSTimeDlyHMSM(0, 0, 0, 10);
  }
}
Пример #7
0
int main()
{

	Xint16 audio_data[128];
	int i;
	u8 *oled_equalizer_buf=(u8 *)malloc(128*sizeof(u8));
	Xil_Out32(OLED_BASE_ADDR,0xff);
	OLED_Init();			//oled init
	IicConfig(XPAR_XIICPS_0_DEVICE_ID);
	AudioPllConfig(); //enable core clock for ADAU1761
	AudioConfigure();

	xil_printf("ADAU1761 configured\n\r");

	/*
	 * perform continuous read and writes from the codec that result in a loopback
	 * from Line in to Line out
	 */

	while(1)
	{
		get_audio(audio_data);
		for(i=0;i<128;i++)
		{
			oled_equalizer_buf[i]=audio_data[i]>>18;
		}
		OLED_Clear();
		OLED_Equalizer_128(oled_equalizer_buf);
	}
    return 0;
}
Пример #8
0
Файл: main.c Проект: mybays/lm3s
//OLED初始化
void Init_OLED(void)
{
	//Setup the OLED controller interface clock to 1MHz
	OLED_Init(1000000);

	//Print the header "Periodic ADC" on the display
	OLED_StringDraw("Periodic ADC",18,24,15);
}
Пример #9
0
/*lint -save  -e970 Disable MISRA rule (6.3) checking. */
int main(void)
/*lint -restore Enable MISRA rule (6.3) checking. */
{
	/* Write your local variable definition here */

	/*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
 	PE_low_level_init();
	/*** End of Processor Expert internal initialization.                    ***/

	/* Write your code here */
	/* For example: for(;;) { } */

	Boot_Check();
	AD1_Calibrate(TRUE);
	OLED_Init();
	unsigned char buffer[64*4];
	ClearScr(buffer,0);
	OLED_Display(buffer);
	DecoderInit();
	int T = 0;
	for(;;) {
		T++;
		ClearScr(buffer,0);
		for (int x = 0;x<64;x++)
		{
			buffer[Reader.Sync * 64 + x] = 255;
		}

		if (Reader.Sync == AUDIOREADER_SYNCED)
		{
			for (int i =0;i<theprogress/8;i++)
			{
				buffer[i] = 0xff;
			}

		}
		//else
		{
			for(int i =0 ;i<64;i++)
			{
				int y =  16 + (((History[i]-32768) * 15)/400);
				if (y>= 0 && y< 32) SetPixel(buffer, i, y);
			}
		}
		OLED_Display(buffer);

	}
	/*** Don't write any code pass this line, or it will be deleted during code generation. ***/
  /*** RTOS startup code. Macro PEX_RTOS_START is defined by the RTOS component. DON'T MODIFY THIS CODE!!! ***/
  #ifdef PEX_RTOS_START
    PEX_RTOS_START();                  /* Startup of the selected RTOS. Macro is defined by the RTOS component. */
  #endif
  /*** End of RTOS startup code.  ***/
  /*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/
  for(;;){}
  /*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/
} /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/
void ICACHE_FLASH_ATTR oled_init() {
	OLED_Init();
	OLED_ON();
	OLED_Print(0, 0, " WXIT Smart Lab", 2);
	os_timer_disarm(&clean_oled_timer);
	os_timer_setfn(&clean_oled_timer, (os_timer_func_t *) clean_oled_cb,
			(void *) 0);
	os_timer_arm(&clean_oled_timer, CLEAN_OLED_DELAY, 1);
}
Пример #11
0
void osd_init(void)
{
	OLED_Init();			//3?¨º??¡¥OLED  
	OLED_Clear()  	; 
	osd_line_1to4_all_disp();

	
	
	
}
Пример #12
0
void osd_test(void)
{	u8 t;
		OLED_Init();			//3?¨º??¡¥OLED  
		OLED_Clear()  	; 
	
		t=' ';
		OLED_ShowCHinese(0,0,0);//?D
				OLED_ShowCHinese(18,0,1);//?¡ã
		OLED_ShowCHinese(36,0,2);//?¡ã
		OLED_ShowCHinese(54,0,3);//¦Ì?
		OLED_ShowCHinese(72,0,4);//¡Á¨®
		OLED_ShowCHinese(90,0,5);//??
		OLED_ShowCHinese(108,0,6);//??
	while(1) 
	{		
		OLED_Clear();
		OLED_ShowCHinese(0,0,0);//?D
		OLED_ShowCHinese(18,0,1);//?¡ã
		OLED_ShowCHinese(36,0,2);//?¡ã
		OLED_ShowCHinese(54,0,3);//¦Ì?
		OLED_ShowCHinese(72,0,4);//¡Á¨®
		OLED_ShowCHinese(90,0,5);//??
		OLED_ShowCHinese(108,0,6);//??
		OLED_ShowString(6,3,"0.96' OLED TEST",16);

				OLED_ShowString(6,4,"0.96' OLED TEST",16);
		OLED_ShowString(0,5,"0.96' OLED TEST",16);

		OLED_ShowString(0,6,"0.96' OLED TEST",16);
		OLED_ShowString(1,7,"0.96' OLED TEST",16);

		OLED_ShowString(6,3,"0.96' OLED TEST",16);

		//OLED_ShowString(8,2,"ZHONGJINGYUAN");  
	 //	OLED_ShowString(20,4,"2014/05/01");  
		OLED_ShowString(0,6,"ASCII:",16);  
		OLED_ShowString(63,6,"CODE:",16);  
		OLED_ShowChar(48,6,t,16);//??¨º?ASCII¡Á?¡¤?	   
		t++;
		if(t>'~')t=' ';
		OLED_ShowNum(103,6,t,3,16);//??¨º?ASCII¡Á?¡¤?¦Ì????¦Ì 	
		rt_thread_delay(1000*3);


		OLED_DrawBMP(0,0,128,8,BMP1);  //¨ª?????¨º?(¨ª?????¨º?¨¦¡Â¨®?¡ê?¨¦¨²3¨¦¦Ì?¡Á?¡À¨ª??¡ä¨®¡ê??¨¢??¨®????¨¤????¡ê?FLASH????8K¨°???¨¦¡Â¨®?)
		rt_thread_delay(1000*3);

		OLED_DrawBMP(0,0,128,8,BMP1);
		rt_thread_delay(1000*3);


	}	
	
}
Пример #13
0
void InitModules(void)
{
    GPIO_Digital_Input( &PTB_PDOR, _GPIO_PINMASK_13 );

    OLED_Init();
    OLED_SetFont( guiFont_Tahoma_8_Regular, OLED_COLOR_WHITE, 0 );
//    OLED_DrawImage( &hexiwearLogo_bmp, 0, 0 );
    OLED_DrawImage( &fire_off_bmp, 0, 0 );

    ADC0_Init();
}
Пример #14
0
void Components_Init(void)
{
	I2C_DRV_MasterInit(FSL_FS_I2C, &FS_I2C_MasterState);
	I2C_DRV_MasterSetBaudRate(FSL_FS_I2C, &FS_I2C_MasterConfig);

	EDMA_DRV_Init( &DMA_controller_State, &DMA_controller_InitConfig0 );
	DSPI_DRV_EdmaMasterInit(FSL_OLED_SPI, &OLED_SPI_MasterState, &OLED_SPI_MasterConfig, &OLED_SPI_dmaTcd);
	DSPI_DRV_EdmaMasterConfigureBus(FSL_OLED_SPI, &OLED_SPI_BusConfig, &OLED_SPI_calculatedBaudRate);

	OLED_Init( &oledModule, &oledSettings );
}
Пример #15
0
int main()
{
    Xil_Out32(OLED_BASE_ADDR,0xff);
    OLED_Init();
    OLED_ShowString(0,3, "LHC OLED TEST");

    OLED_Refresh_Gram();

    while(1);

    return 0;
}
Пример #16
0
/**
 * initialize modules
 */
void MenuDriver_Init(void)
{
  uint8_t
    moduleStatus = OLED_Init( &oledModule, &oledSettings );

  if ( 0 != moduleStatus )
  {
    catch(11);
  }

  MenuDriver_LoadScreen(MENU_NAVIGATION_ROOT , NULL);
}
Пример #17
0
/* \brief LED and AUDIO initialization
 *
 */
void system_init()
{
	Xil_Out32(OLED_BASE_ADDR,0xff);
	OLED_Init();							   //OLED initialization
	IicConfig(XPAR_XIICPS_0_DEVICE_ID);
	AudioPllConfig(); 						   //enable core clock for ADAU1761
	AudioConfigure();
	DMA_Congfig(DMA_DEV_ID);
	//Disable cache on OCM
	Xil_SetTlbAttributes(0x00000000,0x14de2);

}
/** Handle the 'serialPrintln' command */
void handleSerialPrintln(ArduinoCustom_serialPrintln serialPrintln,char* originator) {
  unsigned int len = 0;
  memset(buffer,0,300);
  OLED_Init();
  char oled_show_line[OLED_DISPLAY_MAX_CHAR_PER_ROW+1] = {'\0'};
  baseEvents_log("%s",serialPrintln.message);
  snprintf(oled_show_line, OLED_DISPLAY_MAX_CHAR_PER_ROW+1, "%s",serialPrintln.message);
  OLED_ShowString(OLED_DISPLAY_COLUMN_START, OLED_DISPLAY_ROW_3, (uint8_t*)oled_show_line);
  if (len = sw_acknowledge(hardwareId, "Message sent to Serial.println().", buffer, sizeof(buffer), originator)) {
    mqtt_publish(&broker_mqtt,outbound,(char*)buffer,len,0);
  }
}
Пример #19
0
int main2(void)
{
  #if PROFILING == 1
    volatile unsigned long delay;
  #endif
	/* Initialize 8MHz clock */
	SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_XTAL_8MHZ | SYSCTL_OSC_MAIN);
  OLED_Init(15);
  ADC_Init(1000);
  ADC_Open(0);
  ADC_Open(1);
  SH_Init();
  OS_Init();
  OS_MailBox_Init();
  SH_Init();
  
  //********initialize communication channels
  OS_MailBox_Init();
  OS_Fifo_Init(32);
  
  NumCreated = 0;
  NumSamples = 0;
  MaxJitter = 0;       // OS_Time in 20ns units
  MinJitter = 10000000;
  
  #if PROFILING
    // intialize port b pins as specified by PINS mask
    // for digital output for use in profiling threads
    SYSCTL_RCGC2_R |= SYSCTL_RCGC2_GPIOB;
    delay = SYSCTL_RCGC2_R;
    GPIO_PORTB_DIR_R |= PINS;
    GPIO_PORTB_DEN_R |= PINS;
    GPIO_PORTB_DATA_R &= ~PINS;
  #endif
  
  // testing/debugging stuff
  OS_Add_Periodic_Thread(&DAS,2,1);
//  OS_AddButtonTask(&dummyButtonTask, 1);
  OS_AddButtonTask(&ButtonPush, 1);
  OS_AddDownTask(&ButtonPush, 1);
  
//   NumCreated += OS_AddThread(&jerkTask, 0, 6);
//   NumCreated += OS_AddThread(&dummyTask3, 0, 7);
//   NumCreated += OS_AddThread(&dummyTask1, 0, 2);
  NumCreated += OS_AddThread(&PID, 128, 5);
//   NumCreated += OS_AddThread(&dummyTask2, 0, 2);
  NumCreated += OS_AddThread(&Consumer, 128, 0);
  NumCreated += OS_AddThread(&SH_Shell, 128, 6);
  OS_Launch(TIMESLICE);
	
	/* Loop indefinitely */
  while(1);
}
Пример #20
0
/***********************************************************
 *功能:	初始化调试功能
 *形参:
 *      	无
 *返回:
 *      	无
 */
void InitDebug(void)
{	
	//Initbutten();		//按键
	//oled
	enter_critical();
	OLED_Init();
	exit_critical();
	//串口
	uart_init(Debug_UARTx, 115200);
	uart_irq_EN(Debug_UARTx);
	
	gpio_Interrupt_init(DEBUG_PIN, GPI_UP_PF, GPI_DISAB);
}
Пример #21
0
void InitModules()
{
    OLED_Init();
    OLED_DrawImage( &airQuality_bmp, 0, 0 );

    OLED_SetFont( guiFont_Tahoma_8_Regular, OLED_COLOR_BLACK, 0 );
    OLED_WriteText( valText, 25, 75 );

    /** initialize ADC */
    ADC0_Init();

    /** pause for 100ms for ADC module stabilization */
    Delay_ms(100);
}
Пример #22
0
//各个外设的初始化
void Peripheral_Init(void)
{
	// 中断向量表配置
	NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
	
	PS_Init();	
    KEY_Init();	
	STATU_Init();
	LED_Init();
	BEEP_Init();
    CAN1_Init();
	CAN2_Init();
    OLED_Init();
    ADC_Configuration();
}
void system_init()
{
    // OLED Init
    OLED_Init();
    OLED_FillScreen(OLED_COLOR_BLACK);

    // GPIO Init
    R_LED = 1;
    G_LED = 1;
    B_LED = 1;
    GPIO_Digital_Output(&PTC_PDOR, _GPIO_PINMASK_8);
    GPIO_Digital_Output(&PTD_PDOR, _GPIO_PINMASK_0);
    GPIO_Digital_Output(&PTC_PDOR, _GPIO_PINMASK_9);
    GPIO_Analog_Input(&PTB_PDIR, _GPIO_PINMASK_6);    // AN
    GPIO_Analog_Input(&PTB_PDIR, _GPIO_PINMASK_7);    // INT
    GPIO_Digital_Output(&PTA_PDOR, _GPIO_PINMASK_4);  // PWM
    GPIO_Digital_Output(&PTB_PDOR, _GPIO_PINMASK_9);  // Vibration PIN
    PTB_PDOR = 0;

    // PWM Init
    current_duty = 0;
    pwm_period = PWM_FTM0_Init(200,
                               _PWM_EDGE_ALIGNED_PWM,
                                _PWM_CHANNEL_1, 
                                &_GPIO_Module_PWM0_PTA4);
    PWM_FTM0_Set_Duty(0, _PWM_NON_INVERTED, _PWM_CHANNEL_1);   // Set duty ratio
    PWM_FTM0_Start(_PWM_CHANNEL_1);

    Delay_ms(100);

    // Display text
    OLED_DrawBox(0, 0, 96, 15, OLED_COLOR_BLUE);
    OLED_DrawBox(0, 80, 96, 15, OLED_COLOR_BLUE);
    OLED_SetFont(guiFont_Exo_2_Condensed10x16_Regular, OLED_COLOR_WHITE, 0);
    OLED_WriteText("BRUSHLESS", 20, 0);
    OLED_WriteText("Period:", 5, 30);
    OLED_WriteText("Duty:", 5, 50);
    OLED_WriteText("DEC", 15, 80);
    OLED_WriteText("INC", 63, 80);
    WordToStr(pwm_period, txt_value);
    OLED_WriteText(txt_value, 50, 30);
    WordToStr(current_duty, txt_value);
    OLED_WriteText(txt_value, 50, 50);

    hexiwear_uart_messaging_init();              // Init UART messaging
    MOTOR_DIR = CCW;                             // Setting motor direction 
                                                 //  to counter-clock-wise
}
Пример #24
0
int main(void)
{
		UART_InitTypeDef UART_InitStruct1; 
		UART_InitStruct1.UARTxMAP= UART0_RX_PA14_TX_PA15; 
		UART_InitStruct1.UART_BaudRate=115200;
		UART_Init(&UART_InitStruct1);
		UART_ITConfig(UART0,UART_IT_RDRF, ENABLE);
	  NVIC_EnableIRQ(UART0_RX_TX_IRQn);	
		OLED_Init();
	while(1){
		//UART_SendData(UART0,1);
		//OLED_Write_Char(2,2,ch);
		//UART_SendData(UART0,'x');
		//UART_Send_String(UART0,"abcdefg");
	}
}
Пример #25
0
void IAC_Init(void)
{
	 delay_init(72);  //延时函数初始化
	 Nvic_Init();     //中断初始化 
	 LED_Init();      //led初始化
	 KEY_Init();    //按键初始化
	 OLED_Init();     //oled初始化
	 //Draw_LibLogo();  //logo	
    paramLoad();    //pid参数初始化
	 State_Display();//OLED数据显示
   Moto_Init();		  //电机初始化//200hz
	
	 usart1_init(72,115200); //串口1初始化  摄像头
	 usart2_Init(36,9600);    //ks103数据 9600 
	 usart3_config(460800); //串口3初始化   上位机
	 TIM3_Init(2500); //定时器初始化 2.5MS
}
Пример #26
0
int main(void) {
	
	Clock_Init();
	PortG_Init();
	Sound_Init();	
	OLED_Init();	
	LED_Blink();
	SysTickInt_Init();	
	IntMasterEnable();

	

	while(1) { 
		// SLEEP 
		}
	
}
Пример #27
0
/**@brief Function for application main entry.
 */
int main(void)
{
	system_HFCLK_init();
	// uart init
    simple_uart_config(RTS_PIN_NUMBER, TX_PIN_NUMBER, CTS_PIN_NUMBER, RX_PIN_NUMBER, 0); 
    xprintf("APP start up..\r\n");
	
	mcu_bootloader_check();
    // Initialize.
    app_trace_init();
    leds_init();
    buttons_init();
    ble_stack_init();
    device_manager_init();
    timers_init();
    gap_params_init();
    advertising_init();
    services_init();
    sensor_sim_init();
    conn_params_init();
	
	//I2C and sensor initial
	system_I2C_init();
	OLED_Init();
	sensor_init();
	enter_pedo_mode();	
	
	GPIO_HiToLo_INT_config(BUTTON_2);
	
	// Test battery
	if(!battery_self_detect())
    {
        system_low_battery();
    }
	
	// Start execution.
    application_timers_start();
    advertising_start();
	
	// Enter main loop.
    for (;;)
    {
        power_manage();
    }
}
Пример #28
0
void init_all()
{
    init_gpio();
    pwm_init();
    adc_init();
    init_all_pulse_counter();
    LPLD_Flash_Init();
    init_sdhc();          //SD卡模块初始化   
    uart_interr_init();
    init_i2c();           //MPU6050初始化
    //LPLD_MMA8451_Init();
    OLED_Init();
    pit_init();
    init_paranum();   
    init_setpara();    
    init_readpara();
    save.g_s16SDDenoteNum = 0;//防止不小心保存非0数
}
Пример #29
0
void main()
{
    OLED_Init();
    OLED_DrawImage( &RGB8x8_bmp, 0, 0 );

    GPIO_Digital_Output(&PTC_PDOR, _GPIO_PINMASK_4);
    SPI0_Init_Advanced(5000000, _SPI_CFG_MASTER | _SPI_CFG_SELECT_CTAR0 | _SPI_CFG_FRAME_SIZE_8BITS |
                             _SPI_CFG_CLK_IDLE_LOW | _SPI_CFG_CLK_PHASE_CAPT_LEADING | _SPI_CFG_MSB_FIRST, &_GPIO_Module_SPI0_PC5_7_6);

    Delay_ms(400);

    led_eight_init();
    
    while(1)
    {
        led_eight_scroll_text(text_1, 10);
        led_eight_scroll_text(text_2, 10);
        led_eight_scroll_text(text_3, 10);
    }
}
Пример #30
-1
/******************************************************
Function:	 void OLED_Init(void)
Description: 驱动端口初始化、SSD1306初始化。
Calls:		 void OLED_Init(void);	  //驱动端口初始化
			 void OLED_WCMD(u8 cmd); //向SSD1306写命令
******************************************************/				    
void OLED_SetInit(void)
{ 	 				 	 					    
	OLED_Init();		//端口初始化				  

	OLED_WCMD(0xAE);    //关闭显示
	OLED_WCMD(0xD5);    //设置时钟分频因子,震荡频率
	OLED_WCMD(0x50);	    //[3:0],分频因子;[7:4],震荡频率
	OLED_WCMD(0xA8);    //设置驱动路数
	OLED_WCMD(0x3F);        //默认0X3F(1/64)
	
	OLED_WCMD(0xD3);    //设置显示偏移
	OLED_WCMD(0x00);       //默认为0
	OLED_WCMD(0x40);    //设置显示开始行 [5:0],行数.
	OLED_WCMD(0x8D);    //电荷泵设置
	OLED_WCMD(0x14);    //bit2,开启/关闭
	
	OLED_WCMD(0x20);	//设置内存寻址模式
	OLED_WCMD(0x02);	//[1:0],00,列地址模式;01,行地址模式;10,页地址模式;默认10;	
	OLED_WCMD(0xA1);	//段重定义设置,bit0: 0,column 0->SEG 0;  1,column 0->SEG 127;
	OLED_WCMD(0xC8);	//设置COM扫描方向;bit3:0,普通模式;1,重定义模式 COM[N-1]->COM0;N:驱动路数
	OLED_WCMD(0xDA);	//设置COM硬件引脚配置  [5:4]配置  配置COM(SSD1306)与ROW(液晶)的连接关系
	OLED_WCMD(0x12);        //[5:4]配置  配置COM(SSD1306)与ROW(液晶)的连接关系
	
	OLED_WCMD(0x81);	//对比度设置
	OLED_WCMD(0xEF);	//1~255;默认0X7F (亮度设置,越大越亮)
	OLED_WCMD(0xD9);	//设置预充电周期
	OLED_WCMD(0xF1);	//[3:0],PHASE 1;[7:4],PHASE 2;
	OLED_WCMD(0xDB);	//设置VCOMH 电压倍率
	OLED_WCMD(0x30);	//[6:4] 000,0.65*vcc;001,0.77*vcc;011,0.83*vcc;
	OLED_WCMD(0xA4);	//全局显示开启;bit0:1,开启;0,关闭;(白屏/黑屏)
	OLED_WCMD(0xA6);	//设置显示方式;bit0:1,反相显示;0,正常显示
	OLED_WCMD(0xAF);	//开启显示

	OLED_Clear();		//清屏
}