Shop OBEX P1 Docs P2 Docs Learn Events
Access to propeller-load's config variables — Parallax Forums

Access to propeller-load's config variables

DavidZemonDavidZemon Posts: 2,973
edited 2015-04-20 20:05 in Propeller 1
Someone mentioned in another thread that I can get access to propeller-load's UART settings with three special variables: _cfg_rxpin, _cfg_txpin, and _cfg_baudrate. These have been working great for me and I'm now hoping to use that same method for connecting to my SD card, but I can't figure out what to name the variables :'(

I tried these, but they didn't work.

_cfg_sdspi_do
_cfg_sdspi_di
_cfg_sdspi_clk
_cfg_sdspi_cs

Comments

  • kwinnkwinn Posts: 8,697
    edited 2015-04-20 18:52
    Maybe leave off the "spi" part of the name. Anyone knowledgeable enough to be working with this should know an sd card uses spi for access.
  • DavidZemonDavidZemon Posts: 2,973
    edited 2015-04-20 18:56
    kwinn wrote: »
    Maybe leave off the "spi" part of the name. Anyone knowledgeable enough to be working with this should know an sd card uses spi for access.

    Worthy guess, but that didn't work either.

    I'm finding references to _cfg_sdspi_config1 and _cfg_sdspi_config2 though. Looks like config1 is an encoded version of three of the variables and config2 is the fourth. Knowing that it's split 3/1, I would guess CS is in config2. Now, to figure out how to return them.
  • Dave HeinDave Hein Posts: 6,347
    edited 2015-04-20 19:39
    Look at the function dfs_mount in lib/drivers/mount.c in the library source code. The _SD_Params struct is defined in lib/include/sys/sd.h. The PropGCC SD driver can accommodate three different ways of doing the chip select, which are single, serial demux and parallel demux.
  • DavidZemonDavidZemon Posts: 2,973
    edited 2015-04-20 20:05
    Thanks! That did it :)
    extern int _cfg_sdspi_config1;
    extern int _cfg_sdspi_config2;
    
    void unpack_sd_pins (uint32_t pins[]) {
        __asm__ volatile (
                "       brw #skipVars          \n\t"
                "       .compress off          \n"
                "__cfg_sdspi_config1           \n\t"
                "       nop                    \n"
                "__cfg_sdspi_config2           \n\t"
                "       nop                    \n\t"
                "       .compress default      \n"
                "skipVars:                     \n\t"
        );
    
        pins[0] = (uint32_t) (1 << ((_cfg_sdspi_config1 & BYTE_2) >> 16));
        pins[1] = (uint32_t) (1 << ((_cfg_sdspi_config1 & BYTE_3) >> 24));
        pins[2] = (uint32_t) (1 << ((_cfg_sdspi_config1 & BYTE_1) >> 8));
        pins[3] = (uint32_t) (1 << ((_cfg_sdspi_config2 & BYTE_3) >> 24));
    }
    

    Now I have a no-arg constructor in my SD class :D
Sign In or Register to comment.