Shop OBEX P1 Docs P2 Docs Learn Events
flexspin compiler for P2: Assembly, Spin, BASIC, and C in one compiler - Page 122 — Parallax Forums

flexspin compiler for P2: Assembly, Spin, BASIC, and C in one compiler

1116117118119120122»

Comments

  • @evanh I'm sorry, I was mistaken about ioctl, it isn't hooked all the way up -- that is, an ioctl() on a file doesn't get passed through to the disk :(

    However, you can do something like the following:

    #include <stdio.h>
    #include <unistd.h>
    #include <stdint.h>
    #include <sys/vfs.h>
    #include <fcntl.h>
    
    int main() {
        int r;
        FILE *raw_device = _sdmm_open(61, 60, 59, 58);
    
        if (!raw_device) {
            printf("Unable to open SD card\n");
            return 1;
        }
        /* strictly speaking we don't need to mount to access the device layer,
           but we probably will want to eventually */
        mount("/sd", _vfs_open_fat_handle(raw_device));
        uint8_t *buff = __builtin_alloca(20);    // auto-frees upon return
        errno = 0;
        r = raw_device->ioctl(raw_device, 0, buff);    // Attempting to trigger a CTRL_SYNC in the SD device driver
        printf(" ioctl %d (%d): %s\n", r, errno, strerror(errno));
        return 0;
    }
    

    There was a typo in the declaration of _vfs_open_fat_handle in include/sys/vfs.h (it was looking in the 9p file system instead of fatfs). That's fixed in the current github, or you can change it yourself in your local copy.

  • evanhevanh Posts: 15,912
    edited 2024-11-22 16:04

    Yes! I have the "SYNC" printing. Thank you.

    Ah, I see device init is called even before mounting now.

    I'm way past bedtime. Zzzz

  • RaymanRayman Posts: 14,638

    @ersmith Do you have an opinion on the best name for a file to hold pin and clock settings and such in?

    I've been using Platform.h (copied from Arduino). I see @Wuerfel_21 uses config.spin2 a lot (exclusively?).

    Maybe you have a different/better option/opinion?

Sign In or Register to comment.