Cosmetic changes from review of last PR.
This commit is contained in:
parent
07f9154e5b
commit
230c80b8e1
@ -46,9 +46,11 @@
|
||||
#include <nuttx/board.h>
|
||||
#include <nuttx/spi/spi.h>
|
||||
#include <nuttx/modem/altmdm.h>
|
||||
|
||||
#if defined(CONFIG_MODEM_ALTMDM) && defined(CONFIG_CXD56_GPIO_IRQ)
|
||||
#include <arch/board/board.h>
|
||||
#include <arch/board/cxd56_altmdm.h>
|
||||
|
||||
#include "cxd56_gpio.h"
|
||||
#include "cxd56_gpioint.h"
|
||||
#include "cxd56_pinconfig.h"
|
||||
@ -76,11 +78,11 @@
|
||||
#if defined(CONFIG_MODEM_ALTMDM) && defined(CONFIG_CXD56_GPIO_IRQ)
|
||||
|
||||
struct altmdm_pincfg
|
||||
{
|
||||
uint32_t pin;
|
||||
bool input_enable;
|
||||
bool init_val;
|
||||
};
|
||||
{
|
||||
uint32_t pin;
|
||||
bool input_enable;
|
||||
bool init_val;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@ -92,9 +94,9 @@ struct altmdm_pincfg
|
||||
|
||||
static const struct altmdm_pincfg pincfg[] =
|
||||
{
|
||||
{MODEM_WAKEUP, false, false}, /* out, low */
|
||||
{MASTER_REQUEST, false, false}, /* out, low */
|
||||
{SLAVE_REQUEST, true, false}, /* in, low */
|
||||
{MODEM_WAKEUP, false, false}, /* out, low */
|
||||
{MASTER_REQUEST, false, false}, /* out, low */
|
||||
{SLAVE_REQUEST, true, false}, /* in, low */
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -117,7 +119,7 @@ void board_altmdm_poweron(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* power on altair modem device */
|
||||
/* Power on altair modem device */
|
||||
|
||||
cxd56_gpio_config(ALTMDM_SHUTDOWN, false);
|
||||
cxd56_gpio_write(ALTMDM_SHUTDOWN, true);
|
||||
@ -262,6 +264,7 @@ void board_altmdm_gpio_irq(uint32_t pin, uint32_t polarity,
|
||||
return;
|
||||
break;
|
||||
}
|
||||
|
||||
if (noise_filter == ALTMDM_GPIOINT_NOISE_FILTER_ENABLE)
|
||||
{
|
||||
nf = GPIOINT_NOISE_FILTER_ENABLE;
|
||||
@ -270,6 +273,7 @@ void board_altmdm_gpio_irq(uint32_t pin, uint32_t polarity,
|
||||
{
|
||||
nf = GPIOINT_NOISE_FILTER_DISABLE;
|
||||
}
|
||||
|
||||
if (pin < NUM_OF_PINS)
|
||||
{
|
||||
if (pincfg[pin].input_enable == true)
|
||||
|
@ -81,7 +81,7 @@
|
||||
# endif
|
||||
#endif
|
||||
#else
|
||||
#error "Select LTE SPI 4 or 5"
|
||||
# error "Select LTE SPI 4 or 5"
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
@ -120,7 +120,7 @@ static void spi_pincontrol(int bus, bool on)
|
||||
CXD56_PIN_CONFIGS(PINCONFS_SPI4_GPIO);
|
||||
}
|
||||
break;
|
||||
#endif /* CONFIG_CXD56_SPI4 */
|
||||
#endif /* CONFIG_CXD56_SPI4 */
|
||||
|
||||
#ifdef CONFIG_CXD56_SPI5
|
||||
case 5:
|
||||
@ -133,7 +133,7 @@ static void spi_pincontrol(int bus, bool on)
|
||||
{
|
||||
CXD56_PIN_CONFIGS(PINCONFS_EMMCA_GPIO);
|
||||
}
|
||||
#endif /* CONFIG_CXD56_SPI5_PINMAP_EMMC */
|
||||
#endif /* CONFIG_CXD56_SPI5_PINMAP_EMMC */
|
||||
#ifdef CONFIG_CXD56_SPI5_PINMAP_SDIO
|
||||
if (on)
|
||||
{
|
||||
@ -143,9 +143,9 @@ static void spi_pincontrol(int bus, bool on)
|
||||
{
|
||||
CXD56_PIN_CONFIGS(PINCONFS_SDIOA_GPIO);
|
||||
}
|
||||
#endif /* CONFIG_CXD56_SPI5_PINMAP_SDIO */
|
||||
#endif /* CONFIG_CXD56_SPI5_PINMAP_SDIO */
|
||||
break;
|
||||
#endif /* CONFIG_CXD56_SPI5 */
|
||||
#endif /* CONFIG_CXD56_SPI5 */
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -40,25 +40,25 @@
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
# include <nuttx/modem/altmdm.h>
|
||||
#include <nuttx/modem/altmdm.h>
|
||||
|
||||
# include "altmdm_spi.h"
|
||||
# include "altmdm_sys.h"
|
||||
#include "altmdm_spi.h"
|
||||
#include "altmdm_sys.h"
|
||||
|
||||
# if defined(CONFIG_MODEM_ALTMDM)
|
||||
#if defined(CONFIG_MODEM_ALTMDM)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
struct altmdm_dev_s
|
||||
{
|
||||
FAR char *path; /* Registration path */
|
||||
FAR struct spi_dev_s *spi;
|
||||
struct altmdm_spi_dev_s spidev;
|
||||
struct altmdm_sys_lock_s lock;
|
||||
int poweron;
|
||||
};
|
||||
{
|
||||
FAR char *path; /* Registration path */
|
||||
FAR struct spi_dev_s *spi;
|
||||
struct altmdm_spi_dev_s spidev;
|
||||
struct altmdm_sys_lock_s lock;
|
||||
int poweron;
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
|
@ -68,22 +68,22 @@
|
||||
# define EVENT_MODEM_POWERON_REQ EVENT_BIT(9)
|
||||
# define EVENT_MODEM_POWEROFF_REQ EVENT_BIT(10)
|
||||
# define EVENT_PM_TASK_WAIT (EVENT_D2H_DOWN | EVENT_D2H_UP | \
|
||||
EVENT_MODEM_WAKEUP_REQ | \
|
||||
EVENT_MODEM_RESET_NOTIF | \
|
||||
EVENT_MODEM_POWERON_REQ | \
|
||||
EVENT_MODEM_POWEROFF_REQ | \
|
||||
EVENT_MODEM_SLEEP_REQ | EVENT_EXIT)
|
||||
EVENT_MODEM_WAKEUP_REQ | \
|
||||
EVENT_MODEM_RESET_NOTIF | \
|
||||
EVENT_MODEM_POWERON_REQ | \
|
||||
EVENT_MODEM_POWEROFF_REQ | \
|
||||
EVENT_MODEM_SLEEP_REQ | EVENT_EXIT)
|
||||
# define EVENT_STATE_CHG_WAIT (EVENT_MODEM_SLEPT_NOTIF | \
|
||||
EVENT_MODEM_GOING_TO_SLEEP_NOTIF | \
|
||||
EVENT_MODEM_WAKEUP_NOTIF)
|
||||
EVENT_MODEM_GOING_TO_SLEEP_NOTIF | \
|
||||
EVENT_MODEM_WAKEUP_NOTIF)
|
||||
# define EVENT_MODEM_SLEEP_REQ_DONE_OK EVENT_BIT(0)
|
||||
# define EVENT_MODEM_SLEEP_REQ_DONE_NG EVENT_BIT(1)
|
||||
# define EVENT_MODEM_SLEEP_REQ_DONE (EVENT_MODEM_SLEEP_REQ_DONE_OK | \
|
||||
EVENT_MODEM_SLEEP_REQ_DONE_NG)
|
||||
EVENT_MODEM_SLEEP_REQ_DONE_NG)
|
||||
# define EVENT_MODEM_WAKEUP_REQ_DONE_OK EVENT_BIT(0)
|
||||
# define EVENT_MODEM_WAKEUP_REQ_DONE_NG EVENT_BIT(1)
|
||||
# define EVENT_MODEM_WAKEUP_REQ_DONE (EVENT_MODEM_WAKEUP_REQ_DONE_OK | \
|
||||
EVENT_MODEM_WAKEUP_REQ_DONE_NG)
|
||||
EVENT_MODEM_WAKEUP_REQ_DONE_NG)
|
||||
# define EVENT_MODEM_POWER_ON_DONE EVENT_BIT(0)
|
||||
# define EVENT_MODEM_POWER_OFF_DONE EVENT_BIT(1)
|
||||
|
||||
@ -550,6 +550,7 @@ static int send_modem_sleep_done(FAR struct altmdm_dev_s *priv, int result)
|
||||
{
|
||||
ptn = EVENT_MODEM_SLEEP_REQ_DONE_NG;
|
||||
}
|
||||
|
||||
ret = altmdm_sys_setflag(&g_sleep_done_flag, ptn);
|
||||
if (ret != 0)
|
||||
{
|
||||
@ -850,6 +851,7 @@ static int exe_callback(uint32_t type, uint32_t cb_event)
|
||||
{
|
||||
return -EPERM;
|
||||
}
|
||||
|
||||
lcallback(cb_event);
|
||||
|
||||
return 0;
|
||||
@ -886,6 +888,7 @@ static int wakeup_modem_itself(FAR struct altmdm_dev_s *priv, bool wakeupreq)
|
||||
|
||||
send_modem_wakeup_notif(priv);
|
||||
}
|
||||
|
||||
exe_callback(MODEM_PM_CB_TYPE_NORMAL, MODEM_PM_CB_WAKE);
|
||||
}
|
||||
|
||||
|
@ -232,6 +232,7 @@ static int start_svtimer(FAR struct altmdm_dev_s *priv)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
priv->spidev.sleep_param.sv_timerid = timerid;
|
||||
|
||||
return 0;
|
||||
@ -338,6 +339,7 @@ static int wait_xferready(FAR struct altmdm_dev_s *priv)
|
||||
spidev->is_xferready = true;
|
||||
m_info("ready to xfer\n");
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -398,6 +400,7 @@ static void init_rxbuffer(FAR struct altmdm_dev_s *priv,
|
||||
l_buff->buff_size = unit_size;
|
||||
}
|
||||
}
|
||||
|
||||
*rxbuff = l_buff;
|
||||
}
|
||||
|
||||
@ -418,6 +421,7 @@ static void uninit_rxbuffer(FAR struct altmdm_dev_s *priv,
|
||||
{
|
||||
kmm_free(rxbuff->buff_addr);
|
||||
}
|
||||
|
||||
kmm_free(rxbuff);
|
||||
}
|
||||
}
|
||||
@ -806,6 +810,7 @@ static int do_xferheader(FAR struct altmdm_dev_s *priv,
|
||||
spidev->tx_param.actual_size);
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_sleepreq)
|
||||
{
|
||||
alloc_rxbuffer(priv, &spidev->rx_param.rxbuff, MAX_PKT_SIZE);
|
||||
@ -815,6 +820,7 @@ static int do_xferheader(FAR struct altmdm_dev_s *priv,
|
||||
}
|
||||
set_txheader_possibleofrx(priv, possibleofrx);
|
||||
}
|
||||
|
||||
show_txheader(priv);
|
||||
|
||||
/* Wait for Receiver Ready to receive. */
|
||||
@ -882,6 +888,7 @@ static int do_receivedata(FAR struct altmdm_dev_s *priv)
|
||||
|
||||
ret = do_dmaxfer(priv, (void *)g_tmp_txbuff, rxbuff, dma_xfer_size);
|
||||
}
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
m_err("Rcv Data Failed. ret = %d.\n", ret);
|
||||
@ -919,6 +926,7 @@ static int do_senddata(FAR struct altmdm_dev_s *priv)
|
||||
ret = do_dmaxfer(priv, (void *)spidev->tx_param.buff_addr,
|
||||
(void *)g_tmp_rxbuff, dma_xfer_size);
|
||||
}
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
m_err("ERR:%04d Snd Data Failed. ret = %d.\n", __LINE__, ret);
|
||||
@ -971,6 +979,7 @@ static int do_trxdata(FAR struct altmdm_dev_s *priv)
|
||||
ret = do_dmaxfer(priv, (void *)spidev->tx_param.buff_addr, rxbuff,
|
||||
dma_xfer_size);
|
||||
}
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
m_err("ERR:%04d Trx Data Failed. ret = %d.\n", __LINE__, ret);
|
||||
@ -1010,6 +1019,7 @@ static int do_receivedata_nobuff(FAR struct altmdm_dev_s *priv)
|
||||
ret = do_dmaxfer(priv, (void *)g_tmp_txbuff, (void *)g_tmp_rxbuff,
|
||||
dma_xfer_size);
|
||||
}
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
m_err("ERR:%04d Rcv Data Nobuff Failed. ret = %d.\n", __LINE__, ret);
|
||||
@ -1064,6 +1074,7 @@ static int do_trxdata_norxbuff(FAR struct altmdm_dev_s *priv)
|
||||
ret = do_dmaxfer(priv, (void *)spidev->tx_param.buff_addr,
|
||||
(void *)g_tmp_rxbuff, dma_xfer_size);
|
||||
}
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
m_err("ERR:%04d Trx Data Norxbuff Failed. ret = %d.\n", __LINE__, ret);
|
||||
@ -1105,6 +1116,7 @@ static int do_receivesleepdata(FAR struct altmdm_dev_s *priv, FAR int *resp)
|
||||
ret = do_dmaxfer(priv, (void *)g_tmp_txbuff, (void *)g_tmp_rxbuff,
|
||||
dma_xfer_size);
|
||||
}
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
m_err("ERR:%04d Rcv Sleep Resp Data Failed. ret = %d.\n",
|
||||
@ -1157,6 +1169,7 @@ static int do_receivereset(FAR struct altmdm_dev_s *priv)
|
||||
ret = do_dmaxfer(priv, (void *)g_tmp_txbuff, (void *)g_tmp_rxbuff,
|
||||
dma_xfer_size);
|
||||
}
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
m_err("ERR:%04d Rcv Reset Failed. ret = %d.\n", __LINE__, ret);
|
||||
@ -1174,10 +1187,12 @@ static int do_receivereset(FAR struct altmdm_dev_s *priv)
|
||||
altmdm_pm_set_bootstatus(priv,
|
||||
MODEM_PM_ERR_RESET_BOOTSTAT_BOOTING);
|
||||
break;
|
||||
|
||||
case RESET_BOOTSTAT_UPDATING:
|
||||
altmdm_pm_set_bootstatus(priv,
|
||||
MODEM_PM_ERR_RESET_BOOTSTAT_UPDATING);
|
||||
break;
|
||||
|
||||
default:
|
||||
m_err
|
||||
("ERR:%04d Invalid payload of reset packet. %02x,%02x,%02x,%02x\n",
|
||||
@ -1241,6 +1256,7 @@ static int do_trxreset(FAR struct altmdm_dev_s *priv)
|
||||
ret = do_dmaxfer(priv, (void *)spidev->tx_param.buff_addr,
|
||||
(void *)g_tmp_rxbuff, dma_xfer_size);
|
||||
}
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
m_err("ERR:%04d Trx Reset Failed. ret = %d.\n", __LINE__, ret);
|
||||
@ -1283,6 +1299,7 @@ static int do_xfersleep(FAR struct altmdm_dev_s *priv, uint32_t is_rcvrready)
|
||||
ret = resp;
|
||||
}
|
||||
}
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
ret = SLEEP_NG;
|
||||
@ -1296,6 +1313,7 @@ static int do_xfersleep(FAR struct altmdm_dev_s *priv, uint32_t is_rcvrready)
|
||||
m_info("ready to xfer\n");
|
||||
notify_xferready(priv);
|
||||
}
|
||||
|
||||
altmdm_pm_notify_reset(priv);
|
||||
}
|
||||
|
||||
@ -1328,6 +1346,7 @@ static uint32_t decide_xfermode(FAR struct altmdm_dev_s *priv,
|
||||
{
|
||||
mode = MODE_TRXHEADERFAILRXREQ;
|
||||
}
|
||||
|
||||
if (spidev->rx_param.rxbuff != NULL)
|
||||
{
|
||||
free_rxbuffer(priv, spidev->rx_param.rxbuff);
|
||||
@ -1494,6 +1513,7 @@ static void done_xfer(FAR struct altmdm_dev_s *priv, uint32_t xfer_mode,
|
||||
{
|
||||
spidev->tx_param.result = (ret < 0) ? ret : TRANS_OK;
|
||||
}
|
||||
|
||||
altmdm_sys_setflag(&spidev->tx_param.done_flag, EVENT_TX_DONE);
|
||||
break;
|
||||
|
||||
@ -1507,6 +1527,7 @@ static void done_xfer(FAR struct altmdm_dev_s *priv, uint32_t xfer_mode,
|
||||
{
|
||||
spidev->tx_param.result = (ret < 0) ? ret : TRANS_OK;
|
||||
}
|
||||
|
||||
altmdm_sys_setflag(&spidev->tx_param.done_flag, EVENT_TX_DONE);
|
||||
|
||||
if (ret < 0)
|
||||
@ -1531,6 +1552,7 @@ static void done_xfer(FAR struct altmdm_dev_s *priv, uint32_t xfer_mode,
|
||||
{
|
||||
spidev->tx_param.result = (ret < 0) ? ret : TRANS_OK;
|
||||
}
|
||||
|
||||
altmdm_sys_setflag(&spidev->tx_param.done_flag, EVENT_TX_DONE);
|
||||
break;
|
||||
|
||||
@ -1546,6 +1568,7 @@ static void done_xfer(FAR struct altmdm_dev_s *priv, uint32_t xfer_mode,
|
||||
m_info("ready to xfer\n");
|
||||
notify_xferready(priv);
|
||||
}
|
||||
|
||||
altmdm_pm_notify_reset(priv);
|
||||
break;
|
||||
|
||||
@ -1556,6 +1579,7 @@ static void done_xfer(FAR struct altmdm_dev_s *priv, uint32_t xfer_mode,
|
||||
m_info("ready to xfer\n");
|
||||
notify_xferready(priv);
|
||||
}
|
||||
|
||||
altmdm_pm_notify_reset(priv);
|
||||
if (spidev->tx_param.is_bufful)
|
||||
{
|
||||
@ -1566,6 +1590,7 @@ static void done_xfer(FAR struct altmdm_dev_s *priv, uint32_t xfer_mode,
|
||||
{
|
||||
spidev->tx_param.result = (ret < 0) ? ret : TRANS_OK;
|
||||
}
|
||||
|
||||
altmdm_sys_setflag(&spidev->tx_param.done_flag, EVENT_TX_DONE);
|
||||
break;
|
||||
|
||||
@ -1917,6 +1942,7 @@ int altmdm_spi_uninit(FAR struct altmdm_dev_s *priv)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
usleep(10);
|
||||
}
|
||||
|
||||
@ -1933,6 +1959,7 @@ int altmdm_spi_uninit(FAR struct altmdm_dev_s *priv)
|
||||
free_rxbuffer(priv, priv->spidev.rx_param.rxbuff);
|
||||
priv->spidev.rx_param.rxbuff = NULL;
|
||||
}
|
||||
|
||||
destroy_rxbufffifo(priv);
|
||||
|
||||
/* Uninitalize modem power management driver */
|
||||
@ -2188,6 +2215,7 @@ int altmdm_spi_sleepmodem(FAR struct altmdm_dev_s *priv)
|
||||
{
|
||||
spidev->sleep_param.requested = true;
|
||||
}
|
||||
|
||||
altmdm_sys_unlock(&spidev->sleep_param.lock);
|
||||
|
||||
if (sleep_requested)
|
||||
@ -2213,6 +2241,7 @@ int altmdm_spi_sleepmodem(FAR struct altmdm_dev_s *priv)
|
||||
m_info("%s: sleep result: %d.\n", __func__,
|
||||
spidev->sleep_param.result);
|
||||
}
|
||||
|
||||
spidev->sleep_param.requested = false;
|
||||
}
|
||||
|
||||
@ -2278,4 +2307,4 @@ int altmdm_spi_clearreceiverready(FAR struct altmdm_dev_s *priv)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CONFIG_MODEM_ALTMDM */
|
||||
#endif /* CONFIG_MODEM_ALTMDM */
|
||||
|
@ -58,125 +58,125 @@
|
||||
/* This structure describes the transfer header. */
|
||||
|
||||
struct altmdm_spi_xferhdr_s
|
||||
{
|
||||
uint8_t header[4]; /* Transfer header. */
|
||||
};
|
||||
{
|
||||
uint8_t header[4]; /* Transfer header. */
|
||||
};
|
||||
|
||||
/* This structure describes the buffer for data receive. */
|
||||
|
||||
struct altmdm_spi_rxbuff_s
|
||||
{
|
||||
char *buff_addr; /* Receive buffer address. */
|
||||
uint32_t buff_size; /* Size of this buffer. */
|
||||
uint32_t rx_size; /* Received data size. */
|
||||
struct altmdm_spi_rxbuff_s *next; /* Link for next buffer. */
|
||||
};
|
||||
{
|
||||
FAR char *buff_addr; /* Receive buffer address. */
|
||||
uint32_t buff_size; /* Size of this buffer. */
|
||||
uint32_t rx_size; /* Received data size. */
|
||||
FAR struct altmdm_spi_rxbuff_s *next; /* Link for next buffer. */
|
||||
};
|
||||
|
||||
/* This structure describes the fifo for received buffer. */
|
||||
|
||||
struct altmdm_spi_rxbufffifo_s
|
||||
{
|
||||
struct altmdm_spi_rxbuff_s *head; /* Point to the head of fifo */
|
||||
struct altmdm_spi_rxbuff_s *tail; /* Point to the tail of fifo */
|
||||
struct altmdm_sys_csem_s csem; /* It is used for notification when
|
||||
{
|
||||
FAR struct altmdm_spi_rxbuff_s *head; /* Point to the head of fifo */
|
||||
FAR struct altmdm_spi_rxbuff_s *tail; /* Point to the tail of fifo */
|
||||
struct altmdm_sys_csem_s csem; /* It is used for notification when
|
||||
* data is put in fifo.
|
||||
*/
|
||||
};
|
||||
};
|
||||
|
||||
/* This structure describes the parameters for receive buffer information. */
|
||||
|
||||
struct altmdm_spi_rxbuffinfo_s
|
||||
{
|
||||
struct altmdm_spi_rxbuff_s *free_buff; /* Free receive buffer address. */
|
||||
struct altmdm_spi_rxbufffifo_s fifo; /* Receive buffer fifo. */
|
||||
};
|
||||
{
|
||||
FAR struct altmdm_spi_rxbuff_s *free_buff; /* Free receive buffer address. */
|
||||
struct altmdm_spi_rxbufffifo_s fifo; /* Receive buffer fifo. */
|
||||
};
|
||||
|
||||
/* This structure describes the parameters for send data. */
|
||||
|
||||
struct altmdm_spi_tx_s
|
||||
{
|
||||
struct altmdm_sys_lock_s lock; /* Lock on accessing the following
|
||||
* parameters.
|
||||
*/
|
||||
struct altmdm_sys_flag_s done_flag; /* Notify that tx request has been
|
||||
* completed.
|
||||
*/
|
||||
struct altmdm_spi_xferhdr_s header; /* Tx header. */
|
||||
char *buff_addr; /* Buffer address for data transmission
|
||||
* speceified by the user.
|
||||
*/
|
||||
int32_t actual_size; /* Actual data size. */
|
||||
int32_t total_size; /* Data size of 4byte alignment. */
|
||||
int32_t result; /* Result of transfer. */
|
||||
int32_t is_bufful; /* Indicates the slave is buffer full status. */
|
||||
};
|
||||
{
|
||||
struct altmdm_sys_lock_s lock; /* Lock on accessing the following
|
||||
* parameters.
|
||||
*/
|
||||
struct altmdm_sys_flag_s done_flag; /* Notify that tx request has been
|
||||
* completed.
|
||||
*/
|
||||
struct altmdm_spi_xferhdr_s header; /* Tx header. */
|
||||
FAR char *buff_addr; /* Buffer address for data transmission
|
||||
* specified by the user.
|
||||
*/
|
||||
int32_t actual_size; /* Actual data size. */
|
||||
int32_t total_size; /* Data size of 4byte alignment. */
|
||||
int32_t result; /* Result of transfer. */
|
||||
int32_t is_bufful; /* Indicates the slave is buffer full status. */
|
||||
};
|
||||
|
||||
/* This structure describes the parameters for receive data. */
|
||||
|
||||
struct altmdm_spi_rx_s
|
||||
{
|
||||
struct altmdm_sys_lock_s lock; /* Lock on accessing the following
|
||||
* parameters.
|
||||
*/
|
||||
struct altmdm_spi_xferhdr_s header; /* Rx header. */
|
||||
int8_t status_info; /* Header status information */
|
||||
int32_t actual_size; /* Actual data size */
|
||||
int32_t total_size; /* Data size of 4byte alignment. */
|
||||
struct altmdm_spi_rxbuff_s *rxbuff; /* Current recieve beffer. */
|
||||
bool rxabort; /* Indicates whether the rx process is aborted. */
|
||||
};
|
||||
{
|
||||
struct altmdm_sys_lock_s lock; /* Lock on accessing the following
|
||||
* parameters.
|
||||
*/
|
||||
struct altmdm_spi_xferhdr_s header; /* Rx header. */
|
||||
int8_t status_info; /* Header status information */
|
||||
int32_t actual_size; /* Actual data size */
|
||||
int32_t total_size; /* Data size of 4byte alignment. */
|
||||
FAR struct altmdm_spi_rxbuff_s *rxbuff; /* Current receive buffer. */
|
||||
bool rxabort; /* Indicates whether the rx process is aborted. */
|
||||
};
|
||||
|
||||
/* This structure describes the parameters for sleep modem. */
|
||||
|
||||
struct altmdm_spi_sleepmodem_s
|
||||
{
|
||||
struct altmdm_sys_lock_s lock; /* Lock on accessing the following
|
||||
* parameters.
|
||||
*/
|
||||
{
|
||||
struct altmdm_sys_lock_s lock; /* Lock on accessing the following
|
||||
* parameters.
|
||||
*/
|
||||
|
||||
struct altmdm_sys_flag_s done_flag; /* Notify that sleep request has been
|
||||
* completed.
|
||||
*/
|
||||
int32_t result; /* Result of sleep request. */
|
||||
bool requested; /* Indicates that sleep request has been requested. */
|
||||
timer_t sv_timerid; /* Superviser timer. */
|
||||
};
|
||||
struct altmdm_sys_flag_s done_flag; /* Notify that sleep request has been
|
||||
* completed.
|
||||
*/
|
||||
int32_t result; /* Result of sleep request. */
|
||||
bool requested; /* Indicates that sleep request has been requested. */
|
||||
timer_t sv_timerid; /* Supervisor timer. */
|
||||
};
|
||||
|
||||
/* This structure describes the resource of the ALTMDM spi driver */
|
||||
|
||||
struct altmdm_spi_dev_s
|
||||
{
|
||||
/* Common fields */
|
||||
{
|
||||
/* Common fields */
|
||||
|
||||
bool is_not_run; /* Indicates xfer task is not run. */
|
||||
int32_t task_id; /* xfer task ID. */
|
||||
bool is_xferready; /* Indicates whether the modem is ready to xfer. */
|
||||
struct altmdm_sys_flag_s xferready_flag; /* Used for wating ready to
|
||||
* xfer.
|
||||
*/
|
||||
struct altmdm_sys_flag_s xfer_flag; /* Used for event handling of xfer
|
||||
* task.
|
||||
*/
|
||||
struct altmdm_sys_flag_s dma_done_flag; /* Notify that DMA transfer has
|
||||
* been completed.
|
||||
*/
|
||||
bool is_not_run; /* Indicates xfer task is not run. */
|
||||
int32_t task_id; /* xfer task ID. */
|
||||
bool is_xferready; /* Indicates whether the modem is ready to xfer. */
|
||||
struct altmdm_sys_flag_s xferready_flag; /* Used for waiting ready to
|
||||
* xfer.
|
||||
*/
|
||||
struct altmdm_sys_flag_s xfer_flag; /* Used for event handling of xfer
|
||||
* task.
|
||||
*/
|
||||
struct altmdm_sys_flag_s dma_done_flag; /* Notify that DMA transfer has
|
||||
* been completed.
|
||||
*/
|
||||
|
||||
/* Parameter for recieve buffer */
|
||||
/* Parameter for receive buffer */
|
||||
|
||||
struct altmdm_spi_rxbuffinfo_s rxbuffinfo;
|
||||
struct altmdm_spi_rxbuffinfo_s rxbuffinfo;
|
||||
|
||||
/* Parameter for send data */
|
||||
/* Parameter for send data */
|
||||
|
||||
struct altmdm_spi_tx_s tx_param;
|
||||
struct altmdm_spi_tx_s tx_param;
|
||||
|
||||
/* Parameter for recieve data */
|
||||
/* Parameter for receive data */
|
||||
|
||||
struct altmdm_spi_rx_s rx_param;
|
||||
struct altmdm_spi_rx_s rx_param;
|
||||
|
||||
/* Parameters for sleep modem */
|
||||
/* Parameters for sleep modem */
|
||||
|
||||
struct altmdm_spi_sleepmodem_s sleep_param;
|
||||
};
|
||||
struct altmdm_spi_sleepmodem_s sleep_param;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif /* __DRIVERS_MODEM_ALTMDM_ALTMDM_SPI_H */
|
||||
|
@ -51,7 +51,7 @@
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
# define MY_TIMER_SIGNAL SIGUSR1
|
||||
#define MY_TIMER_SIGNAL SIGUSR1
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
@ -68,9 +68,9 @@
|
||||
int altmdm_sys_initlock(FAR struct altmdm_sys_lock_s *handle)
|
||||
{
|
||||
int ret;
|
||||
# ifdef CONFIG_MODEM_ALTMDM_DEBUG
|
||||
#ifdef CONFIG_MODEM_ALTMDM_DEBUG
|
||||
int l_errno;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Check argument. */
|
||||
|
||||
@ -81,13 +81,13 @@ int altmdm_sys_initlock(FAR struct altmdm_sys_lock_s *handle)
|
||||
|
||||
ret = sem_init(&handle->sem, 0, 1);
|
||||
|
||||
# ifdef CONFIG_MODEM_ALTMDM_DEBUG
|
||||
#ifdef CONFIG_MODEM_ALTMDM_DEBUG
|
||||
if (ret == ERROR)
|
||||
{
|
||||
l_errno = errno;
|
||||
m_err("sem_init() failed:%d\n", l_errno);
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -103,9 +103,9 @@ int altmdm_sys_initlock(FAR struct altmdm_sys_lock_s *handle)
|
||||
int altmdm_sys_deletelock(FAR struct altmdm_sys_lock_s *handle)
|
||||
{
|
||||
int ret;
|
||||
# ifdef CONFIG_MODEM_ALTMDM_DEBUG
|
||||
#ifdef CONFIG_MODEM_ALTMDM_DEBUG
|
||||
int l_errno;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Check argument. */
|
||||
|
||||
@ -116,13 +116,13 @@ int altmdm_sys_deletelock(FAR struct altmdm_sys_lock_s *handle)
|
||||
|
||||
ret = sem_destroy(&handle->sem);
|
||||
|
||||
# ifdef CONFIG_MODEM_ALTMDM_DEBUG
|
||||
#ifdef CONFIG_MODEM_ALTMDM_DEBUG
|
||||
if (ret == ERROR)
|
||||
{
|
||||
l_errno = errno;
|
||||
m_err("sem_destroy() failed:%d\n", l_errno);
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -159,6 +159,7 @@ int altmdm_sys_lock(FAR struct altmdm_sys_lock_s *handle)
|
||||
}
|
||||
m_err("sem_wait() failed:%d\n", l_errno);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@ -176,9 +177,9 @@ int altmdm_sys_lock(FAR struct altmdm_sys_lock_s *handle)
|
||||
int altmdm_sys_unlock(FAR struct altmdm_sys_lock_s *handle)
|
||||
{
|
||||
int ret;
|
||||
# ifdef CONFIG_MODEM_ALTMDM_DEBUG
|
||||
#ifdef CONFIG_MODEM_ALTMDM_DEBUG
|
||||
int l_errno;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Check argument. */
|
||||
|
||||
@ -189,13 +190,13 @@ int altmdm_sys_unlock(FAR struct altmdm_sys_lock_s *handle)
|
||||
|
||||
ret = sem_post(&handle->sem);
|
||||
|
||||
# ifdef CONFIG_MODEM_ALTMDM_DEBUG
|
||||
#ifdef CONFIG_MODEM_ALTMDM_DEBUG
|
||||
if (ret == ERROR)
|
||||
{
|
||||
l_errno = errno;
|
||||
m_err("sem_post() failed:%d\n", l_errno);
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -211,9 +212,9 @@ int altmdm_sys_unlock(FAR struct altmdm_sys_lock_s *handle)
|
||||
int altmdm_sys_initcsem(FAR struct altmdm_sys_csem_s *handle)
|
||||
{
|
||||
int ret;
|
||||
# ifdef CONFIG_MODEM_ALTMDM_DEBUG
|
||||
#ifdef CONFIG_MODEM_ALTMDM_DEBUG
|
||||
int l_errno;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Check argument. */
|
||||
|
||||
@ -224,13 +225,13 @@ int altmdm_sys_initcsem(FAR struct altmdm_sys_csem_s *handle)
|
||||
|
||||
ret = sem_init(&handle->sem, 0, 0);
|
||||
|
||||
# ifdef CONFIG_MODEM_ALTMDM_DEBUG
|
||||
#ifdef CONFIG_MODEM_ALTMDM_DEBUG
|
||||
if (ret == ERROR)
|
||||
{
|
||||
l_errno = errno;
|
||||
m_err("sem_init() failed:%d\n", l_errno);
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -246,9 +247,9 @@ int altmdm_sys_initcsem(FAR struct altmdm_sys_csem_s *handle)
|
||||
int altmdm_sys_deletecsem(FAR struct altmdm_sys_csem_s *handle)
|
||||
{
|
||||
int ret;
|
||||
# ifdef CONFIG_MODEM_ALTMDM_DEBUG
|
||||
#ifdef CONFIG_MODEM_ALTMDM_DEBUG
|
||||
int l_errno;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Check argument. */
|
||||
|
||||
@ -259,13 +260,13 @@ int altmdm_sys_deletecsem(FAR struct altmdm_sys_csem_s *handle)
|
||||
|
||||
ret = sem_destroy(&handle->sem);
|
||||
|
||||
# ifdef CONFIG_MODEM_ALTMDM_DEBUG
|
||||
#ifdef CONFIG_MODEM_ALTMDM_DEBUG
|
||||
if (ret == ERROR)
|
||||
{
|
||||
l_errno = errno;
|
||||
m_err("sem_destroy() failed:%d\n", l_errno);
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -300,8 +301,10 @@ int altmdm_sys_waitcsem(FAR struct altmdm_sys_csem_s *handle)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
m_err("sem_wait() failed:%d\n", l_errno);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@ -319,9 +322,9 @@ int altmdm_sys_waitcsem(FAR struct altmdm_sys_csem_s *handle)
|
||||
int altmdm_sys_postcsem(FAR struct altmdm_sys_csem_s *handle)
|
||||
{
|
||||
int ret;
|
||||
# ifdef CONFIG_MODEM_ALTMDM_DEBUG
|
||||
#ifdef CONFIG_MODEM_ALTMDM_DEBUG
|
||||
int l_errno;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Check argument. */
|
||||
|
||||
@ -332,13 +335,13 @@ int altmdm_sys_postcsem(FAR struct altmdm_sys_csem_s *handle)
|
||||
|
||||
ret = sem_post(&handle->sem);
|
||||
|
||||
# ifdef CONFIG_MODEM_ALTMDM_DEBUG
|
||||
#ifdef CONFIG_MODEM_ALTMDM_DEBUG
|
||||
if (ret == ERROR)
|
||||
{
|
||||
l_errno = errno;
|
||||
m_err("sem_post() failed:%d\n", l_errno);
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -355,9 +358,9 @@ int altmdm_sys_getcsemvalue(FAR struct altmdm_sys_csem_s *handle,
|
||||
FAR int *value)
|
||||
{
|
||||
int ret;
|
||||
# ifdef CONFIG_MODEM_ALTMDM_DEBUG
|
||||
#ifdef CONFIG_MODEM_ALTMDM_DEBUG
|
||||
int l_errno;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Check argument. */
|
||||
|
||||
@ -368,13 +371,13 @@ int altmdm_sys_getcsemvalue(FAR struct altmdm_sys_csem_s *handle,
|
||||
|
||||
ret = sem_getvalue(&handle->sem, value);
|
||||
|
||||
# ifdef CONFIG_MODEM_ALTMDM_DEBUG
|
||||
#ifdef CONFIG_MODEM_ALTMDM_DEBUG
|
||||
if (ret == ERROR)
|
||||
{
|
||||
l_errno = errno;
|
||||
m_err("sem_getvalue() failed:%d\n", l_errno);
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -390,9 +393,9 @@ int altmdm_sys_getcsemvalue(FAR struct altmdm_sys_csem_s *handle,
|
||||
int altmdm_sys_initflag(FAR struct altmdm_sys_flag_s *handle)
|
||||
{
|
||||
int ret;
|
||||
# ifdef CONFIG_MODEM_ALTMDM_DEBUG
|
||||
#ifdef CONFIG_MODEM_ALTMDM_DEBUG
|
||||
int l_errno;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Check argument. */
|
||||
|
||||
@ -404,13 +407,13 @@ int altmdm_sys_initflag(FAR struct altmdm_sys_flag_s *handle)
|
||||
handle->flag = 0;
|
||||
ret = sem_init(&handle->sem, 0, 0);
|
||||
|
||||
# ifdef CONFIG_MODEM_ALTMDM_DEBUG
|
||||
#ifdef CONFIG_MODEM_ALTMDM_DEBUG
|
||||
if (ret == ERROR)
|
||||
{
|
||||
l_errno = errno;
|
||||
m_err("sem_init() failed:%d\n", l_errno);
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -426,9 +429,9 @@ int altmdm_sys_initflag(FAR struct altmdm_sys_flag_s *handle)
|
||||
int altmdm_sys_deleteflag(FAR struct altmdm_sys_flag_s *handle)
|
||||
{
|
||||
int ret;
|
||||
# ifdef CONFIG_MODEM_ALTMDM_DEBUG
|
||||
#ifdef CONFIG_MODEM_ALTMDM_DEBUG
|
||||
int l_errno;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Check argument. */
|
||||
|
||||
@ -439,13 +442,13 @@ int altmdm_sys_deleteflag(FAR struct altmdm_sys_flag_s *handle)
|
||||
|
||||
ret = sem_destroy(&handle->sem);
|
||||
|
||||
# ifdef CONFIG_MODEM_ALTMDM_DEBUG
|
||||
#ifdef CONFIG_MODEM_ALTMDM_DEBUG
|
||||
if (ret == ERROR)
|
||||
{
|
||||
l_errno = errno;
|
||||
m_err("sem_destroy() failed:%d\n", l_errno);
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -484,6 +487,7 @@ int altmdm_sys_waitflag(FAR struct altmdm_sys_flag_s *handle,
|
||||
case ALTMDM_SYS_FLAG_WMODEOR:
|
||||
case ALTMDM_SYS_FLAG_WMODEAND:
|
||||
break;
|
||||
|
||||
default:
|
||||
m_err("invalid wait mode:%d\n", wait_mode);
|
||||
return ERROR;
|
||||
@ -540,11 +544,13 @@ int altmdm_sys_waitflag(FAR struct altmdm_sys_flag_s *handle,
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
leave_critical_section(flags);
|
||||
|
||||
ret = OK;
|
||||
break;
|
||||
}
|
||||
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
else
|
||||
@ -569,11 +575,13 @@ int altmdm_sys_waitflag(FAR struct altmdm_sys_flag_s *handle,
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
leave_critical_section(flags);
|
||||
|
||||
ret = OK;
|
||||
break;
|
||||
}
|
||||
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
||||
@ -589,6 +597,7 @@ int altmdm_sys_waitflag(FAR struct altmdm_sys_flag_s *handle,
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
m_err("sem_timedwait() failed:%d\n", l_errno);
|
||||
break;
|
||||
}
|
||||
@ -605,6 +614,7 @@ int altmdm_sys_waitflag(FAR struct altmdm_sys_flag_s *handle,
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
m_err("sem_wait() failed:%d\n", l_errno);
|
||||
break;
|
||||
}
|
||||
|
@ -58,25 +58,25 @@
|
||||
****************************************************************************/
|
||||
|
||||
struct altmdm_sys_lock_s
|
||||
{
|
||||
sem_t sem;
|
||||
};
|
||||
{
|
||||
sem_t sem;
|
||||
};
|
||||
|
||||
struct altmdm_sys_csem_s
|
||||
{
|
||||
sem_t sem;
|
||||
};
|
||||
{
|
||||
sem_t sem;
|
||||
};
|
||||
|
||||
struct altmdm_sys_flag_s
|
||||
{
|
||||
sem_t sem;
|
||||
uint32_t flag;
|
||||
};
|
||||
{
|
||||
sem_t sem;
|
||||
uint32_t flag;
|
||||
};
|
||||
|
||||
struct altmdm_sys_flagstate_s
|
||||
{
|
||||
uint32_t flag_pattern;
|
||||
};
|
||||
{
|
||||
uint32_t flag_pattern;
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
|
Loading…
x
Reference in New Issue
Block a user