Skip to content

Commit

Permalink
Merge pull request #41 from SPRESENSE/release-v1.4.1
Browse files Browse the repository at this point in the history
Merge release-v1.4.1 into master for v1.4.1 release
  • Loading branch information
SPRESENSE committed Oct 4, 2019
2 parents aa7f53a + 3bfd09a commit ee8f2dd
Show file tree
Hide file tree
Showing 13 changed files with 1,224 additions and 161 deletions.
717 changes: 713 additions & 4 deletions LICENSE

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions sdk/modules/include/gpsutils/cxd56_gnss_nmea.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ int NMEA_RegistOutputFunc(FAR const NMEA_OUTPUT_CB *func);
* ___
* ### Mask description
*
* - Defult value 0x000000ef.
* - Default value 0x000000ef.
* - Bits not listed below are reserved.
*
* |bit |sentence|
Expand All @@ -127,7 +127,7 @@ int NMEA_RegistOutputFunc(FAR const NMEA_OUTPUT_CB *func);
* |bit5|RMC|
* |bit6|VTG|
* |bit7|ZDA|
* |bit22|QZQSM|
* |bit14|QZQSM|
*
*/

Expand Down Expand Up @@ -167,7 +167,7 @@ uint16_t NMEA_DcReport_Output(const struct cxd56_gnss_dcreport_data_s* dcrdat);
uint16_t NMEA_OutputSpectrum(FAR NMEA_SPECTRUM_DATA *spectrumdat);

/*
* Extract raw data from postion data
* Extract raw data from position data
* @param[in] pposdat : Position data output from GNSS
* @param[out] rawdat : Extracted raw data
* @retval 0 : success
Expand Down
132 changes: 40 additions & 92 deletions sdk/modules/lte/altcom/api/lte/lte_power.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@

#include <stdio.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <nuttx/modem/altmdm.h>

#include "lte/lte_api.h"
#include "wrkrid.h"
Expand All @@ -60,15 +57,14 @@
* Pre-processor Definitions
****************************************************************************/

#ifdef CONFIG_MODEM_DEVICE_PATH
# define DEV_PATH CONFIG_MODEM_DEVICE_PATH
#else
# warning "CONFIG_MODEM_DEVICE_PATH not defined"
# define DEV_PATH "/dev/altmdm"
#endif

#define POWERON_DATA_LEN (0)

/****************************************************************************
* Private Data
****************************************************************************/

static FAR struct hal_if_s *g_halif = NULL;

