Exemplo n.º 1
0
static THD_FUNCTION(msg_thread1, p) {

  chMsgSend(p, 'A');
  chMsgSend(p, 'B');
  chMsgSend(p, 'C');
  chMsgSend(p, 'D');
}
Exemplo n.º 2
0
static msg_t thread(void *p) {

  chMsgSend(p, 'A');
  chMsgSend(p, 'B');
  chMsgSend(p, 'C');
  chMsgSend(p, 'D');
  return 0;
}
Exemplo n.º 3
0
static unsigned int msg_loop_test(Thread *tp) {

  uint32_t n = 0;
  test_wait_tick();
  test_start_timer(1000);
  do {
    (void)chMsgSend(tp, 1);
    n++;
#if defined(SIMULATOR)
    ChkIntSources();
#endif
  } while (!test_timer_done);
  (void)chMsgSend(tp, 0);
  return n;
}
Exemplo n.º 4
0
  msg_t ThreadReference::sendMessage(msg_t msg) {

    chDbgAssert(thread_ref != NULL,
                "not referenced");

    return chMsgSend(thread_ref, msg);
  }
Exemplo n.º 5
0
/**
 * @brief Close File.
 *
 * @param fp    Pointer to the file object to be closed.
 * @return
 */
FRESULT wf_close (FIL* fp) {
    struct wrapper_msg_pFIL msg;

    msg.action = eFCLOSE;
    msg.filep = fp;

    chMsgSend(workerThread, (msg_t) &msg);
    return msg.result;
}
Exemplo n.º 6
0
/**
 * @brief Truncate File.
 *
 * @param fp    Pointer to the file object.
 * @return
 */
FRESULT wf_truncate (FIL* fp) {
    struct wrapper_msg_pFIL msg;

    msg.action = eFTRUNCATE;
    msg.filep = fp;

    chMsgSend(workerThread, (msg_t) &msg);
    return msg.result;
}
Exemplo n.º 7
0
/**
 * @brief Create a Directory.
 * @param path  Pointer to the directory path.
 * @return
 */
FRESULT wf_mkdir (const TCHAR* path) {
    struct wrapper_msg_pTCHAR msg;

    msg.action = eFMKDIR;
    msg.string = (TCHAR*) path;

    chMsgSend(workerThread, (msg_t) &msg);
    return msg.result;
}
Exemplo n.º 8
0
/**
 * @brief Change current drive.
 * @param drv    Drive number.
 * @return
 */
FRESULT wf_chdrive (BYTE drv) {
    struct wrapper_msg_vBYTE msg;

    msg.action = eFCHDRIVE;
    msg.byte = drv;

    chMsgSend(workerThread, (msg_t) &msg);
    return msg.result;
}
Exemplo n.º 9
0
/**
 * @brief Mount/Unmount a logical Drive
 * @param vol   Logical drive number to be mounted/unmounted.
 * @param fs    Pointer to new file system object (NULL for unmount).
 * @return
 */
FRESULT wf_mount (BYTE vol, FATFS* fs) {
    struct wrapper_msg_vBYTEpFATFS msg;

    msg.action = eFMOUNT;
    msg.byte = vol;
    msg.fatfsp = fs;

    chMsgSend(workerThread, (msg_t) &msg);
    return msg.result;
}
Exemplo n.º 10
0
/**
 * @brief Put a string to the file.
 * @param str   Pointer to the string to be output.
 * @param fil   Pointer to the file object.
 * @return
 */
int wf_puts (const TCHAR* str, FIL* fil) {
    struct wrapper_msg_pTCHARpFIL msg;

    msg.action = eFPUTS;
    msg.string = (TCHAR*) str;
    msg.filep = fil;

    chMsgSend(workerThread, (msg_t) &msg);
    return msg.result;
}
Exemplo n.º 11
0
/**
 * @brief Seek File R/W Pointer.
 *
 * @param fp    Pointer to the file object.
 * @param ofs   File pointer from top of file.
 * @return
 */
FRESULT wf_lseek (FIL* fp, DWORD ofs) {
    struct wrapper_msg_pFILvDWORD msg;

    msg.action = eFLSEEK;
    msg.filep = fp;
    msg.dword = ofs;

    chMsgSend(workerThread, (msg_t) &msg);
    return msg.result;
}
Exemplo n.º 12
0
/**
 * @brief Change Timestamp.
 *
 * @param path  Pointer to the file/directory name.
 * @param fno   Pointer to the time stamp to be set.
 * @return
 */
FRESULT wf_utime (const TCHAR* path, const FILINFO* fno) {
    struct wrapper_msg_pTCHARpFILINFO msg;

    msg.action = eFUTIME;
    msg.string = (TCHAR*) path;
    msg.filinfop = (FILINFO*) fno;

    chMsgSend(workerThread, (msg_t) &msg);
    return msg.result;
}
Exemplo n.º 13
0
/**
 * @brief Rename File/Directory.
 * @param path_old  Pointer to the old name.
 * @param path_new  Pointer to the new name
 * @return
 */
