예제 #1
0
파일: DiskIO.cs 프로젝트: valoni/FatFsFez
        public static void InitializeCpuIO()
        {
            if (chipSelectPin == null)
            {
                chipSelectPin = GpioController.GetDefault().OpenPin(CS_PIN_NUM);
                chipSelectPin.SetDriveMode(GpioPinDriveMode.Output);
                chipSelectPin.Write(GpioPinValue.High);
            }

            Spi.InitSpi();     /* Initialize ports to control MMC */
        }
예제 #2
0
파일: DiskIO.cs 프로젝트: valoni/FatFsFez
        /*-----------------------------------------------------------------------*/
        /* Select the card and wait for ready                                    */
        /*-----------------------------------------------------------------------*/

        static int select()     /* 1:OK, 0:Timeout */
        {
            /* Set CS# low */
            chipSelectPin.Write(GpioPinValue.Low);
            Spi.RcvSpi();                   /* Dummy clock (force DO enabled) */
            if (wait_ready() > 0)
            {
                return(1);                  /* Wait for card ready */
            }
            deselect();
            return(0);                               /* Failed */
        }
예제 #3
0
파일: DiskIO.cs 프로젝트: valoni/FatFsFez
        /*-----------------------------------------------------------------------*/
        /* Receive bytes from the card                                           */
        /*-----------------------------------------------------------------------*/

        static void rcvr_mmc(
            ref byte[] buff,    /* Pointer to read buffer */
            uint bc             /* Number of bytes to receive */
            )
        {
            int rxIndex = 0;

            do
            {
                buff[rxIndex++] = Spi.RcvSpi();     /* Store a received byte */
            }while (--bc > 0);
        }
예제 #4
0
파일: DiskIO.cs 프로젝트: valoni/FatFsFez
        static byte CardType;          /* b0:MMC, b1:SDv1, b2:SDv2, b3:Block addressing */



        /*-----------------------------------------------------------------------*/
        /* Transmit bytes to the card                                            */
        /*-----------------------------------------------------------------------*/

        static void xmit_mmc(
            byte[] buff,    /* Data to be sent */
            uint bc         /* Number of bytes to send */
            )
        {
            byte d;
            int  bufIndex = 0;

            do
            {
                d = buff[bufIndex++];         /* Get a byte to be sent */
                Spi.XmitSpi(d);
            } while (bufIndex < bc);
        }
예제 #5
0
파일: DiskIO.cs 프로젝트: valoni/FatFsFez
        /*-----------------------------------------------------------------------*/
        /* Deselect the card and release SPI bus                                 */
        /*-----------------------------------------------------------------------*/

        static void deselect()
        {
            chipSelectPin.Write(GpioPinValue.High);
            Spi.RcvSpi();       /* Dummy clock (force DO hi-z for multiple slave SPI) */
        }