/** * * @param boot_dev * @param arm_m_type * @param atags * @return */ int notmain(uint32_t boot_dev, uint32_t arm_m_type, uint32_t atags) { #ifdef ENABLE_FRAMEBUFFER fb_init(); #else bcm2835_uart_begin(); #endif printf("Compiled on %s at %s\n\n", __DATE__, __TIME__); mem_info(); cpu_info(); printf("\n"); printf("EMMC Clock rate (Hz): %ld\n", bcm2835_vc_get_clock_rate(BCM2835_VC_CLOCK_ID_EMMC)); printf("UART Clock rate (Hz): %ld\n", bcm2835_vc_get_clock_rate(BCM2835_VC_CLOCK_ID_UART)); printf("ARM Clock rate (Hz): %ld\n", bcm2835_vc_get_clock_rate(BCM2835_VC_CLOCK_ID_ARM)); printf("CORE Clock rate (Hz): %ld\n", bcm2835_vc_get_clock_rate(BCM2835_VC_CLOCK_ID_CORE)); printf("\n"); printf("Set UART Clock rate 4000000 Hz: %ld\n", bcm2835_vc_set_clock_rate(BCM2835_VC_CLOCK_ID_UART, 4000000)); printf("UART Clock rate (Hz): %ld\n", bcm2835_vc_get_clock_rate(BCM2835_VC_CLOCK_ID_UART)); printf("\n"); uint8_t mac_address[6]; bcm2835_vc_get_board_mac_address(mac_address); printf("MAC address : %.2X:%.2X:%.2X:%.2X:%.2X:%.2X\n", mac_address[0],mac_address[1],mac_address[2],mac_address[3],mac_address[4],mac_address[5]); printf("\nProgram ending...\n"); return 0; }
int notmain (void) { FRESULT rc; /* Result code */ DIR dir; /* Directory object */ FILINFO fno; /* File information object */ UINT br ; bcm2835_uart_begin(); f_mount(0, &Fatfs); /* Register volume work area (never fails) */ #if 1 printf("\r\nOpen an existing file (rainbowcircle.ild).\r\n"); rc = f_open(&Fil, "rainbowcircle.ild", FA_READ); if (rc) die(rc); for (;;) { uint32_t i1 = bcm2835_st_read(); rc = f_read(&Fil, Buff, 20, &br); /* Read a chunk of file */ uint32_t i2 = bcm2835_st_read(); if (rc || !br) break; /* Error or end of file */ printf("br [%d] i2-i1 [%d]\n", br, (int)(i2-i1)); } if (rc) die(rc); printf("\r\nClose the file.\r\n"); rc = f_close(&Fil); if (rc) die(rc); #endif #if 0 printf("\r\nCreate a new file (hello.txt).\r\n"); rc = f_open(&Fil, "HELLO.TXT", FA_WRITE | FA_CREATE_ALWAYS); if (rc) die(rc); printf("\r\nWrite a text data. (Hello world!)\r\n"); rc = f_write(&Fil, "Hello world!\r\n", 14, &bw); if (rc) die(rc); printf("%u bytes written.\r\n", bw); printf("\r\nClose the file.\r\n"); rc = f_close(&Fil); if (rc) die(rc); #endif printf("\r\nOpen root directory.\r\n"); rc = f_opendir(&dir, ""); if (rc) die(rc); char filename_buf[32]; printf("\r\nDirectory listing...\r\n"); for (;;) { fno.lfname = filename_buf; fno.lfsize = sizeof(filename_buf); rc = f_readdir(&dir, &fno); /* Read a directory item */ if (rc || !fno.fname[0]) break; /* Error or end of dir */ if (fno.fattrib & AM_DIR) printf(" <dir> %s\r\n", fno.fname); else { char * fn = *fno.lfname ? fno.lfname : fno.fname; printf("%8lu %s\r\n", fno.fsize, (char *) fn); } } if (rc) die(rc); printf("\nTest completed.\n"); die(0); return 0; }