This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

LPC1788 + RL-RTX + RL-FlashFS ( SD CARD)

I try to use RTX with RL-FlashFS (for SD Card).
I Initilized Memory Card in main.
in my tasks ;ffind,fattrib,frename function work well , but fopen Routine dont work.

i use (static U64 Main_stk[2200];) for task that use fopen function

any body can help me
Regards

  • Hi, I'm trying to use RLFlash + LPC1788 and I´m having problems. Could you post your MCI driver for LPC1788 ?

    I adjust a MCI driver, but don't work. I'm debugging in simulation mode and the finit (NULL) function call only the Init() of MCI driver. The others routines, BusWidth, BusSpeed, Command, ReadBlock... no calls are being.

    Someone know where is error ? Below is my MCI driver.

    
    #define __DRV_ID  mci0_drv
    #define __MCLK    48000000
    #define __CPUCLK  48000000
    
    /* MCI Driver Interface functions */
    static BOOL Init (void);
    static BOOL UnInit (void);
    static void Delay (U32 us);
    static BOOL BusMode (U32 mode);
    static BOOL BusWidth (U32 width);
    static BOOL BusSpeed (U32 kbaud);
    static BOOL Command (U8 cmd, U32 arg, U32 resp_type, U32 *rp);
    static BOOL ReadBlock (U32 bl, U8 *buf, U32 cnt);
    static BOOL WriteBlock (U32 bl, U8 *buf, U32 cnt);
    static U32  CheckMedia (void);        /* Optional function for SD card check */
    
    /* MCI Device Driver Control Block */
    MCI_DRV __DRV_ID = {
      Init,
      UnInit,
      Delay,
      BusMode,
      BusWidth,
      BusSpeed,
      Command,
      ReadBlock,
      WriteBlock,
      NULL,
      CheckMedia
    };
    
    #define DMA_TOUT  10000000
    
    static void DmaStart (U32 mode, U8 *buf);
    
    /*--------------------------- Init ------------------------------------------*/
    
    static BOOL Init (void) {
            /* Initialize MCI interface. */
    
      /* Power Up the MCI and DMA controller. */
      LPC_SC->PCONP   |=  (1 << 28) | (1 << 29);
    
      /* Enable MCI pins. */
            LPC_IOCON->P1_2  |= (1 << 9) | 2;      /* MCICLK */
      LPC_IOCON->P1_3  |= (1 << 9) | 2;      /* MCICMD */
      LPC_IOCON->P1_5  |= (1 << 9) | 2;      /* MCIPWR */
      LPC_IOCON->P1_6  |= (1 << 9) | 2;      /* MCIDAT0 */
      LPC_IOCON->P1_7  |= (1 << 9) | 2;      /* MCIDAT1 */
      LPC_IOCON->P1_11 |= (1 << 9) | 2;      /* MCIDAT2 */
      LPC_IOCON->P1_12 |= (1 << 9) | 2;      /* MCIDAT3 */
      /* Clear all pending interrupts. */
    
      LPC_MCI->COMMAND   = 0;
      LPC_MCI->DATACTRL = 0;
      LPC_MCI->CLEAR     = 0x7FF;
    
      /* Power up, switch on VCC for the Flash Card. */
      LPC_MCI->POWER  = 0x02;
      Delay (10000);
    
      /* Power on the Flash Card. */
      LPC_MCI->POWER |= 0x01;
        return MCI_FUNC_OK;
            }
    
    /*--------------------------- UnInit ----------------------------------------*/
    
    static BOOL UnInit (void) {
      /* Reset the MCI peripheral to default state. */
    
      /* Power down, switch off VCC for the Flash Card. */
      LPC_MCI->POWER = 0x00;
    
      /* Clear all pending interrupts. */
      LPC_MCI->COMMAND   = 0;
      LPC_MCI->DATACTRL = 0;
      LPC_MCI->CLEAR     = 0x7FF;
    
      return (__TRUE);
    }
    
    
    /*--------------------------- Delay -----------------------------------------*/
    
    static void Delay (U32 us) {
      /* Approximate delay in micro seconds. */
      U32 i;
    
      for (i = WAIT_CNT(__CPUCLK, us); i; i--);
    }
    
    
    /*--------------------------- BusMode ---------------------------------------*/
    
    static BOOL BusMode (U32 mode) {
      /* Set MCI Bus mode to Open Drain or Push Pull. */
    
      switch (mode) {
        case BUS_OPEN_DRAIN:
          LPC_MCI->POWER |= 0x40;
          return (__TRUE);
    
        case BUS_PUSH_PULL:
          LPC_MCI->POWER &= ~0x40;
          return (__TRUE);
      }
      return (__FALSE);
    }
    
    
    /*--------------------------- BusWidth --------------------------------------*/
    
    static BOOL BusWidth (U32 width) {
      /* Set MCI Bus width. */
    
      switch (width) {
        case 1:
          LPC_MCI->CLOCK &= ~0x0800;
          return (__TRUE);
    
        case 4:
          LPC_MCI->CLOCK |= 0x0800;
          return (__TRUE);
      }
      return (__FALSE);
    }
    
    
    /*--------------------------- BusSpeed --------------------------------------*/
    
    static BOOL BusSpeed (U32 kbaud) {
      /* Set a MCI clock speed to desired value. */
      U32 div;
    
      /* baud = MCLK / (2 x (div + 1)) */
      div = (__MCLK/2000 + kbaud - 1) / kbaud;
      if (div > 0)    div--;
      if (div > 0xFF) div = 0xFF;
      LPC_MCI->CLOCK = (LPC_MCI->CLOCK & ~0xFF) | 0x300 | div;
      return (__TRUE);
    }