diff options
| author | Giovanni Di Sirio <gdisirio@gmail.com> | 2016-02-19 16:32:09 +0000 | 
|---|---|---|
| committer | Giovanni Di Sirio <gdisirio@gmail.com> | 2016-02-19 16:32:09 +0000 | 
| commit | 4f3674f5f22d41dd58a6ea51d3a5fed89ef1990b (patch) | |
| tree | 03859edf86e74755fb0c493b0e9e55f525204b77 | |
| parent | 6865ddcce5e27e124f2f7c114391191ce1f4bd27 (diff) | |
| download | ChibiOS-4f3674f5f22d41dd58a6ea51d3a5fed89ef1990b.tar.gz ChibiOS-4f3674f5f22d41dd58a6ea51d3a5fed89ef1990b.tar.bz2 ChibiOS-4f3674f5f22d41dd58a6ea51d3a5fed89ef1990b.zip  | |
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@8912 35acf78f-673a-0410-8e92-d51de3d6d3f4
| -rw-r--r-- | os/hal/ports/STM32/LLD/OTGv1/usb_lld.c | 22 | ||||
| -rw-r--r-- | os/various/shell.c | 45 | ||||
| -rw-r--r-- | os/various/shell.h | 6 | ||||
| -rw-r--r-- | testhal/STM32/STM32F7xx/GPT-ADC/chconf.h | 2 | ||||
| -rw-r--r-- | testhal/STM32/STM32F7xx/IRQ_STORM/chconf.h | 2 | ||||
| -rw-r--r-- | testhal/STM32/STM32F7xx/PWM-ICU/chconf.h | 2 | ||||
| -rw-r--r-- | testhal/STM32/STM32F7xx/SPI/chconf.h | 2 | ||||
| -rw-r--r-- | testhal/STM32/STM32F7xx/USB_CDC/chconf.h | 2 | ||||
| -rw-r--r-- | testhal/STM32/STM32F7xx/USB_CDC/main.c | 29 | ||||
| -rw-r--r-- | testhal/STM32/STM32F7xx/USB_RAW/chconf.h | 2 | 
10 files changed, 48 insertions, 66 deletions
diff --git a/os/hal/ports/STM32/LLD/OTGv1/usb_lld.c b/os/hal/ports/STM32/LLD/OTGv1/usb_lld.c index 6224cbb5c..ffdaaf3ca 100644 --- a/os/hal/ports/STM32/LLD/OTGv1/usb_lld.c +++ b/os/hal/ports/STM32/LLD/OTGv1/usb_lld.c @@ -714,10 +714,7 @@ void usb_lld_init(void) {    {
      void *wsp = USBD2.wa_pump;
      _thread_memfill((uint8_t *)wsp,
 -                    (uint8_t *)wsp + sizeof(thread_t),
 -                    CH_DBG_THREAD_FILL_VALUE);
 -    _thread_memfill((uint8_t *)wsp + sizeof(thread_t),
 -                    (uint8_t *)wsp + sizeof(USBD2.wa_pump),
 +                    (uint8_t *)wsp + sizeof (USBD2.wa_pump),
                      CH_DBG_STACK_FILL_VALUE);
    }
  #endif /* CH_DBG_FILL_THREADS */
 @@ -861,10 +858,16 @@ void usb_lld_start(USBDriver *usbp) {  #if defined(_CHIBIOS_RT_)
      /* Creates the data pump thread. Note, it is created only once.*/
      if (usbp->tr == NULL) {
 -      usbp->tr = chThdCreateI(usbp->wa_pump, sizeof usbp->wa_pump,
 -                              STM32_USB_OTG_THREAD_PRIO,
 -                              usb_lld_pump, usbp);
 -      chThdStartI(usbp->tr);
 +      thread_descriptor_t usbpump_descriptor = {
 +        "usb_pump",
 +        THD_WORKING_AREA_BASE(usbp->wa_pump),
 +        THD_WORKING_AREA_END(usbp->wa_pump),
 +        STM32_USB_OTG_THREAD_PRIO,
 +        usb_lld_pump,
 +        (void *)usbp
 +      };
 +
 +      usbp->tr = chThdCreateI(&usbpump_descriptor);
        chSchRescheduleS();
    }
  #endif
 @@ -1286,9 +1289,6 @@ void usb_lld_pump(void *p) {    USBDriver *usbp = (USBDriver *)p;
    stm32_otg_t *otgp = usbp->otg;
 -#if defined(_CHIBIOS_RT_)
 -  chRegSetThreadName("usb_lld_pump");
 -#endif
    osalSysLock();
    while (true) {
      usbep_t ep;
 diff --git a/os/various/shell.c b/os/various/shell.c index 0de6f449a..a60f9b479 100644 --- a/os/various/shell.c +++ b/os/various/shell.c @@ -133,7 +133,7 @@ static bool cmdexec(const ShellCommand *scp, BaseSequentialStream *chp,   *
   * @param[in] p         pointer to a @p BaseSequentialStream object
   */
 -static THD_FUNCTION(shell_thread, p) {
 +THD_FUNCTION(shellThread, p) {
    int n;
    BaseSequentialStream *chp = ((ShellConfig *)p)->sc_channel;
    const ShellCommand *scp = ((ShellConfig *)p)->sc_commands;
 @@ -218,43 +218,14 @@ void shellExit(msg_t msg) {  }
  /**
 - * @brief   Spawns a new shell.
 - * @pre     @p CH_CFG_USE_HEAP and @p CH_CFG_USE_DYNAMIC must be enabled.
 - *
 - * @param[in] scp       pointer to a @p ShellConfig object
 - * @param[in] size      size of the shell working area to be allocated
 - * @param[in] prio      priority level for the new shell
 - * @return              A pointer to the shell thread.
 - * @retval NULL         thread creation failed because memory allocation.
 - *
 - * @api
 - */
 -#if CH_CFG_USE_HEAP && CH_CFG_USE_DYNAMIC
 -thread_t *shellCreate(const ShellConfig *scp, size_t size, tprio_t prio) {
 -
 -  return chThdCreateFromHeap(NULL, size, prio, shell_thread, (void *)scp);
 -}
 -#endif
 -
 -/**
 - * @brief   Create statically allocated shell thread.
 - *
 - * @param[in] scp       pointer to a @p ShellConfig object
 - * @param[in] wsp       pointer to a working area dedicated to the shell thread stack
 - * @param[in] size      size of the shell working area
 - * @param[in] prio      priority level for the new shell
 - * @return              A pointer to the shell thread.
 - *
 - * @api
 - */
 -thread_t *shellCreateStatic(const ShellConfig *scp, void *wsp,
 -                            size_t size, tprio_t prio) {
 -
 -  return chThdCreateStatic(wsp, size, prio, shell_thread, (void *)scp);
 -}
 -
 -/**
   * @brief   Reads a whole line from the input channel.
 + * @note    Input chars are echoed on the same stream object with the
 + *          following exceptions:
 + *          - DEL and BS are echoed as BS-SPACE-BS.
 + *          - CR is echoed as CR-LF.
 + *          - 0x4 is echoed as "^D".
 + *          - Other values below 0x20 are not echoed.
 + *          .
   *
   * @param[in] chp       pointer to a @p BaseSequentialStream object
   * @param[in] line      pointer to the line buffer
 diff --git a/os/various/shell.h b/os/various/shell.h index 29d20db5e..9ee73d4dc 100644 --- a/os/various/shell.h +++ b/os/various/shell.h @@ -70,12 +70,8 @@ extern event_source_t shell_terminated;  extern "C" {
  #endif
    void shellInit(void);
 +  THD_FUNCTION(shellThread, p);
    void shellExit(msg_t msg);
 -#if CH_CFG_USE_HEAP && CH_CFG_USE_DYNAMIC
 -  thread_t *shellCreate(const ShellConfig *scp, size_t size, tprio_t prio);
 -#endif
 -  thread_t *shellCreateStatic(const ShellConfig *scp, void *wsp,
 -                              size_t size, tprio_t prio);
    bool shellGetLine(BaseSequentialStream *chp, char *line, unsigned size);
  #ifdef __cplusplus
  }
 diff --git a/testhal/STM32/STM32F7xx/GPT-ADC/chconf.h b/testhal/STM32/STM32F7xx/GPT-ADC/chconf.h index edd657ac1..95b002cc3 100644 --- a/testhal/STM32/STM32F7xx/GPT-ADC/chconf.h +++ b/testhal/STM32/STM32F7xx/GPT-ADC/chconf.h @@ -524,6 +524,8 @@  /* Port-specific settings (override port settings defaulted in chcore.h).    */
  /*===========================================================================*/
 +#define CORTEX_VTOR_INIT                    0x00200000U
 +
  #endif  /* _CHCONF_H_ */
  /** @} */
 diff --git a/testhal/STM32/STM32F7xx/IRQ_STORM/chconf.h b/testhal/STM32/STM32F7xx/IRQ_STORM/chconf.h index edd657ac1..95b002cc3 100644 --- a/testhal/STM32/STM32F7xx/IRQ_STORM/chconf.h +++ b/testhal/STM32/STM32F7xx/IRQ_STORM/chconf.h @@ -524,6 +524,8 @@  /* Port-specific settings (override port settings defaulted in chcore.h).    */
  /*===========================================================================*/
 +#define CORTEX_VTOR_INIT                    0x00200000U
 +
  #endif  /* _CHCONF_H_ */
  /** @} */
 diff --git a/testhal/STM32/STM32F7xx/PWM-ICU/chconf.h b/testhal/STM32/STM32F7xx/PWM-ICU/chconf.h index edd657ac1..95b002cc3 100644 --- a/testhal/STM32/STM32F7xx/PWM-ICU/chconf.h +++ b/testhal/STM32/STM32F7xx/PWM-ICU/chconf.h @@ -524,6 +524,8 @@  /* Port-specific settings (override port settings defaulted in chcore.h).    */
  /*===========================================================================*/
 +#define CORTEX_VTOR_INIT                    0x00200000U
 +
  #endif  /* _CHCONF_H_ */
  /** @} */
 diff --git a/testhal/STM32/STM32F7xx/SPI/chconf.h b/testhal/STM32/STM32F7xx/SPI/chconf.h index edd657ac1..95b002cc3 100644 --- a/testhal/STM32/STM32F7xx/SPI/chconf.h +++ b/testhal/STM32/STM32F7xx/SPI/chconf.h @@ -524,6 +524,8 @@  /* Port-specific settings (override port settings defaulted in chcore.h).    */
  /*===========================================================================*/
 +#define CORTEX_VTOR_INIT                    0x00200000U
 +
  #endif  /* _CHCONF_H_ */
  /** @} */
 diff --git a/testhal/STM32/STM32F7xx/USB_CDC/chconf.h b/testhal/STM32/STM32F7xx/USB_CDC/chconf.h index edd657ac1..95b002cc3 100644 --- a/testhal/STM32/STM32F7xx/USB_CDC/chconf.h +++ b/testhal/STM32/STM32F7xx/USB_CDC/chconf.h @@ -524,6 +524,8 @@  /* Port-specific settings (override port settings defaulted in chcore.h).    */
  /*===========================================================================*/
 +#define CORTEX_VTOR_INIT                    0x00200000U
 +
  #endif  /* _CHCONF_H_ */
  /** @} */
 diff --git a/testhal/STM32/STM32F7xx/USB_CDC/main.c b/testhal/STM32/STM32F7xx/USB_CDC/main.c index 16b298bc1..b75c37cda 100644 --- a/testhal/STM32/STM32F7xx/USB_CDC/main.c +++ b/testhal/STM32/STM32F7xx/USB_CDC/main.c @@ -34,17 +34,18 @@  #define TEST_WA_SIZE    THD_WORKING_AREA_SIZE(256)
  static void cmd_mem(BaseSequentialStream *chp, int argc, char *argv[]) {
 -  size_t n, size;
 +  size_t n, total, largest;
    (void)argv;
    if (argc > 0) {
      chprintf(chp, "Usage: mem\r\n");
      return;
    }
 -  n = chHeapStatus(NULL, &size);
 +  n = chHeapStatus(NULL, &total, &largest);
    chprintf(chp, "core free memory : %u bytes\r\n", chCoreGetStatusX());
    chprintf(chp, "heap fragments   : %u\r\n", n);
 -  chprintf(chp, "heap free total  : %u bytes\r\n", size);
 +  chprintf(chp, "heap free total  : %u bytes\r\n", total);
 +  chprintf(chp, "heap free largest: %u bytes\r\n", largest);
  }
  static void cmd_threads(BaseSequentialStream *chp, int argc, char *argv[]) {
 @@ -56,13 +57,13 @@ static void cmd_threads(BaseSequentialStream *chp, int argc, char *argv[]) {      chprintf(chp, "Usage: threads\r\n");
      return;
    }
 -  chprintf(chp, "    addr    stack prio refs     state time\r\n");
 +  chprintf(chp, "stklimit    stack     addr prio     state         name\r\n");
    tp = chRegFirstThread();
    do {
 -    chprintf(chp, "%08lx %08lx %4lu %4lu %9s\r\n",
 -            (uint32_t)tp, (uint32_t)tp->p_ctx.r13,
 -            (uint32_t)tp->p_prio, (uint32_t)(tp->p_refs - 1),
 -            states[tp->p_state]);
 +    chprintf(chp, "%08lx %08lx %08lx %4lu %9s %12s\r\n",
 +             (uint32_t)tp->stklimit, (uint32_t)tp->ctx.r13, (uint32_t)tp,
 +             (uint32_t)tp->prio, states[tp->state],
 +             tp->name == NULL ? "" : tp->name);
      tp = chRegNextThread(tp);
    } while (tp != NULL);
  }
 @@ -209,14 +210,16 @@ int main(void) {    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.
 +   * Normal main() thread activity, spawning shells.
     */
    while (true) {
 -    if (!shelltp && (SDU2.config->usbp->state == USB_ACTIVE))
 -      shelltp = shellCreate(&shell_cfg1, SHELL_WA_SIZE, NORMALPRIO);
 +    if (!shelltp && (SDU2.config->usbp->state == USB_ACTIVE)) {
 +      shelltp = chThdCreateFromHeap(NULL, SHELL_WA_SIZE, NORMALPRIO + 1,
 +                                    shellThread, (void *)&shell_cfg1);
 +    }
      else if (chThdTerminatedX(shelltp)) {
 -      chThdRelease(shelltp);    /* Recovers memory of the previous shell.   */
 +      chThdWait(shelltp);
 +      chHeapFree(chthdGetStackLimitX(shelltp));
        shelltp = NULL;           /* Triggers spawning of a new shell.        */
      }
  #if 0
 diff --git a/testhal/STM32/STM32F7xx/USB_RAW/chconf.h b/testhal/STM32/STM32F7xx/USB_RAW/chconf.h index edd657ac1..95b002cc3 100644 --- a/testhal/STM32/STM32F7xx/USB_RAW/chconf.h +++ b/testhal/STM32/STM32F7xx/USB_RAW/chconf.h @@ -524,6 +524,8 @@  /* Port-specific settings (override port settings defaulted in chcore.h).    */
  /*===========================================================================*/
 +#define CORTEX_VTOR_INIT                    0x00200000U
 +
  #endif  /* _CHCONF_H_ */
  /** @} */
  | 