FRESULT wf_rename (const TCHAR* path_old, const TCHAR* path_new) {
    struct wrapper_msg_pTCHARpTCHAR msg;

    msg.action = eFRENAME;
    msg.string1 = (TCHAR*) path_old;
    msg.string2 = (TCHAR*) path_new;

    chMsgSend(workerThread, (msg_t) &msg);
    return msg.result;
}
Exemplo n.º 14
0
/**
 * @brief Read Directory Entry in Sequence
 * @param dj    Pointer to the open directory object.
 * @param fno   Pointer to file information to return.
 * @return
 */
FRESULT wf_readdir (DIR* dj, FILINFO* fno) {
    struct wrapper_msg_pDIRpFILINFO msg;

    msg.action = eFREADDIR;
    msg.dirp = dj;
    msg.filinfop = fno;

    chMsgSend(workerThread, (msg_t) &msg);
    return msg.result;
}
Exemplo n.º 15
0
/**
 * @brief Get File Status.
 *
 * @param path  Pointer to the file path.
 * @param fno   Pointer to file information to return.
 * @return
 */
FRESULT wf_stat (const TCHAR* path, FILINFO* fno) {
    struct wrapper_msg_pTCHARpFILINFO msg;

    msg.action = eFSTAT;
    msg.string = (TCHAR*) path;
    msg.filinfop = fno;

    chMsgSend(workerThread, (msg_t) &msg);
    return msg.result;
}
Exemplo n.º 16
0
/**
 * @brief Get current working directory.
 * @param path      Pointer to the directory path.
 * @param sz_path   Size of path.
 * @return
 */
FRESULT wf_getcwd (TCHAR* path, UINT sz_path) {
    struct wrapper_msg_pTCHARvUINT msg;

    msg.action = eFGETCWD;
    msg.string = (TCHAR*) path;
    msg.uint = sz_path;

    chMsgSend(workerThread, (msg_t) &msg);
    return msg.result;
}
Exemplo n.º 17
0
/**
 * @brief Create a Directory Object
 *
 * @param dj    Pointer to directory object to create.
 * @param path  Pointer to the directory path.
 * @return
 */
FRESULT wf_opendir (DIR* dj, const TCHAR* path) {
    struct wrapper_msg_pDIRpTCHAR msg;

    msg.action = eFOPENDIR;
    msg.dirp = dj;
    msg.string = (TCHAR*) path;

    chMsgSend(workerThread, (msg_t) &msg);
    return msg.result;
}
Exemplo n.º 18
0
/**
 * @brief Change Attribute.
 *
 * @param path  Pointer to the file path.
 * @param value Attribute bits.
 * @param mask  Attribute mask to change.
 * @return
 */
FRESULT wf_chmod (const TCHAR* path, BYTE value, BYTE mask) {
    struct wrapper_msg_pTCHARvBYTEvBYTE msg;

    msg.action = eFCHMOD;
    msg.string = (TCHAR*) path;
    msg.byte1 = value;
    msg.byte2 = mask;

    chMsgSend(workerThread, (msg_t) &msg);
    return msg.result;
}
Exemplo n.º 19
0
/**
 * @brief Get a string from the file.
 * @param buff  Pointer to the string buffer to read.
 * @param len   Size of string buffer (characters).
 * @param fil   Pointer to the file object.
 * @return
 */
TCHAR* wf_gets (TCHAR* buff, int len, FIL* fil) {
    struct wrapper_msg_pTCHARvINTpFILpTCHAR msg;

    msg.action = eFGETS;
    msg.string = buff;
    msg.n = len;
    msg.filep = fil;

    chMsgSend(workerThread, (msg_t) &msg);
    return msg.string2;
}
Exemplo n.º 20
0
/**
 * @brief Put a character to the file.
 * @param c     A character to be output.
 * @param fil   Pointer to the file object.
 * @return
 */
int wf_putc (TCHAR c, FIL* fil) {
    struct wrapper_msg_vTCHARpFIL msg;

    msg.action = eFPUTC;
    msg.tchar = c;
    msg.filep = fil;


    chMsgSend(workerThread, (msg_t) &msg);
    return msg.result;
}
Exemplo n.º 21
0
void wf_terminate (void) {
    struct wrapper_msg_base msg;

    if (workerThread) {
        msg.action = eTERMINATE;

        chThdTerminate(workerThread);
        chMsgSend(workerThread, (msg_t) &msg);
    }
    return;
}
Exemplo n.º 22
0
/**
 * @brief Divide Physical Drive
 * @param pdrv  Physical drive number.
 * @param szt   Pointer to the size table for each partitions.
 * @param work  Pointer to the working buffer.
 * @return
 */
