* SCI module initialization.
* Call this method before using this module.
*
- * @param[in] baud Baud rate for the SCI. Tested values are 9600 and FIXME
- * Use 0 or any value less than 9600 to set to default 9600.
* @return SUCCESS if initialization successful.
- * FAILURE is module already initialized.
+ * FAILURE is module already initialized.
+ */
+int8_t rpp_sci_init();
+
+
+/**
+ * SCI module setup.
+ * Configure the SCI module.
+ *
+ * @param[in] baud Baud rate for the SCI. Tested values are 9600 and FIXME
+ * Default is 9600.
+ *
+ * @return TRUE if baud rate is a known value.
+ * FALSE otherwise.
*/
-int8_t rpp_sci_init(uint32_t baud);
+boolean_t rpp_sci_setup(uint32_t baud);
/**
#include "drv/drv.h"
-void drv_sci_init(uint32_t baud)
+void drv_sci_init()
{
// Low level init
sciInit();
+}
+void drv_sci_set_baudrate(baud)
+{
// Set baudrate
sciSetBaudrate(sciREG, baud);
}
#endif
#if rppCONFIG_INCLUDE_SCI == 1
- rpp_sci_init(0);
+ rpp_sci_init();
#endif
#if rppCONFIG_INCLUDE_ETH == 1
static boolean_t initialized = FALSE;
-int8_t rpp_sci_init(uint32_t baud)
+int8_t rpp_sci_init()
{
if(initialized) {
return FAILURE;
}
initialized = TRUE;
- if(baud < 9600) {
- baud = 9600;
+ #if rppCONFIG_DRV == 1
+ drv_sci_init();
+ #endif
+
+ return SUCCESS;
+}
+
+
+boolean_t rpp_sci_setup(uint32_t baud)
+{
+ boolean_t known = FALSE;
+
+ // FIXME This is a standard list of baud rates. This should include only
+ // tested baud rates.
+ switch(baud) {
+ case 110:
+ known = TRUE;
+ break;
+ case 300:
+ known = TRUE;
+ break;
+ case 600:
+ known = TRUE;
+ break;
+ case 1200:
+ known = TRUE;
+ break;
+ case 2400:
+ known = TRUE;
+ break;
+ case 4800:
+ known = TRUE;
+ break;
+ case 9600:
+ known = TRUE;
+ break;
+ case 14400:
+ known = TRUE;
+ break;
+ case 19200:
+ known = TRUE;
+ break;
+ case 28800:
+ known = TRUE;
+ break;
+ case 38400:
+ known = TRUE;
+ break;
+ case 56000:
+ known = TRUE;
+ break;
+ case 57600:
+ known = TRUE;
+ break;
+ case 115200:
+ known = TRUE;
+ break;
}
#if rppCONFIG_DRV == 1
- drv_sci_init(baud);
+ drv_sci_set_baudrate(baud);
#endif
- return SUCCESS;
+ return known;
}
+
int rpp_sci_printf(const char *format, ...)
{
char str[128];
}
- #ifdef DEBUG
/**
* FreeRTOS malloc() failed hook.
*/
void vApplicationMallocFailedHook(void) {
+ #ifdef DEBUG
rpp_sci_printf((const char*)"<malloc() failed>\r\n");
+ #endif
}
/**
*/
void vApplicationStackOverflowHook(xTaskHandle xTask,
signed portCHAR *pcTaskName) {
+ #ifdef DEBUG
rpp_sci_printf((const char*)"<stack overflow : \"%s\">\r\n", pcTaskName);
+ #endif
}
- #endif
%closefile tmpBuf
%<LibSetSourceFileSection(cFile, "Functions", tmpBuf)>