Example #1
0
/*
     实验名称:Flexbus驱动ARAM
     实验平台:渡鸦开发板
     板载芯片:MK60DN512ZVQ10
 实验效果:测试外挂的SRAM工作情况  
       具体的SRAM应用请参见sram.c文件
*/
int main(void)
{
    DelayInit();
    DelayMs(10);
    GPIO_QuickInit(HW_GPIOE, 6, kGPIO_Mode_OPP);
    UART_QuickInit(UART0_RX_PD06_TX_PD07, 115200);
    
    printf("Flexbus SRAM test\r\n");
    
    /* 初始化外部SRAM */
    SRAM_Init();
    /* SRAM 自测 */
    if(!SRAM_SelfTest())
    {
        printf("sram test ok!\r\n");
    }
    else
    {
        printf("sram test failed!\r\n");
    }
    while(1)
    {
        GPIO_ToggleBit(HW_GPIOE, 6);
        DelayMs(500);
    }
}
Example #2
0
static rt_err_t rt_uart_init (rt_device_t dev)
{
    struct uart_device * uart_dev;
    uart_dev = (struct uart_device*)dev;
    
    UART_QuickInit(BOARD_UART_DEBUG_MAP, BOARD_UART_BAUDRATE);
    UART_CallbackRxInstall(HW_UART0, UART0_ISR);
    UART_CallbackRxInstall(HW_UART1, UART1_ISR);
    UART_CallbackRxInstall(HW_UART2, UART2_ISR);
    UART_CallbackRxInstall(HW_UART3, UART3_ISR);
    UART_CallbackRxInstall(HW_UART4, UART4_ISR);
    UART_ITDMAConfig(uart_dev->hw_instance, kUART_IT_Rx, true);

    switch(uart_dev->hw_instance)
    {
        case 0:
            uart_dev->hw_isr = UART0_ISR;
            break;
        case 1:
            uart_dev->hw_isr = UART1_ISR;
            break; 
        case 2:
            uart_dev->hw_isr = UART2_ISR;
            break;   
        case 3:
            uart_dev->hw_isr = UART2_ISR;
            break; 
        case 4:
            uart_dev->hw_isr = UART2_ISR;
            break; 
    }
    return RT_EOK;
}
Example #3
0
int main(void)
{
    uint32_t i;
    DelayInit();
    GPIO_QuickInit(HW_GPIOE, 6, kGPIO_Mode_OPP);
    UART_QuickInit(UART0_RX_PD06_TX_PD07, 115200);
    printf("SD test\r\n");
    printf("please insert SD card...\r\n");
    //SD卡模块快速初始化,设置速度为20000000
    SD_QuickInit(20000000);
    //获取SD卡的容量
    printf("SD size:%dMB\r\n", SD_GetSizeInMB());
    /* 读取0扇区数据,每一个扇区512字节 */
    SD_ReadSingleBlock(0, sd_buffer);
    /* 打印0扇区数据 */
    printf("sectoer 0 data:\r\n");
    for(i = 0; i < 512; i++)
    {
        printf("0x%02X ", sd_buffer[i]);
    }
    while(1)
    {
        //小灯闪烁
        GPIO_ToggleBit(HW_GPIOE, 6);
        DelayMs(500);
    }
}
Example #4
0
int main(void)
{
    DelayInit();
    
    GPIO_QuickInit(HW_GPIOE, 6, kGPIO_Mode_OPP); /* LED */
    GPIO_QuickInit(HW_GPIOE, 26, kGPIO_Mode_IPU); /* KEY */
    
    UART_QuickInit(UART0_RX_PD06_TX_PD07, 115200);
    
    /* 初始化看门狗 */
    WDOG_InitTypeDef WDOG_InitStruct1;
    WDOG_InitStruct1.windowInMs = 0;
    WDOG_InitStruct1.mode = kWDOG_Mode_Normal;  //设置看门狗处于正常工作模式
    WDOG_InitStruct1.timeOutInMs = 2000; /* 时限 2000MS : 2000MS 内没有喂狗则复位 */
    WDOG_Init(&WDOG_InitStruct1);
    
    printf("WDOG test start!\r\n");
    printf("press KEY1 to feed dog within 2S or system with reset!\r\n");
    
    /* 点亮LED 然后熄灭  指示系统运行从新上电运行 */
    GPIO_WriteBit(HW_GPIOE, 6, 0);
    DelayMs(200);
    GPIO_WriteBit(HW_GPIOE, 6, 1);
    while(1)
    {
        if(GPIO_ReadBit(HW_GPIOE, 26) == 0) /* 按键被按下 */
        {
            /* 喂狗 防止复位 */
            printf("wdog feed! we have 2s\r\n");
            WDOG_Refresh(); //喂狗
            DelayMs(100);
        }
        DelayMs(10);
    }
}
Example #5
0
/*
     实验名称:WDOG窗口看门狗
     实验平台:渡鸦开发板
     板载芯片:MK60DN512ZVQ10
 实验效果:开启看门狗的窗口模式,必须在规定的时间范围内喂狗,否则芯片复位
*/
int main(void)
{
    DelayInit();
    
    GPIO_QuickInit(HW_GPIOE, 6, kGPIO_Mode_OPP); /* LED */
    
    UART_QuickInit(UART0_RX_PD06_TX_PD07, 115200);
    
    /* 初始化看门狗 */
    WDOG_InitTypeDef WDOG_InitStruct1 = {0};
    WDOG_InitStruct1.mode = kWDOG_Mode_Window;   //设置看门狗为窗口模式
    WDOG_InitStruct1.windowInMs = 1000;   /* 开窗时间 设置为窗体模式后 喂狗必须在 看门狗开始计时后 1000 - 2000 MS内完成 多了少了都复位 比普通看门狗严格*/
    WDOG_InitStruct1.timeOutInMs = 2000; /* 时限 2000MS : 2000MS 内没有喂狗则复位 */
    WDOG_Init(&WDOG_InitStruct1);
    
    printf("\r\nSYSTEM RESET!!!!!!!%d\r\n", WDOG_GetResetCounter());
    printf("press any character to feed dog feed, must be in windows time\r\n");
    
    static uint32_t i;
    uint16_t ch;
    while(1)
    {
        if(UART_ReadByte(HW_UART0, &ch) == 0)
        {
            printf("wdog feed succ!\r\n");
            WDOG_Refresh(); //喂狗
            i = 0;
        }
        printf("cnt:i:%d\r", i++);
        DelayMs(100);
        GPIO_ToggleBit(HW_GPIOE, 6);
    }
}
Example #6
0
int main(void)
{
    DelayInit();
    SYSTICK_Init((1000*1000)/OS_TICKS_PER_SEC);
    SYSTICK_ITConfig(true);

    UART_QuickInit(UART0_RX_PD06_TX_PD07, 115200);

    printf("uCOSII test\r\n");

    OSInit();  //OS初始化
    OSTaskCreate(AppLED1Task,(void *)0,
                 &APP_LED1_STK[TASK_STK_SIZE-1],
                 APP_LED1_TASK_PRIO); //建立LED1 任务
    OSTaskCreate(AppLED0Task,(void *)0,
                 &APP_LED0_STK[TASK_STK_SIZE-1],
                 APP_LED0_TASK_PRIO); //建立LED0 任务

    SYSTICK_Cmd(true);

    /* 控制权交给操作系统 */
    OSStart();
    /* 程序永远不会运行到这 */
    while(1);
}
Example #7
0
int main(void)
{
    int value;
    DelayInit();

    GPIO_QuickInit(HW_GPIOD, 7, kGPIO_Mode_OPP);
    GPIO_QuickInit(HW_GPIOE, 6, kGPIO_Mode_OPP);
    
    UART_QuickInit(UART0_RX_PA01_TX_PA02, 115200);
    
    printf("LPTMR test\r\n");
    printf("PWM will generated from PC04, LPTMR will measure pulse on PC05\r\n");
    printf("please connect PC04&PC05\r\n");
    
    /* 边沿对其方式产生PWM波 */
    TPM_PWM_QuickInit(TPM0_CH3_PC04, kPWM_EdgeAligned, 50);
    
    /* 占空比 50% */
    TPM_PWM_ChangeDuty(HW_TPM0, kTPM_IT_CH3, 5000);
    
    LPTMR_PC_QuickInit(LPTMR_ALT2_PC05);
    
    while(1)
    {
        value = LPTMR_PC_ReadCounter();
        printf("lptmr:%dHz\r\n", value);
        LPTMR_ClearCounter();
        DelayMs(1000);
    }
}
Example #8
0
int main(void)
{
    uint32_t instance; /*存放 UART 的模块号 */
    DelayInit();
    DelayMs(10);
    GPIO_QuickInit(HW_GPIOE, 6, kGPIO_Mode_OPP);
    
    /* 初始化UART 使用快速初始化方式 波特率 115200 其他配置默认 返回初始化后 UART的模块号 */
    instance = UART_QuickInit(UART0_RX_PD06_TX_PD07, 115200);
    
    /* 当使用串口初始化后 printf 被默认连接到第一个被初始化的串口上*/
    printf("UART%d OK! Hello Kinetis\r\n", instance);
    
    while(1)
    {
        /* 串口 按字节发送 数据 注意 HW_UART0必须是已经初始化过的模块 否则 将产生错误*/
        UART_WriteByte(instance, 'h');
        UART_WriteByte(instance, 'e');
        UART_WriteByte(instance, 'l');
        UART_WriteByte(instance, 'l');
        UART_WriteByte(instance, 'o');
        UART_WriteByte(instance, '\r');
        UART_WriteByte(instance, '\n');
        /* 闪烁小灯 */
        GPIO_ToggleBit(HW_GPIOE, 6);
        DelayMs(500);
    }
}
Example #9
0
int main(void)
{
    DelayInit();
    UART_QuickInit(UART0_RX_PD06_TX_PD07, 115200);
    GPIO_QuickInit(HW_GPIOE, 6, kGPIO_Mode_OPP); /* LED */

    printf("calc the PWM duty, pwm will be generated on PA08 and input pin: PC01 and PC02\r\n");
    
    FTM_PWM_QuickInit(FTM1_CH0_PA08, kPWM_EdgeAligned, 200);
	FTM_PWM_ChangeDuty(HW_FTM1, HW_FTM_CH0, 2500);/* 25% */
    
    /* 配置IC 功能 设置中断 */
    FTM_IC_QuickInit(FTM0_CH0_PC01, kFTM_ClockDiv128);
    FTM_IC_SetTriggerMode(HW_FTM0, HW_FTM_CH0, kFTM_IC_RisingEdge);
    FTM_CallbackInstall(HW_FTM0, FTM0_ISR);
    FTM_ITDMAConfig(HW_FTM0, kFTM_IT_CH0, true);
	
	FTM_IC_QuickInit(FTM0_CH1_PC02, kFTM_ClockDiv128);
    FTM_IC_SetTriggerMode(HW_FTM0, HW_FTM_CH1, kFTM_IC_FallingEdge);
    /* FTM_CallbackInstall(HW_FTM1, FTM1_ISR); */
    FTM_ITDMAConfig(HW_FTM0, kFTM_IT_CH1, true);
    
	while(1)
    {
        /*
		printf("Frequency:%6dHz", InputCaptureValue);
		printf(" Frequency1:%6dHz\r\n", InputCaptureValue1);
		*/
		printf("Duty = %3f%% \n",((double)InputCaptureValue)/((double)InputCaptureValue1)*100.0);
        GPIO_ToggleBit(HW_GPIOE, 6); //控制小灯闪烁
        DelayMs(500);
    }
}
Example #10
0
int main(void)
{
    DelayInit();
    UART_QuickInit(UART0_RX_PD06_TX_PD07, 115200);
    printf("CHBootloader\r\n");
    
    UART_CallbackRxInstall(HW_UART0, UART_ISR);
    FLASH_Init();
    
    Boot.name = "MK6xDN1M(512)VLQ12";
    Boot.AppStartAddr = 0x5000;
    Boot.TimeOut = 2000;
    Boot.FlashPageSize = FLASH_GetSectorSize();
    Boot.send = send;
    Boot.flash_erase = flash_erase;
    Boot.flash_write = flash_write;
    
    BootloaderInit(&Boot);
    
    UART_ITDMAConfig(HW_UART0, kUART_IT_Rx, true);
    
    while(1)
    {
        BootloaderProc();
    }
}
Example #11
0
int main(void)
{
    DelayInit();
    GPIO_QuickInit(HW_GPIOE, 6, kGPIO_Mode_OPP);
    UART_QuickInit(UART0_RX_PD06_TX_PD07, 115200);
    
    /* 设置PORTE PORTA 中断 */
    GPIO_QuickInit(HW_GPIOE,26, kGPIO_Mode_IPU);
    GPIO_QuickInit(HW_GPIOA, 4, kGPIO_Mode_IPU);
    GPIO_CallbackInstall(HW_GPIOE, PORTE_ISR);
    GPIO_CallbackInstall(HW_GPIOA, PORTA_ISR);
    GPIO_ITDMAConfig(HW_GPIOE, 26, kGPIO_IT_RisingEdge, true);
    GPIO_ITDMAConfig(HW_GPIOA, 4,  kGPIO_IT_RisingEdge, true);
    
    printf("NVIC test connect E26&A04\r\n");
    /* 将系统 中断优先级分组 可以配置 16个 抢占优先级 和16个 子优先级 */
    NVIC_SetPriorityGrouping(NVIC_PriorityGroup_2);  //中断优先级分成2组
    NVIC_SetPriority(PORTE_IRQn, NVIC_EncodePriority(NVIC_PriorityGroup_2, 2, 2)); //设置PTE端口的抢占优先级的子优先级
    NVIC_SetPriority(PORTA_IRQn, NVIC_EncodePriority(NVIC_PriorityGroup_2, 2, 2));
    
    while(1)
    {
        GPIO_ToggleBit(HW_GPIOE, 6);
        DelayMs(500);
    }
}
Example #12
0
int main(void)
{
    DelayInit();
    GPIO_QuickInit(HW_GPIOE, 6, kGPIO_Mode_OPP);
    UART_QuickInit(UART0_RX_PD06_TX_PD07, 115200);
    printf("FATFS test\r\n");
    printf("please insert SD card...\r\n");
    if(SD_QuickInit(20*1000*1000))
    {
        printf("SD card init failed!\r\n");
        while(1);
    }
    printf("SD size:%dMB\r\n", SD_GetSizeInMB());
    FRESULT rc;
    FATFS fs_sd;
    FIL fil;
    FATFS *fs;
    fs = &fs_sd;
    UINT bw,br; /* bw = byte writted br = byte readed */
    DWORD fre_clust, fre_sect, tot_sect;
    /* 挂载文件系统 */
    rc = f_mount(fs, "0:", 0);
    ERROR_TRACE(rc);
    rc = f_getfree("0:", &fre_clust, &fs);
    ERROR_TRACE(rc);
    /* 计算磁盘空间及剩余空间 */
    tot_sect = (fs->n_fatent - 2) * fs->csize;
    fre_sect = fre_clust * fs->csize;
    printf("%d KB total drive space.\r\n%d KB available.\r\n", tot_sect / 2, fre_sect / 2);
    /* 写入文件 */
    printf("open or create file\r\n");
    rc = f_open(&fil, "0:/fatfs.txt", FA_WRITE | FA_CREATE_ALWAYS);
    ERROR_TRACE(rc);
    printf("write file\r\n");
    rc = f_write(&fil, "HelloWorld\r\n", 12, &bw);
    ERROR_TRACE(rc);
    printf("%d bytes writen\r\n", bw);
    rc = f_close(&fil);
    /* 读取文件 */
    rc = f_open(&fil, "0:/fatfs.txt", FA_READ);
    ERROR_TRACE(rc);
    printf("file size:%l\r\n", f_size(&fil));
    printf("file contents:\r\n");
    while(1)
    {
        rc = f_read(&fil, buf, sizeof(buf), &br);
        if(rc || !br ) break;
        printf("%s", buf);
    }
    rc = f_close(&fil);
    ERROR_TRACE(rc);
    
    while(1)
    {
        GPIO_ToggleBit(HW_GPIOE, 6);
        DelayMs(500);
    }
}
Example #13
0
uint32_t UARTB_Init(int rate)
{
    uint32_t instance;
    
    instance = UART_QuickInit(UART4_RX_PE25_TX_PE24, rate);
    /*  配置UART 中断配置 打开接收中断 安装中断回调函数 */
    UART_CallbackRxInstall(HW_UART4, UART_RX_ISR);
    /* 打开串口接收中断功能 IT 就是中断的意思*/
    UART_ITDMAConfig(HW_UART4, kUART_IT_Rx, true);
    
    return instance;
}
Example #14
0
int main(void)
{
    uint32_t i;
    uint32_t len;
    DelayInit();
    GPIO_QuickInit(HW_GPIOE, 6, kGPIO_Mode_OPP);
    UART_QuickInit(UART0_RX_PD06_TX_PD07, 115200);
    UART_CallbackRxInstall(HW_UART0, UART_ISR);
    UART_ITDMAConfig(HW_UART0, kUART_IT_Rx, true);
    
    printf("NRF24L01 test\r\n");
    /* 初始化 NRF2401模块 的SPI接口及片选 */
    PORT_PinMuxConfig(HW_GPIOE, 1, kPinAlt2); 
    PORT_PinMuxConfig(HW_GPIOE, 2, kPinAlt2); 
    PORT_PinMuxConfig(HW_GPIOE, 3, kPinAlt2); 
    PORT_PinMuxConfig(HW_GPIOE, 4, kPinAlt2);
    /* 初始化2401所需的CE引脚 */
    GPIO_QuickInit(HW_GPIOE, 0 , kGPIO_Mode_OPP);
    /* 初始化2401模块*/
    SPI_QuickInit(SPI1_SCK_PE02_SOUT_PE01_SIN_PE03, kSPI_CPOL0_CPHA0, 1*1000*1000);
    nrf24l01_init(HW_SPI1, 0);
    
    //检测是否存在无线设备,并配置接收和发送地址
    if(nrf24l01_probe())
    {
        printf("no nrf24l01 device found!\r\n");
    }
    /* 进入Rx模式 */
    nrf24l01_set_rx_mode();
    while(1)
    {
        /* 如果收到串口数据则发送 */
        if(gpRevChar != NULL)
        {
            nrf24l01_set_tx_mode();
            nrf24l01_write_packet(gpRevChar, 1);
            nrf24l01_set_rx_mode();
            gpRevChar = NULL;
        }
        /* 如果收到2401 的数据 则传输到串口 */
        if(!nrf24l01_read_packet(NRF2401RXBuffer, &len))
        {
            i = 0;
            while(len--)
            {
                UART_WriteByte(HW_UART0, NRF2401RXBuffer[i++]);
            }
        }
    }
}
Example #15
0
int main(void)
{
    DelayInit();
    GPIO_QuickInit(HW_GPIOE, 6, kGPIO_Mode_OPP);
    UART_QuickInit(UART0_RX_PD06_TX_PD07, 115200);

    printf("spi touch screen test\r\n");

    /* 初始化SPI2 接口连接触控屏的触控芯片*/
    SPI_QuickInit(SPI2_SCK_PD12_SOUT_PD13_SIN_PD14, kSPI_CPOL0_CPHA0, 2*1000*1000);

    PORT_PinMuxConfig(HW_GPIOD, 11, kPinAlt2); /* SPI2_PCS0 */
    /* 初始化触控芯片 使用CS0片选 */
    ads7843_init(HW_SPI2, HW_SPI_CS0);

    GUI_Init();//液晶屏界面初始化
    GUI_SetBkColor(GUI_WHITE); //设置背景色
    GUI_SetColor(GUI_BLACK);   //设置前景色
    GUI_Clear();  //清屏
    GUI_SetPenSize(3); //设置点的大小
    GUI_DispString("Measurement of\nA/D converter values");
    while (1)
    {
        GUI_PID_STATE TouchState;
        int xPhys, yPhys;
        GUI_TOUCH_GetState(&TouchState);  /* 获得触控位置 */
        xPhys = GUI_TOUCH_GetxPhys();     /* 获得x轴的测量值 */
        yPhys = GUI_TOUCH_GetyPhys();     /* 获得y轴的测量值 */
        /* 显示测量结果 */
        GUI_SetColor(GUI_BLUE);
        GUI_DispStringAt("Analog input:\n", 0, 20);
        GUI_GotoY(GUI_GetDispPosY() + 2);
        GUI_DispString("x:");
        GUI_DispDec(xPhys, 4);
        GUI_DispString(", y:");
        GUI_DispDec(yPhys, 4);
        /* Display the according position */
        GUI_SetColor(GUI_RED);
        GUI_GotoY(GUI_GetDispPosY() + 4);
        GUI_DispString("\nPosition:\n");
        GUI_GotoY(GUI_GetDispPosY() + 2);
        GUI_DispString("x:");
        GUI_DispDec(TouchState.x,4);
        GUI_DispString(", y:");
        GUI_DispDec(TouchState.y,4);
        GUI_DrawPoint(TouchState.x, TouchState.y);
        GUI_TOUCH_Exec();
    }
}
Example #16
0
int main()
{
	
	uint8_t i,Track_Midline_value,A;
	DelayInit();
	GPIO_QuickInit(HW_GPIOE,0,kGPIO_Mode_OPP);
	GPIO_WriteBit(HW_GPIOE,0,0);
	

	GPIO_QuickInit(HW_GPIOB,2,kGPIO_Mode_OPP);
	GPIO_QuickInit(HW_GPIOB,4,kGPIO_Mode_OPP);
	CCD_SI(0);
  CCD_CLK(0);
	
	UART_QuickInit(UART0_RX_PA15_TX_PA14, 115200);

	ADC_QuickInit(ADC0_SE8_PB0,kADC_SingleDiff8or9);

	CCD_Restet();
  while(1)
	{
		  //CCD();
		  CCD_gather(); 
		  CCD_Filtering();

		  Data_binarization(averaging());
		

			for(i=0;i<128;i++)
		{
      if(CCD_filtering_data[127]==0xff)
			{
        CCD_filtering_data[127]=0xfe;
      }
			UART_WriteByte(HW_UART0,CCD_filtering_data[i]);
    }
		UART_WriteByte(HW_UART0,0xff);
		
		
	
//		Track_Midline_value = Track_Midline();
//		A = Track_Midline_value;
//		printf("Track_Midline_value = %d\n",A);
  }
}
Example #17
0
int main(void)
{
    int value;
    DelayInit();
    
    UART_QuickInit(UART0_RX_PA01_TX_PA02, 115200);
    kinetis_spi_bus_init(&bus, HW_SPI1);
    PORT_PinMuxConfig(HW_GPIOE, 0, kPinAlt2);  
    PORT_PinMuxConfig(HW_GPIOE, 1, kPinAlt2);  
    PORT_PinMuxConfig(HW_GPIOE, 2, kPinAlt2);  
    ili9163_init(&bus, 0);
    GUI_printf(0, 0, "HelloWorld", "Numis:",13);
    GUI_printf(0, 10, "%d", 1234);
    while(1)
    {

    }
}
Example #18
0
int main(void)
{
    uint8_t i;
    DelayInit();
    GPIO_QuickInit(HW_GPIOE, 6, kGPIO_Mode_OPP);
    UART_QuickInit(UART0_RX_PD06_TX_PD07, 115200);
    
    printf("flexbus lcd test\r\n");
    ili9320_init();
    printf("controller id:0x%X\r\n", ili9320_get_id());
    
    while(1)
    {
        i++; i%= ARRAY_SIZE(ColorTable);
        ili9320_clear(ColorTable[i]);
        GPIO_ToggleBit(HW_GPIOE, 6);
        DelayMs(500);
    }
}
Example #19
0
int main(void)
{
    DelayInit();
    SYSTICK_Init(1000*1000/OS_TICKS_PER_SEC);
    SYSTICK_ITConfig(true);
    
    UART_QuickInit(UART0_RX_PD06_TX_PD07, 115200);
    
    printf("uCOSII test\r\n");

    OSInit();
	OSTaskCreate(AppStartTask,(void *)0,
							&APP_START_STK[TASK_STK_SIZE-1],
							APP_START_TASK_PRIO);
    
    SYSTICK_Cmd(true);
    
    OSStart();
    while(1);
}
Example #20
0
int main(void)
{
    DelayInit();
    DelayMs(10);
    GPIO_QuickInit(HW_GPIOE, 6, kGPIO_Mode_OPP);

    UART_QuickInit(UART0_RX_PB16_TX_PB17 , 115200);

    printf("ATCMD test\r\n");

    UART_CallbackRxInstall(HW_UART0, UART_RX_ISR);
    UART_ITDMAConfig(HW_UART0, kUART_IT_Rx, true);

    ATP_Init(ATCMD, ARRAY_SIZE(ATCMD));
    while(1)
    {
        GPIO_ToggleBit(HW_GPIOE, 6);
        DelayMs(500);
    }
}
Example #21
0
int main(void)
{
    DelayInit();
    GPIO_QuickInit(HW_GPIOE, 6, kGPIO_Mode_OPP);
    
    UART_QuickInit(UART0_RX_PD06_TX_PD07 , 115200);
    
    printf("type any character which will echo...\r\n");
    
    /*  配置UART 中断配置 打开接收中断 安装中断回调函数 */
    UART_CallbackRxInstall(HW_UART0, UART_RX_ISR);
    /* 打开串口接收中断功能 IT 就是中断的意思*/
    UART_ITDMAConfig(HW_UART0, kUART_IT_Rx, true);
    
    while(1)
    {
        GPIO_ToggleBit(HW_GPIOE, 6);
        DelayMs(500);
    }
}
Example #22
0
int main(void)
{
    DelayInit();
    GPIO_QuickInit(HW_GPIOE, 6, kGPIO_Mode_OPP);
    UART_QuickInit(UART0_RX_PD06_TX_PD07, 115200);

    printf("OV7620 test\r\n");

    ili9320_init();
    SRAM_Init();
    /* 摄像头速度非常快 把FLexbus 总线速度调到最高 */
    SIM->CLKDIV1 &= ~SIM_CLKDIV1_OUTDIV3_MASK;
    SIM->CLKDIV1 |= SIM_CLKDIV1_OUTDIV3(0);
    OV7620_Init();
    SCCB_Init();
    while(1)
    {
        GPIO_ToggleBit(HW_GPIOE, 6);
        DelayMs(500);
    }
}
Example #23
0
int main(void)
{
    uint32_t clock;
    DelayInit();
    GPIO_QuickInit(HW_GPIOE, 6, kGPIO_Mode_OPP);
    UART_QuickInit(UART0_RX_PD06_TX_PD07, 115200);
    /* 打印芯片信息 */
    printf("%s - %dP\r\n", CPUIDY_GetFamID(), CPUIDY_GetPinCount());
    /* 打印时钟频率 */
    clock = GetClock(kCoreClock);
    printf("core clock:%dHz\r\n", clock);
    clock = GetClock(kBusClock);
    printf("bus clock:%dHz\r\n", clock);
    
    while(1)
    {
        /* 闪烁小灯 */
        GPIO_ToggleBit(HW_GPIOE, 6);
        DelayMs(500);
    }
}
Example #24
0
int main(void)
{
    uint32_t i;
    DelayInit();
    GPIO_QuickInit(HW_GPIOE, 6, kGPIO_Mode_OPP);
    UART_QuickInit(UART0_RX_PD06_TX_PD07, 115200);
    
    printf("flexbus lcd test\r\n");
    GUI_Init();
    GUI_DispString("ucGUI");
    GUI_DispString(GUI_GetVersionString());
    GUI_DispString("\r\nHello world!");
    while(1) 
    {
        GUI_DispDecAt( i++, 20,20,4);
        if (i>9999)
        {
            i=0;
        }
    }
}
Example #25
0
int main(void)
{
    DelayInit();
    GPIO_QuickInit(HW_GPIOE, 6, kGPIO_Mode_OPP);
    UART_QuickInit(UART0_RX_PB16_TX_PB17, 115200);
    
    /* 声明一个时间结构 */
    RTC_DateTime_Type td = {0};
    td.day = 20;
    td.hour = 23;
    td.minute = 59;
    td.second = 50;
    td.year = 2014;
    td.month = 11;
    printf("RTC alarm test\r\n");
    
    RTC_QuickInit();
    if(RTC_IsTimeValid() == false)
    {
        printf("bad time, reset!\r\n");
        RTC_SetTime(&td);
    }
    /* 开启中断 */
    RTC_CallbackInstall(RTC_ISR);
    RTC_ITDMAConfig(kRTC_IT_TimeAlarm, true);
    
    /* 设置闹钟在当前3秒后 */
    RTC_GetTime(&td);
    td.second += 3;
    RTC_SetAlarm(&td);

    while(1)
    {
        /* 获得时间 */
        RTC_GetTime(&td);//获得时间
        printf("%d-%d-%d %d:%d:%d\r\n", td.year, td.month, td.day, td.hour, td.minute, td.second);
        GPIO_ToggleBit(HW_GPIOE, 6);
        DelayMs(1000);
    }
}
Example #26
0
int main(void)
{
    int i;
    DelayInit();
    GPIO_QuickInit(HW_GPIOE, 6, kGPIO_Mode_OPP);
    UART_QuickInit(UART0_RX_PA01_TX_PA02, 115200);
    
     /** print message before mode change*/
    printf("i2s MAPSK64 test\r\n");
    I2C_QuickInit(I2C0_SCL_PE24_SDA_PE25, 100*1000);
   // I2C_Scan(I2C0_SCL_PE24_SDA_PE25);
    wm8960_init(0);
    wm8960_format_config(44100, 16);
   // wm8960_set_volume(kWolfsonModuleHP, 0x2FFF);
    
    
    I2S_InitTypeDef Init;
    Init.instance = 0;
    Init.isStereo = true;
    Init.isMaster = true;
    Init.protocol = kSaiBusI2SLeft;
    Init.sampleBit = 16;
    Init.sampleRate = 44100;
    Init.chl = 0;
    I2S_Init(&Init);
    
    /* pinmux */
    PORT_PinMuxConfig(HW_GPIOE, 6, kPinAlt4);
    PORT_PinMuxConfig(HW_GPIOE, 7, kPinAlt4);
    PORT_PinMuxConfig(HW_GPIOE, 12, kPinAlt4); 
    PORT_PinMuxConfig(HW_GPIOE, 11, kPinAlt4); 
    PORT_PinMuxConfig(HW_GPIOE, 10, kPinAlt4); 
    
    while(1)
    {
        I2S_SendData(0, 16, 0, (uint8_t*)music_44100_16_2, sizeof(music_44100_16_2));
        printf("complete\r\n");
      //  DelayMs(500);
    }
}
Example #27
0
/*
     实验名称:PIT触发ADC
     实验平台:渡鸦开发板
     板载芯片:MK60DN512ZVQ10
 实验效果:使用PIT模块周期性的触发ADC模块进行数据采集
    通过调节开发板上的电位器,可以更改ad采集结果
*/
int main(void)
{
    DelayInit();
    GPIO_QuickInit(HW_GPIOE, 6, kGPIO_Mode_OPP);
    UART_QuickInit(UART0_RX_PD06_TX_PD07, 115200);
    
    printf("PIT tirgger ADC test\r\n");
    
    /* 配置ADC0 硬件触发源 */
    SIM->SOPT7 |= SIM_SOPT7_ADC0TRGSEL(4); /* 使用PIT0 触发 */
    SIM->SOPT7 &= ~SIM_SOPT7_ADC0PRETRGSEL_MASK; /* 使用trigger A */
    SIM->SOPT7 |= SIM_SOPT7_ADC0ALTTRGEN_MASK; /*使用除PDB之外的硬件触发源 此触发源可能因芯片而异*/

    /* 初始化ADC模块 ADC0_SE19_DM0 */
    ADC_InitTypeDef AD_InitStruct1;
    AD_InitStruct1.instance = HW_ADC0;
    AD_InitStruct1.clockDiv = kADC_ClockDiv2; /* ADC采样时钟2分频 */
    AD_InitStruct1.resolutionMode = kADC_SingleDiff10or11; /*单端 10位精度 查分 11位精度 */
    AD_InitStruct1.triggerMode = kADC_TriggerHardware; /* 硬件触发转换 */
    AD_InitStruct1.singleOrDiffMode = kADC_Single; /*单端模式 */
    AD_InitStruct1.continueMode = kADC_ContinueConversionDisable;
    AD_InitStruct1.hardwareAveMode = kADC_HardwareAverageDisable; /*禁止 硬件平均 功能 */
    ADC_Init(&AD_InitStruct1);
    
    /* 初始化对应引脚 */
    /* DM0引脚为专门的模拟引脚 ADC时 无需设置复用  DM0也无法当做普通的数字引脚 */
    
    /* 启动一次ADC转换 填入通道值*/
    ADC_StartConversion(HW_ADC0, 19, kADC_MuxA);
    /* 初始化 PIT模块 */
    PIT_QuickInit(HW_PIT_CH0, 1000*200); /* 200 ms 触发一次 */
    while(1)
    {
        /* 如果ADC转换完成 读取转换结果*/
        if(ADC_IsConversionCompleted(HW_ADC0, kADC_MuxA) == 0)
        {
            printf("ADC:%04d\r", ADC_ReadValue(HW_ADC0, kADC_MuxA));
        }
    }
}
Example #28
0
int main(void)
{
    DelayInit();
    GPIO_QuickInit(HW_GPIOE, 6, kGPIO_Mode_OPP);
    SRAM_Init();
    UART_QuickInit(UART0_RX_PD06_TX_PD07, 115200);
    GUI_Init();
    GUI_DispString("BMP file test\r\n");
    GUI_DispString("please insert SD card...\r\n");
    SD_QuickInit(10*1000*1000);
    printf("SD size:%dMB\r\n", SD_GetSizeInMB());
    FATFS fs_sd;
    FATFS *fs = &fs_sd;
    /* 挂载文件系统 */
    f_mount(fs, "0:", 0);
    
    while(1)
    {
        scan_files("0:");
        GPIO_ToggleBit(HW_GPIOE, 6);
    }
}
Example #29
0
int main(void)
{
    DelayInit();
    
    GPIO_QuickInit(HW_GPIOE, 6, kGPIO_Mode_OPP); /* LED */
    UART_QuickInit(UART0_RX_PD06_TX_PD07, 115200); /* 为了代码简单 这里直接调用快速初始化了 */
    
    printf("lptrm timer counter test\r\n");
    
    /* 快速初始化 LPTMR 用作时间计数 */
    LPTMR_TC_InitTypeDef LPTMR_TC_InitStruct1; //申请结构体
    LPTMR_TC_InitStruct1.timeInMs = 1000; /* 定时时间 1S */
    LPTMR_TC_Init(&LPTMR_TC_InitStruct1);
    
    LPTMR_CallbackInstall(LPTMR_ISR); /* 注册回调函数 */
    LPTMR_ITDMAConfig(kLPTMR_IT_TOF, true); /* 开启LPTMR中断 */
    
    while(1)
    {
        /* 等待中断 */
    }
}
Example #30
0
int main(void)
{
    DelayInit();

    GPIO_QuickInit(HW_GPIOD, 7, kGPIO_Mode_OPP);
    GPIO_QuickInit(HW_GPIOE, 6, kGPIO_Mode_OPP);
    
    UART_QuickInit(UART0_RX_PA01_TX_PA02, 115200);
    
    printf("HelloWorld\r\n");
    
    /* ´ò¿ª´®¿ÚÖÐ¶Ï */
    UART_ITDMAConfig(HW_UART0, kUART_IT_Rx, true);
    UART_CallbackRxInstall(HW_UART0, UART_ISR);
    
    while(1)
    {
        GPIO_ToggleBit(HW_GPIOD, 7);
        GPIO_ToggleBit(HW_GPIOE, 6);
        DelayMs(50);
    }
}