FRESULT wf_fdisk (BYTE pdrv, const DWORD szt[], void* work) {
    struct wrapper_msg_vBYTEpDWORDpVOID msg;

    msg.action = eFFDISK;
    msg.byte = pdrv;
    msg.dwordp = (DWORD*) szt;
    msg.voidp = work;

    chMsgSend(workerThread, (msg_t) &msg);
    return msg.result;
}
Exemplo n.º 23
0
/**
 * @brief Open or Create a File.
 *
 * @param fp    Pointer to the blank file object.
 * @param path  Pointer to the file name.
 * @param mode  Access mode and file open mode flags.
 * @return
 */
FRESULT wf_open (FIL* fp, const TCHAR* path, BYTE mode) {
    struct wrapper_msg_pFILpTCHARvBYTE msg;

    msg.action = eFOPEN;
    msg.filep = fp;
    msg.string = (TCHAR*) path;
    msg.byte = mode;

    chMsgSend(workerThread, (msg_t) &msg);
    return msg.result;
}
Exemplo n.º 24
0
/**
 * @brief Create File System on the Drive.
 * @param drv   Logical drive number.
 * @param sfd   Partitioning rule 0:FDISK, 1:SFD.
 * @param au    Allocation unit size [bytes].
 * @return
 */
FRESULT wf_mkfs (BYTE drv, BYTE sfd, UINT au) {
    struct wrapper_msg_vBYTEvBYTEvUINT msg;

    msg.action = eFMKFS;
    msg.byte1 = drv;
    msg.byte2 = sfd;
    msg.uint = au;

    chMsgSend(workerThread, (msg_t) &msg);
    return msg.result;
}
Exemplo n.º 25
0
/**
 * @brief Get Number of Free Clusters.
 *
 * @param path  Pointer to the logical drive number (root dir).
 * @param nclst Pointer to the variable to return number of free clusters,
 * @param fatfs Pointer to pointer to corresponding file system object to
 *              return.
 * @return
 */
FRESULT wf_getfree (const TCHAR* path, DWORD*nclst, FATFS** fatfs) {
    struct wrapper_msg_pTCHARpDWORDppFATFS msg;

    msg.action = eFGETFREE;
    msg.string = (TCHAR*) path;
    msg.dwordp = nclst;
    msg.fatfspp = fatfs;

    chMsgSend(workerThread, (msg_t) &msg);
    return msg.result;
}
Exemplo n.º 26
0
/**
 * @brief Write File.
 *
 * @param fp    Pointer to the file object.
 * @param buff  Pointer to the data to be written.
 * @param btw   Number of bytes to write.
 * @param bw    Pointer to number of bytes written.
 * @return
 */
FRESULT wf_write (FIL* fp, const void* buff, UINT btw, UINT* bw) {
    struct wrapper_msg_pFILpVOIDvUINTpUINT msg;

    msg.action = eFWRITE;
    msg.filep = fp;
    msg.voidp = (void*) buff;
    msg.uint = btw;
    msg.uintp = bw;

    chMsgSend(workerThread, (msg_t) &msg);
    return msg.result;
}
Exemplo n.º 27
0
/**
 * @brief Read File
 *
 * @param fp    Pointer to the file object.
 * @param buff  Pointer to data buffer.
 * @param btr   Number of bytes to read.
 * @param br    Pointer to number of bytes read.
 * @return
 */
FRESULT wf_read (FIL* fp, void* buff, UINT btr, UINT* br) {
    struct wrapper_msg_pFILpVOIDvUINTpUINT msg;

    msg.action = eFREAD;
    msg.filep = fp;
    msg.voidp = buff;
    msg.uint = btr;
    msg.uintp = br;

    chMsgSend(workerThread, (msg_t) &msg);
    return msg.result;
}
Exemplo n.º 28
0
int main(void) {

  /*
   * System initializations.
   * - HAL initialization, this also initializes the configured device drivers
   *   and performs the board-specific initializations.
   * - Kernel initialization, the main() function becomes a thread and the
   *   RTOS is active.
   */
  halInit();
  chSysInit();

  /*
   * Activates the serial driver 2 using the driver default configuration.
   */
  sdStart(&SD2, NULL);

  /*
   * Creates the blinker thread.
   */
  console = chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);

  /*
   * Normal main() thread activity, in this demo it does nothing except
   * sleeping in a loop and check the button state.
   */
  while (true) {
    if (!palReadPad(GPIOC, GPIOC_BUTTON)) {
        palSetPad(GPIOA, GPIOA_LED_GREEN);
        (void)chMsgSend(console, (msg_t)"ON");    }
    else {
        palClearPad(GPIOA, GPIOA_LED_GREEN);
        (void)chMsgSend(console, (msg_t)"OFF");    }
    chThdSleepMilliseconds(50);
  }
}
Exemplo n.º 29
0
static THD_FUNCTION(thread, p) {

  chMsgSend(p, 'A');
  chMsgSend(p, 'B');
  chMsgSend(p, 'C');
}
Exemplo n.º 30
0
  msg_t BaseThread::SendMessage(msg_t msg) {

    return chMsgSend(thread_ref, msg);
  }