/****************************************************************************
* Private Functions
****************************************************************************/
Expand All @@ -92,8 +88,7 @@ static int32_t poweron_status_chg_cb(int32_t new_stat, int32_t old_stat)
{
if (new_stat <= ALTCOM_STATUS_INITIALIZED)
{
DBGIF_LOG2_INFO("poweron_status_chg_cb(%d -> %d)\n",
old_stat, new_stat);
DBGIF_LOG2_INFO("poweron_status_chg_cb(%d -> %d)\n", old_stat, new_stat);
altcomcallbacks_unreg_cb(APICMDID_POWER_ON);

return ALTCOM_STATUS_REG_CLR;
Expand Down Expand Up @@ -187,84 +182,6 @@ static void restart_callback(uint32_t state)
DBGIF_ASSERT(0 == ret, "Failed to job to worker\n");
}

/****************************************************************************
* Name: modem_powerctrl
*
* Description:
* Power on or off the modem.
*
* Input Parameters:
* on "power on" or "power off".
*
* Returned Value:
* On success, 0 is returned.
* On failure, negative value is returned.
*
****************************************************************************/

int32_t modem_powerctrl(bool on)
{
int32_t ret;
int fd;
int l_errno;
int req;

/* Open the device */

fd = open(DEV_PATH, O_WRONLY);
if (0 > fd)
{
DBGIF_LOG2_ERROR("Device %s open failure. %d\n", DEV_PATH, fd);
ret = fd;
}
else
{

if (on)
{
ret = ioctl(fd, MODEM_IOC_PM_ERR_REGISTERCB,
(unsigned long)restart_callback);
if (0 > ret)
{
/* Store errno */

l_errno = errno;
ret = -l_errno;

DBGIF_LOG2_ERROR("Failed to ioctl(0x%08x). %d\n", MODEM_IOC_PM_ERR_REGISTERCB, l_errno);

}
}

if (on)
{
req = MODEM_IOC_POWERON;
}
else
{
req = MODEM_IOC_POWEROFF;
}

/* Power on the modem */

ret = ioctl(fd, req, 0);
if (0 > ret)
{
/* Store errno */

l_errno = errno;
ret = -l_errno;

DBGIF_LOG2_ERROR("Failed to ioctl(0x%08x). %d\n", req, l_errno);

}

close(fd);
}

return ret;
}

/****************************************************************************
* Name: poweron_job
*
Expand Down Expand Up @@ -327,9 +244,15 @@ int32_t lte_power_on(void)
switch (state)
{
case ALTCOM_STATUS_INITIALIZED:
if (!g_halif)
{
ret = -EFAULT;
break;
}

/* Power on the modem */

ret = modem_powerctrl(true);
ret = g_halif->poweron_modem(g_halif, restart_callback);
if (ret == 0)
{
altcom_set_status(ALTCOM_STATUS_RESTART_ONGOING);
Expand Down Expand Up @@ -380,9 +303,15 @@ int32_t lte_power_off(void)
break;
case ALTCOM_STATUS_RESTART_ONGOING:
case ALTCOM_STATUS_POWER_ON:
if (!g_halif)
{
ret = -EFAULT;
break;
}

/* Power off the modem */

ret = modem_powerctrl(false);
ret = g_halif->poweroff_modem(g_halif);
if (ret == 0)
{
altcom_set_status(ALTCOM_STATUS_INITIALIZED);
Expand Down Expand Up @@ -425,3 +354,22 @@ enum evthdlrc_e apicmdhdlr_power(FAR uint8_t *evt, uint32_t evlen)
return apicmdhdlrbs_do_runjob(evt,
APICMDID_CONVERT_RES(APICMDID_POWER_ON), poweron_job);
}

/****************************************************************************
* Name: lte_power_set_hal_instance
*
* Description:
* Set the HAL instance.
*
* Input Parameters:
* halif HAL instance.
*
* Returned Value:
* None
*
****************************************************************************/

void lte_power_set_hal_instance(FAR struct hal_if_s *halif)
{
g_halif = halif;
}
14 changes: 6 additions & 8 deletions sdk/modules/lte/altcom/api/ltebuilder.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
#include "apicmdhdlr_imsi.h"
#include "apicmdhdlr_operator.h"
#include "apicmdhdlr_phoneno.h"
#include "apicmdhdlr_power.h"
#include "lte_power.h"
#include "apicmdhdlr_repcellinfo.h"
#include "apicmdhdlr_repevt.h"
#include "apicmdhdlr_repquality.h"
Expand Down Expand Up @@ -102,9 +102,6 @@

#define BLOCKSETLIST_NUM (sizeof(g_blk_settings) / sizeof(g_blk_settings[0]))

#define APICMD_TRANSACTION_SIZE_MAX \
(sizeof(struct apicmd_cmdhdr_s) + APICMD_PAYLOAD_SIZE_MAX)

/****************************************************************************
* Private Function Prototypes
****************************************************************************/
Expand Down Expand Up @@ -139,10 +136,7 @@ static struct buffpool_blockset_s g_blk_settings[] =
},
#endif
{
APICMDGW_RECVBUFF_SIZE_MAX, 1
},
{
APICMD_TRANSACTION_SIZE_MAX, 1
APICMDGW_RECVBUFF_SIZE_MAX, 2
}
};

Expand Down Expand Up @@ -447,6 +441,8 @@ static int32_t halspi_initialize(void)
ret = -1;
}

lte_power_set_hal_instance(g_halif);

return ret;
}

Expand All @@ -469,6 +465,8 @@ static int32_t halspi_uninitialize(void)
{
int32_t ret;

lte_power_set_hal_instance(NULL);

ret = hal_altmdm_spi_delete(g_halif);
if (0 > ret)
{
Expand Down
Loading

0 comments on commit ee8f2dd

Please sign in to comment.