Ejemplo n.º 1
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();
    }
}
Ejemplo n.º 2
0
static rt_err_t rt_dflash_init (rt_device_t dev)
{
    FLASH_Init();
    
    SectorSize = FLASH_GetSectorSize();
    StartAddr = RT_ALIGN(((uint32_t)&Image$$ER_IROM1$$RO$$Limit + SectorSize), SectorSize);
    DiskSize = FLASH_SIZE - StartAddr;
    rt_kprintf("dflash sector size:%d 0ffset:0x%X\r\n", SectorSize, StartAddr);
    
    mutex = rt_mutex_create("_mu", RT_IPC_FLAG_FIFO);
    
    return RT_EOK;
}
Ejemplo n.º 3
0
DRESULT disk_ioctl (
	BYTE pdrv,		/* Physical drive nmuber (0..) */
	BYTE cmd,		/* Control code */
	void *buff		/* Buffer to send/receive control data */
)
{
	DRESULT res;
//	int result;

	switch (pdrv)
    {
        case SD_CARD :
            switch(cmd)
            {
                case CTRL_SYNC:
                    res = RES_OK;
                    break;	 
                case GET_SECTOR_SIZE:
                    *(WORD*)buff = FLASH_GetSectorSize();
                    res = RES_OK;
                    break;	 
                case GET_BLOCK_SIZE:
                    *(WORD*)buff = 8;
                    res = RES_OK;
                    break;	 
                case GET_SECTOR_COUNT:
                    *(DWORD*)buff = UDISK_SIZE/FLASH_GetSectorSize();
                    res = RES_OK;
                    break;
                default:
                    res = RES_PARERR;
                    break;
            }
		return res;
	}
	return RES_PARERR;
}
Ejemplo n.º 4
0
DRESULT disk_read (
	BYTE pdrv,		/* Physical drive nmuber (0..) */
	BYTE *buff,		/* Data buffer to store read data */
	DWORD sector,	/* Sector address (LBA) */
	UINT count		/* Number of sectors to read (1..128) */
)
{
    
	DRESULT res;

	switch (pdrv)
    {
        case SD_CARD :
            memcpy(buff, (uint8_t*)(FLASH_START_ADDR + sector*FLASH_GetSectorSize()), count*FLASH_GetSectorSize());
          //  SD_ReadMultiBlock(sector, buff, count);
            res = RES_OK;
		return res;

	}
	return RES_PARERR;
}
Ejemplo n.º 5
0
int main(void)
{
    DelayInit();

    
    UART_Init(UART0_RX_PA01_TX_PA02, 115200);
    FLASH_Init();
    
    Boot.name = "Uranus";
    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_SetIntMode(HW_UART0, kUART_IntRx, true);
    while(1)
    {
        BootloaderProc();
    }
}