Shell. Added possibility to create statically allocated shell thread.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3331 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
barthess 2011-09-17 21:06:25 +00:00
parent 278fc39f99
commit 62b5054dfa
2 changed files with 28 additions and 0 deletions

View File

@ -220,6 +220,8 @@ void shellInit(void) {
/**
* @brief Spawns a new shell.
*
* @pre @p CH_USE_MALLOC_HEAP and @p CH_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 the priority level for the new shell
@ -227,10 +229,34 @@ void shellInit(void) {
* @return A pointer to the shell thread.
* @retval NULL thread creation failed because memory allocation.
*/
#if CH_USE_HEAP && CH_USE_DYNAMIC
Thread *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 to be allocated
* @param[in] prio the priority level for the new shell
*
* @return A pointer to the shell thread.
*/
Thread *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.

View File

@ -80,6 +80,8 @@ extern "C" {
#endif
void shellInit(void);
Thread *shellCreate(const ShellConfig *scp, size_t size, tprio_t prio);
Thread *shellCreateStatic(const ShellConfig *scp, void *wsp,
size_t size, tprio_t prio);
bool_t shellGetLine(BaseChannel *chp, char *line, unsigned size);
#ifdef __cplusplus
}