Add debug messages, some more code refactoring

This commit is contained in:
Michał Łyszczek 2016-08-17 21:53:04 +02:00
parent 2ae38b6bc6
commit efead3e564
6 changed files with 32 additions and 1 deletions

View File

@ -65,6 +65,7 @@ int board_adc_setup(void)
return OK;
}
ainfo("INFO: Initializing ADC12_IN10\n");
stm32_configgpio(GPIO_ADC12_IN10);
if ((adc = stm32_adcinitialize(1, channel, 1)) == NULL)
{
@ -79,6 +80,7 @@ int board_adc_setup(void)
}
initialized = true;
ainfo("INFO: ADC12_IN10 initialized succesfully\n");
return OK;
}

View File

@ -37,6 +37,7 @@
* Included Files
****************************************************************************/
#include <arch/board/board.h>
#include <nuttx/board.h>
#include <nuttx/config.h>
#include <stdbool.h>

View File

@ -37,10 +37,12 @@
* Included Files
****************************************************************************/
#include <debug.h>
#include <nuttx/config.h>
#include <nuttx/mmcsd.h>
#include <nuttx/spi/spi.h>
#include <pthread.h>
#include <sched.h>
#include <semaphore.h>
#include <time.h>
#include <unistd.h>
@ -96,9 +98,11 @@ static void *stm32_cd_thread(void *arg)
{
(void)arg;
spiinfo("INFO: Runnig card detect thread\n");
while (1)
{
sem_wait(&g_cdsem);
spiinfo("INFO: Card has been inserted, initializing\n");
if (g_chmediaclbk)
{
@ -159,6 +163,7 @@ static int stm32_cd(int irq, FAR void *context)
int stm32_spi1register(FAR struct spi_dev_s *dev, spi_mediachange_t callback,
FAR void *arg)
{
spiinfo("INFO: Registering spi1 device\n");
g_chmediaclbk = callback;
chmediaarg = arg;
return OK;
@ -178,6 +183,7 @@ int stm32_mmcsd_initialize(int minor)
pthread_attr_t pattr;
int rv;
spiinfo("INFO: Initializing mmcsd card\n");
if ((spi = stm32_spibus_initialize(SD_SPI_PORT)) == NULL)
{
ferr("failed to initialize SPI port %d\n", SD_SPI_PORT);
@ -203,9 +209,10 @@ int stm32_mmcsd_initialize(int minor)
#endif
schparam.sched_priority = 50;
pthread_attr_setschedparam(&pattr, &schedparam);
pthread_attr_setschedparam(&pattr, &schparam);
pthread_create(NULL, &pattr, stm32_cd_thread, NULL);
spiinfo("INFO: mmcsd card has been initialized successfully\n");
return OK;
}

View File

@ -36,6 +36,7 @@
* Included Files
****************************************************************************/
#include <debug.h>
#include <nuttx/spi/spi.h>
#include "stm32_butterfly2.h"
@ -59,6 +60,7 @@
void stm32_spidev_initialize(void)
{
spiinfo("INFO: Initializing spi gpio pins\n");
stm32_configgpio(GPIO_SD_CS);
stm32_configgpio(GPIO_SD_CD);
}
@ -73,6 +75,7 @@ void stm32_spidev_initialize(void)
void stm32_spi1select(FAR struct spi_dev_s *dev, enum spi_dev_e devid,
bool select)
{
spiinfo("INFO: Selecting spi dev: %d, state: %d\n", devid, select);
if (devid == SPIDEV_MMCSD)
{
stm32_gpiowrite(GPIO_SD_CS, !select);
@ -88,6 +91,7 @@ void stm32_spi1select(FAR struct spi_dev_s *dev, enum spi_dev_e devid,
uint8_t stm32_spi1status(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
{
spiinfo("INFO: Requesting info from spi dev: %d\n", devid);
if (devid == SPIDEV_MMCSD)
{
if (stm32_gpioread(GPIO_SD_CD) == 0)

View File

@ -37,6 +37,8 @@
* Include Files
****************************************************************************/
#include <debug.h>
#include "stm32_gpio.h"
#include "stm32_butterfly2.h"
@ -54,6 +56,7 @@
void stm32_usb_initialize(void)
{
uinfo("INFO: Initializing usb otgfs gpio pins\n");
stm32_configgpio(GPIO_OTGFS_VBUS);
stm32_configgpio(GPIO_OTGFS_PWRON);
}

View File

@ -37,10 +37,12 @@
* Include Files
****************************************************************************/
#include <debug.h>
#include <errno.h>
#include <nuttx/config.h>
#include <nuttx/usb/usbhost.h>
#include <pthread.h>
#include <sched.h>
#include <stdbool.h>
#include <stdint.h>
#include <sys/types.h>
@ -79,6 +81,7 @@ static void* usbhost_detect(void *arg)
(void)arg;
struct usbhost_hubport_s *hport;
uinfo("INFO: Starting usb detect thread\n");
for (;;)
{
CONN_WAIT(g_usbconn, &hport);
@ -108,6 +111,7 @@ int stm32_usbhost_initialize(void)
int rv;
#ifdef CONFIG_USBHOST_MSC
uinfo("INFO: Initializing USB MSC class\n");
if ((rv = usbhost_msc_initialize()) < 0)
{
uerr("ERROR: Failed to register mass storage class: %d\n", rv);
@ -115,6 +119,7 @@ int stm32_usbhost_initialize(void)
#endif
#ifdef CONFIG_USBHOST_CDACM
uinfo("INFO: Initializing CDCACM usb class\n");
if ((rv = usbhost_cdacm_initialize()) < 0)
{
uerr("ERROR: Failed to register CDC/ACM serial class: %d\n", rv);
@ -122,6 +127,7 @@ int stm32_usbhost_initialize(void)
#endif
#ifdef CONFIG_USBHOST_HIDKBD
uinfo("INFO: Initializing HID Keyboard usb class\n");
if ((rv = usbhost_kbdinit()) < 0)
{
uerr("ERROR: Failed to register the KBD class: %d\n", rv);
@ -129,6 +135,7 @@ int stm32_usbhost_initialize(void)
#endif
#ifdef CONFIG_USBHOST_HIDMOUSE
uinfo("INFO: Initializing HID Mouse usb class\n");
if ((rv = usbhost_mouse_init()) < 0)
{
uerr("ERROR: Failed to register the mouse class: %d\n", rv);
@ -136,6 +143,7 @@ int stm32_usbhost_initialize(void)
#endif
#ifdef CONFIG_USBHOST_HUB
uinfo("INFO: Initializing USB HUB class\n");
if ((rv = usbhost_hub_initialize()) < 0)
{
uerr("ERROR: Failed to register hub class: %d\n", rv);
@ -145,8 +153,14 @@ int stm32_usbhost_initialize(void)
if ((g_usbconn = stm32_otgfshost_initialize(0)))
{
pthread_attr_t pattr;
struct sched_param schparam;
pthread_attr_init(&pattr);
pthread_attr_setstacksize(&pattr, 2048);
schparam.sched_priority = 50;
pthread_attr_setschedparam(&pattr, &schparam);
return pthread_create(NULL, &pattr, usbhost_detect, NULL);
}