Merged in alinjerpelea/nuttx (pull request #948)

arch: arm: cxd56xx: add GNSS device and UART0

* arch: arm: cxd56xx: add GNSS device

    Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

* arch: arm: cxd56xx: add Geofence Support

    Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

* arch: arm: cxd56xx: add UART0 iterface

    UART0 is an interface with hardware flow control in the application subsystem.

    Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

* configs: spresense: path correction

    In the initial commit the path reference was not updated

    Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

Approved-by: Gregory Nutt <gnutt@nuttx.org>
This commit is contained in:
Alin Jerpelea 2019-07-12 11:29:22 +00:00 committed by Gregory Nutt
parent 1a1321df6b
commit 5867fdc0e1
15 changed files with 6952 additions and 1 deletions

View File

@ -0,0 +1,233 @@
/****************************************************************************
* arch/arm/include/cxd56xx/geofence.h
*
* Copyright 2018 Sony Semiconductor Solutions Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name of Sony Semiconductor Solutions Corporation nor
* the names of its contributors may be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
#ifndef __ARCH_ARM_INCLUDE_CXD56XX_GEOFENCE_H
#define __ARCH_ARM_INCLUDE_CXD56XX_GEOFENCE_H
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/* Start geofence monitoring.
* This command is used to start the geofence monitoring.
*
* param arg
* Parameter is Unnecessary. Set Zero.
*/
#define CXD56_GEOFENCE_IOCTL_START 1
/* Stop geofence monitoring.
* This command is used to stop the geofence monitoring.
*
* param arg
* Parameter is Unnecessary. Set Zero.
*/
#define CXD56_GEOFENCE_IOCTL_STOP 2
/* Add region.
* This command is used to add the region.
*
* param arg
* Parameter is struct cxd56_geofence_region_s.
*/
#define CXD56_GEOFENCE_IOCTL_ADD 3
/* Modify region.
* This command is used to modify the region.
*
* param arg
* Parameter is struct cxd56_geofence_region_s.
*/
#define CXD56_GEOFENCE_IOCTL_MODIFY 4
/* Delete region.
* This command is used to delete the region.
*
* param arg
* Parameter is region id.
*/
#define CXD56_GEOFENCE_IOCTL_DELETE 5
/* Delete all region.
* This command is used to delete all region.
*
* param arg
* Parameter is Unnecessary. Set Zero.
*/
#define CXD56_GEOFENCE_IOCTL_ALL_DELETE 6
/* Get region data.
* This command is used to get region data.
*
* param arg
* Parameter is struct cxd56_geofence_region_s pointer
* Latitude and longitude and radius data of specified id is stored.
*/
#define CXD56_GEOFENCE_IOCTL_GET_REGION_DATA 7
/* Get used id.
* This command is used to get used region id.
*
* param arg
* Parameter is uint32_t data pointer.
* The used id is represented by bit field.
* For example, when ID0 and ID19 are used,
* since bit0 and bit19 are set, the return value is 0x00080001.
*/
#define CXD56_GEOFENCE_IOCTL_GET_USED_ID 8
/* Get all status.
* This command is used to get all region status.
*
* param arg
* Parameter is Unnecessary. Set Zero.
* All region status will stored in next read data.
*/
#define CXD56_GEOFENCE_IOCTL_GET_ALL_STATUS 9
/* Set goefence operation mode
* This command is used to set operation mode.
*
* param arg
* Parameter is struct cxd56_geofence_mode_s.
*/
#define CXD56_GEOFENCE_IOCTL_SET_MODE 10
/* check macros for GNSS commands */
#define CXD56_GEOFENCE_IOCTL_INVAL 0
#define CXD56_GEOFENCE_IOCTL_MAX 11
/* The transition type indicating that the user exits the region. */
#define CXD56_GEOFENCE_TRANSITION_EXIT 0
/* The transition type indicating that the user enters the region. */
#define CXD56_GEOFENCE_TRANSITION_ENTER 1
/* The transition type indicating that the user enters and
* dwells in region for a given period of time.
*/
#define CXD56_GEOFENCE_TRANSITION_DWELL 2
/* MAX number of region on the CXD56xx. */
#define CXD56_GEOFENCE_REGION_CAPACITY 20
/* Region center point and radius data
*
* The latitude and longtitude data format is
* integer value multiplied by 1000000.
* Example: When latitude is 35.123456, specify 35123456.
*/
struct cxd56_geofence_region_s
{
/* Region ID The range of ID is 0 to 19. */
uint8_t id;
/* Latitude (degree) of the center position of the region. */
long latitude;
/* Longitude (degree) of the center position of the region. */
long longitude;
/* Radius (m) of the region. */
uint16_t radius;
};
/* Geofence mode setting parameter */
struct cxd56_geofence_mode_s
{
uint16_t deadzone; /* dead zone [meter] */
uint16_t dwell_detecttime; /* Dewlling period time [sec] */
};
/* The transition data */
struct cxd56_geofence_trans_s
{
/* Region ID */
uint8_t id;
/* Transition status.
* The status is #CXD56_GEOFENCE_TRANSITION_EXIT or
* #CXD56_GEOFENCE_TRANSITION_ENTER or #CXD56_GEOFENCE_TRANSITION_DWELL.
*/
uint8_t status;
};
/* Geofence output data structer. */
struct cxd56_geofence_status_s
{
/* Updated region ID count */
uint8_t update;
/* The detail data od updated region ID */
struct cxd56_geofence_trans_s status[CXD56_GEOFENCE_REGION_CAPACITY];
};
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif /* __ARCH_ARM_INCLUDE_ARCH_CXD56XX_GEOFENCE_H */

View File

@ -0,0 +1,869 @@
/****************************************************************************
* arch/arm/include/cxd56xx/gnss.h
*
* Copyright 2018,2019 Sony Semiconductor Solutions Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name of Sony Semiconductor Solutions Corporation nor
* the names of its contributors may be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
#ifndef __ARCH_ARM_INCLUDE_CXD56XX_GNSS_H
#define __ARCH_ARM_INCLUDE_CXD56XX_GNSS_H
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C" {
#else
#define EXTERN extern
#endif
/****************************************************************************
* include files
****************************************************************************/
#include <arch/chip/gnss_type.h>
/* Start the positioning.
* This command is used to start the positioning.
*
* param arg
* Start mode value of uint32_t. Not address pointer.
* One of #CXD56_GNSS_STMOD_COLD, #CXD56_GNSS_STMOD_WARM, #CXD56_GNSS_STMOD_HOT
*/
#define CXD56_GNSS_IOCTL_START 1
/* Stop the positioning.
* This command is used to stop the positioning. GNSS will transition to idle
* mode.
*
* param arg
* Parameter is Unnecessary. Set Zero.
*/
#define CXD56_GNSS_IOCTL_STOP 2
/* Select the satellite systems.
* This command is used to select the satellite systems to be used for
* positioning.
* The satellite system is defined as a bit, and you can select mutiple
* sattelites using OR value.
* Do not specify zero, please select at least one system.
* This command must be issued in idle mode.
*
* param[in] arg
* Satellite system bitmap value of uint32_t. Not address pointer.
* Bit OR of #CXD56_GNSS_SAT_GPS, #CXD56_GNSS_SAT_GLONASS,
* #CXD56_GNSS_SAT_SBAS, #CXD56_GNSS_SAT_QZ_L1CA, #CXD56_GNSS_SAT_QZ_L1S.
*/
#define CXD56_GNSS_IOCTL_SELECT_SATELLITE_SYSTEM 3
/* Get satellite system to be used for measurement GNSS.
* The satellite system setting of the subscriber that a
* SF_COMMAND_COMMON_START command was published is acquired.
*
* param[out] arg
* Address pinting to of uint32_t object.
* Bit OR of #CXD56_GNSS_SAT_GPS, #CXD56_GNSS_SAT_GLONASS,
* #CXD56_GNSS_SAT_SBAS, #CXD56_GNSS_SAT_QZ_L1CA, #CXD56_GNSS_SAT_QZ_L1S.
*/
#define CXD56_GNSS_IOCTL_GET_SATELLITE_SYSTEM 4
/* Set the receiver approximate position.
* The receiver position is set using ellipsoidal coordinates (latitude,
* longitude, altitude).
* If ellipsoidal coordinates setting, north latitude and east longitude
* direction as positive.
* When specifying south latitude or west longitude, set it to a negative
* value.
*
* The receiver position, current time and TCXO offset value, ephemeris data
* are required in order to initiate a hot start
* so the position must have been set to GNSS using this command prior to hot
* start.
* Set GNSS configure with this command before hot start if receiver position
* is not stored in the memory.
* This command must be issued in idle mode.
*
* param[in] arg
* Address pointing to struct #cxd56_gnss_ellipsoidal_position_s object.
*/
#define CXD56_GNSS_IOCTL_SET_RECEIVER_POSITION_ELLIPSOIDAL 5
/* Set the receiver approximate position.
* The receiver position is set using orthogonal coordinates (x, y, z).
* The receiver position, current time and TCXO offset value, ephemeris data
* are required in order to initiate a hot start.
* Set the position with this command before hot start if no position
* information in GNSS.
* This command must be issued in idle mode.
*
* param[in] arg
* Address pointing to struct #cxd56_gnss_orthogonal_position_s object.
*/
#define CXD56_GNSS_IOCTL_SET_RECEIVER_POSITION_ORTHOGONAL 6
/* Set receiver operation mode.
* Can set operation mode and measurement cycle.
* The cycle data is 1000msec aligned only and cannot set 0msec.
*
* param[in] arg
* Address pointing to struct #cxd56_gnss_ope_mode_param_s object.
*/
#define CXD56_GNSS_IOCTL_SET_OPE_MODE 7
/* Get receiver operation mode.
*
* param[out] arg
* Address pointing to struct #cxd56_gnss_ope_mode_param_s object.
*/
#define CXD56_GNSS_IOCTL_GET_OPE_MODE 8
/* Set receiver TCXO offset value to GNSS.
* Receiver TCXO offset value set in "Hz". It can specify positive direction
* or negative direction by a sign int the argument.
* The receiver position, current time and TCXO offset value, ephemeris data
* are required in order to initiate a hot start.
* Set the offset with this command before hot start if no offset information
* in GNSS.
* This command must be issued in idle mode.
*
* param[in] arg
* TCXO offset value of uint32_t. Not address pointer.
* Address pointing to a offset value(int32_t) object.
*/
#define CXD56_GNSS_IOCTL_SET_TCXO_OFFSET 9
/* Get receiver TCXO offset value.
*
* param[out] arg
* Address pointing to int32_t object.
*/
#define CXD56_GNSS_IOCTL_GET_TCXO_OFFSET 10
/* Set receiver time to GNSS.
* The UTC time standard is used for the receiver time stored in a argument of
* cxd56_gnss_datetime type.
* The receiver position, current time and TCXO offset value, ephemeris data
* are required in order to initiate a hot start.
* Set the time with this command before hot start if GPS time is not counted
* in RTC.
* This command must be issued in idle mode.
*
* param[in] arg
* Address pointing to struct #cxd56_gnss_datetime_s object.
*/
#define CXD56_GNSS_IOCTL_SET_TIME 11
/* Get the latest almanac data extracted from the satellite signal.
* Almanac data size is 2048(GPS) or 576(GLONASS) bytes.
* This command must be issued in idle mode.
*
* param[out] arg
* Address pointing to struct #cxd56_gnss_orbital_param_s object.
*/
#define CXD56_GNSS_IOCTL_GET_ALMANAC 12
/* Set almanac data.
* Almanac data size is 2048(GPS) or 576(GLONASS) bytes.
* This command must be issued in idle mode.
*
* param[in] arg
* Address pointing to struct #cxd56_gnss_orbital_param_s object.
*/
#define CXD56_GNSS_IOCTL_SET_ALMANAC 13
/* Get the latest ephemeris data extracted from the satellite signal.
* Ephemeris data size is 3072(GPS) or 1152(GLONASS) bytes.
* This command must be issued in idle mode.
*
* param[out] arg
* Address pointing to struct #cxd56_gnss_orbital_param_s object.
*/
#define CXD56_GNSS_IOCTL_GET_EPHEMERIS 14
/* Set ephemeris data.
* Ephemeris data size is 3072(GPS) or 1152(GLONASS) bytes.
* This command must be issued in idle mode.
*
* param[in] arg
* Address pointing to struct #cxd56_gnss_orbital_param_s object.
*/
#define CXD56_GNSS_IOCTL_SET_EPHEMERIS 15
/* This command is used to save the backup data. The backup data contents are
* saved in the flash memory.
* The backup data saved in the flash memory is automatically restored at
* boot-up of GNSS.
* The receiver position, ephemeris, almanac, TCXO offset and other
* information required
* for hot start are included in the backup data.
* By saving it with this command, you can restore the information necessary
* for starting except time at boot time.
* This command must be issued in idle mode.
*
* param arg
* Parameter is Unnecessary. Set Zero.
*/
#define CXD56_GNSS_IOCTL_SAVE_BACKUP_DATA 16
/* Erase backup data on flash memory.
* This command must be issued in idle mode.
*
* param arg
* Parameter is Unnecessary. Set Zero.
*/
#define CXD56_GNSS_IOCTL_ERASE_BACKUP_DATA 17
/* Open CEP data file for GNSS device.
*
* Open the CEP data file and make the data available from the device.
* The file name to be opened is specified by Kconfig.
* This command must be issued in idle mode, between calling open function
* for GNSS device and issuing the command CXD56_GNSS_IOCTL_START.
*
* param[in] arg
* Parameter is Unnecessary. Set Zero.
*/
#define CXD56_GNSS_IOCTL_OPEN_CEP_DATA 18
/* Close the CEP data file opened with the command
* CXD56_GNSS_IOCTL_OPEN_CEP_DATA.
* This command must be issued in idle mode.
*
* param arg
* Parameter is Unnecessary. Set Zero.
*/
#define CXD56_GNSS_IOCTL_CLOSE_CEP_DATA 19
/* Check the validity of the CEP assist data.
* Return error code if the data file dose not exist or data is invalid.
*
* param arg
* Parameter is Unnecessary. Set Zero.
*/
#define CXD56_GNSS_IOCTL_CHECK_CEP_DATA 20
/* Get age(lifetime) information of assist data.
* Age includes start date and time represented by the Julian date(MJD), and
* validity period.
* Conversion MJD to YMD is following formula.
* (Assist data start time must 0:00 (GPS time))\n
* If the data file dose not exist, an error will be returned.
*
* JD12 = floor(MJD + 2400001)
* e = floor((JD12 - 1867216.25) / 36524.25)
* f = JD12 + (e - floor(e / 4) + 1)
* g = f + 1524
* h = floor((g - 122.1) / 365.25)
* i = floor(365.25 * h)
* j = floor((g - i) / 30.6001)
*
* d = g - i - floor(30.6001 * j)
* m = j - 12 * floor(j / 14) - 1
* w = h - 4716 + floor((14 - m) / 12)
*
* if w > 0 then y = w else y = w - 1
*
* param[in] arg
* Address pointing to struct #cxd56_gnss_cep_age_s object.
*/
#define CXD56_GNSS_IOCTL_GET_CEP_AGE 21
/* Reset CEP assist data init flag & valid flag.
* This command for notifying that the data has been updated.
* Execute this command before measurement if assist data updated.
*
* param arg
* Parameter is Unnecessary. Set Zero.
*/
#define CXD56_GNSS_IOCTL_RESET_CEP_FLAG 22
/* Currently version not supported. */
#define CXD56_GNSS_IOCTL_RTK_START 23
/* Currently version not supported. */
#define CXD56_GNSS_IOCTL_RTK_STOP 24
/* Currently version not supported. */
#define CXD56_GNSS_IOCTL_RTK_SET_INTERVAL 25
/* Currently version not supported. */
#define CXD56_GNSS_IOCTL_RTK_GET_INTERVAL 26
/* Currently version not supported. */
#define CXD56_GNSS_IOCTL_RTK_SELECT_SATELLITE_SYSTEM 27
/* Currently version not supported. */
#define CXD56_GNSS_IOCTL_RTK_GET_SATELLITE_SYSTEM 28
/* Currently version not supported. */
#define CXD56_GNSS_IOCTL_RTK_SET_EPHEMERIS_ENABLER 29
/* Currently version not supported. */
#define CXD56_GNSS_IOCTL_RTK_GET_EPHEMERIS_ENABLER 30
/* Set acquist data.
*
* param[in] arg
* Address pointing to struct #cxd56_gnss_agps_acquist_s object.
*/
#define CXD56_GNSS_IOCTL_AGPS_SET_ACQUIST 31
/* Set frame time.
*
* param[in] arg
* Address pointing to struct #cxd56_gnss_agps_frametime_s object.
*/
#define CXD56_GNSS_IOCTL_AGPS_SET_FRAMETIME 32
/* Set tau_GPS(&tau;GPS: Differnece of system time between GPS and Glonass
* system).
*
* param[in] arg
* Address pointing to tau GPS value(&tau;GPS, double) object.
*/
#define CXD56_GNSS_IOCTL_AGPS_SET_TAU_GPS 33
/* Set high precision receiver time.
*
* param arg
* Address pointing to struct #cxd56_gnss_agps_time_gps_s object.
*/
#define CXD56_GNSS_IOCTL_AGPS_SET_TIME_GPS 34
/* Clear info(s) for hot start.
*
* param arg
* Bit OR of #CXD56_GNSS_GCLR_EPH, #CXD56_GNSS_GCLR_ALM, #CXD56_GNSS_GCLR_PV,
* #CXD56_GNSS_GCLR_TIME, #CXD56_GNSS_GCLR_TCXO, #CXD56_GNSS_GCLR_ALL.
*/
#define CXD56_GNSS_IOCTL_AGPS_CLEAR_RECEIVER_INFO 35
/* Set acquist data.
*
* param[in] arg
* Address pointing to struct #cxd56_gnss_agps_tow_assist_s object.
*/
#define CXD56_GNSS_IOCTL_AGPS_SET_TOW_ASSIST 36
/* Set acquist data.
*
* param[in] arg
* Address pointing to struct #cxd56_gnss_agps_utc_model_s object.
*/
#define CXD56_GNSS_IOCTL_AGPS_SET_UTC_MODEL 37
/* Enable or not to output spectrum data of GNSS signal.
*
* param arg
* Address pointing to struct #cxd56_gnss_spectrum_control_s object.
*/
#define CXD56_GNSS_IOCTL_SPECTRUM_CONTROL 38
/* Start GPS factory test.
* Test results can get by CXD56_GNSS_IOCTL_FACTORY_GET_TEST_RESULT command
* after execute this command and waiting 1 second.
* This command execute during measurement stop.
* After executing this command, it is not accepted except for
* CXD56_GNSS_IOCTL_FACTORY_GET_TEST_RESULT and
* CXD56_GNSS_IOCTL_FACTORY_STOP_TEST.
*
* param[in] arg
* Address pointing to struct #cxd56_gnss_test_info_s object.
*/
#define CXD56_GNSS_IOCTL_FACTORY_START_TEST 39
/* Stop GPS factory test.
*
* param arg
* Parameter is Unnecessary. Set Zero.
*/
#define CXD56_GNSS_IOCTL_FACTORY_STOP_TEST 40
/* Get GPS factory test result.
*
* param[out] arg
* Address pointing to struct #cxd56_gnss_test_result_s object.
*/
#define CXD56_GNSS_IOCTL_FACTORY_GET_TEST_RESULT 41
/* Set signal information for GNSS events from GNSS device driver.
* The field 'enable' of struct #cxd56_gnss_signal_setting_s to be given
* as a parameter must be specified as 1 when setting and 0 when unsetting.
* param[out] arg
* Address pointing to struct #cxd56_gnss_signal_setting_s object.
*/
#define CXD56_GNSS_IOCTL_SIGNAL_SET 42
/* Start PVTLOG.
* Automatically saves the PVT log in the GNSS core.
*
* param arg
* Address pointing to #cxd56_pvtlog_setting_s object.
*/
#define CXD56_GNSS_IOCTL_PVTLOG_START 43
/* Stop PVTLOG.
* param arg
* Parameter is Unnecessary. Set Zero.
*/
#define CXD56_GNSS_IOCTL_PVTLOG_STOP 44
/* Delete PVTlog data.
* Delete the log data saved in the GNSS core.
* param arg
* Parameter is Unnecessary. Set Zero.
*/
#define CXD56_GNSS_IOCTL_PVTLOG_DELETE_LOG 45
/* Get PVTLOG status.
* This command is for getting the log stored status.
* The status data include stored log data count and logging time.
*
* param arg
* Address pointing to #cxd56_pvtlog_status_s.
*/
#define CXD56_GNSS_IOCTL_PVTLOG_GET_STATUS 46
/* Currently version not supported. */
#define CXD56_GNSS_IOCTL_NAVMSG_START 47
/* Set ephemeris data.
* Only satellites with data are output.
* Ephemeris data size is variable.
* Ephemeris data max size is 3072(GPS) or 1152(GLONASS) bytes.
* This command must be issued in idle mode.
*
* param[in] arg
* Address pointing to struct #cxd56_gnss_set_var_ephemeris_s object.
*/
#define CXD56_GNSS_IOCTL_SET_VAR_EPHEMERIS 48
/* Get the latest ephemeris data extracted from the satellite signal.
* Only satellites with data are output.
* Ephemeris data size is variable.
* Ephemeris data max size is 3072(GPS) or 1152(GLONASS) bytes.
* This command must be issued in idle mode.
*
* param[out] arg
* Address pointing to struct #cxd56_gnss_get_var_ephemeris_s object.
*/
#define CXD56_GNSS_IOCTL_GET_VAR_EPHEMERIS 49
/* check macros for GNSS commands */
#define CXD56_GNSS_IOCTL_INVAL 0
#define CXD56_GNSS_IOCTL_MAX 50
/* Same value to GD Start mode CXD56_GNSS_STMOD_XXXX for GD_Start */
#define CXD56_GNSS_STMOD_COLD 0 /* Cold Start */
#define CXD56_GNSS_STMOD_WARM 1 /* Warm Start */
#define CXD56_GNSS_STMOD_WARM_ACC2 2 /* Warm Start, better accuracy, less TTFF than WARM */
#define CXD56_GNSS_STMOD_HOT 3 /* Hot Start */
#define CXD56_GNSS_STMOD_HOT_ACC 4 /* Hot Start, better accuracy, less TTFF than HOT */
#define CXD56_GNSS_STMOD_HOT_ACC2 5 /* Hot Start, better accuracy, less TTFF than ACC */
#define CXD56_GNSS_STMOD_HOT_ACC3 6 /* Optimized hot start, better TTFF than HOT */
#define CXD56_GNSS_STMOD_GSPQ CXD56_GNSS_STMOD_HOT_ACC3
#define CXD56_GNSS_GPS_ALMANAC_SIZE 2048 /* GPS Almanac Size */
#define CXD56_GNSS_GPS_EPHEMERIS_SIZE 3072 /* GPS Ephemeris Size */
#define CXD56_GNSS_GLONASS_ALMANAC_SIZE 576 /* GLONASS Almanac Size */
#define CXD56_GNSS_GLONASS_EPHEMERIS_SIZE 1152 /* GLONASS Ephemeris Size */
#define CXD56_GNSS_QZSSL1CA_ALMANAC_SIZE 640 /* GPS Almanac Size */
#define CXD56_GNSS_QZSSL1CA_EPHEMERIS_SIZE 960 /* GPS Ephemeris Size */
/* PVTLOG notify threshold of the stored data. */
#define CXD56_GNSS_PVTLOG_THRESHOLD_FULL 0 /* Limit of the storage size */
#define CXD56_GNSS_PVTLOG_THRESHOLD_HALF 1 /* 1/2 of the Storage size */
#define CXD56_GNSS_PVTLOG_THRESHOLD_ONE_DATA 2 /* Each log stored */
/* Offset for last GNSS data */
#define CXD56_GNSS_READ_OFFSET_LAST_GNSS 0x0000
/* Offset for GNSS data */
#define CXD56_GNSS_READ_OFFSET_GNSS(N) (0x1000 + 0x800 * (N))
/* Offset for AGPS data */
#define CXD56_GNSS_READ_OFFSET_AGPS 0x5000
/* Offset for RTK data */
#define CXD56_GNSS_READ_OFFSET_RTK 0x6000
/* Offset for RTK GPS Ephemeris data */
#define CXD56_GNSS_READ_OFFSET_GPSEPHEMERIS 0x7000
/* Offset for RTK GLONASS Ephemeris data */
#define CXD56_GNSS_READ_OFFSET_GLNEPHEMERIS 0x8000
/* Offset for SBAS data */
#define CXD56_GNSS_READ_OFFSET_SBAS 0x9000
/* Offset for DC report */
#define CXD56_GNSS_READ_OFFSET_DCREPORT 0x9800
/* Offset for Spectrum data */
#define CXD56_GNSS_READ_OFFSET_SPECTRUM 0xa000
/* Offset for GNSS info */
#define CXD56_GNSS_READ_OFFSET_INFO 0xf000
/* Offset for PVTLOG data */
#define CXD56_GNSS_READ_OFFSET_PVTLOG 0x10000
/* Signal types from GNSS */
/* Signal type is GNSS */
#define CXD56_GNSS_SIG_GNSS 0
/* Signal type is PVTLog */
#define CXD56_GNSS_SIG_PVTLOG 2
/* Signal type is AGPS */
#define CXD56_GNSS_SIG_AGPS 3
/* Signal type is RTK Career Phase */
#define CXD56_GNSS_SIG_RTK 4
/* Signal type is Soectrum */
#define CXD56_GNSS_SIG_SPECTRUM 5
/* Signal type is RTK GPS Ephemeris */
#define CXD56_GNSS_SIG_GPSEPHEMERIS 11
/* Signal type is RTK GLONASS Ephemeris */
#define CXD56_GNSS_SIG_GLNEPHEMERIS 12
/* Signal type is SBAS */
#define CXD56_GNSS_SIG_SBAS 14
/* Signal type is QZSS DC report */
#define CXD56_GNSS_SIG_DCREPORT 15
/****************************************************************************
* Public Types
****************************************************************************/
/* GNSS operation mode and cycle */
struct cxd56_gnss_ope_mode_param_s
{
/* receiver operation mode
* 0: No Change Operation
* 1: Normal(default)
*/
uint32_t mode;
/* Positioning cycle[ms]
* The cycle data is 1000msec aligned only and
* cannot set 0msec.
* (Init value 1000)
*/
uint32_t cycle;
};
/* Sattelite almanac, ephemeris data */
struct cxd56_gnss_orbital_param_s
{
uint32_t type; /* One of #CXD56_GNSS_DATA_GPS,
* #CXD56_GNSS_DATA_GLONASS or
* #CXD56_GNSS_DATA_QZSSL1CA.
*/
FAR uint32_t *data; /* Address pointing to almanac or ephemeris data buffer */
};
/* date and time */
struct cxd56_gnss_datetime_s
{
struct cxd56_gnss_date_s date; /* date */
struct cxd56_gnss_time_s time; /* time */
};
/* ellipsoidal position */
struct cxd56_gnss_ellipsoidal_position_s
{
double latitude; /* latitude[degree] */
double longitude; /* longitude[degree] */
double altitude; /* altitude[meter] */
};
/* ellipsoidal position */
struct cxd56_gnss_orthogonal_position_s
{
int32_t x; /* x[meter] */
int32_t y; /* y[meter] */
int32_t z; /* z[meter] */
};
/* Currently version not supported. */
struct cxd56_gnss_cep_data_s
{
FAR uint32_t *data;
uint32_t size;
uint32_t counter;
};
/* CEP age info */
struct cxd56_gnss_cep_age_s
{
float age; /* age */
float cepi; /* cepi */
};
/* acquist data and size for AGPS */
struct cxd56_gnss_agps_acquist_s
{
FAR uint8_t *data; /* Address pointing to aquist data buffer */
uint16_t size; /* Aquist data size */
};
/* tow assist data and size for AGPS */
struct cxd56_gnss_agps_tow_assist_s
{
FAR uint8_t *data; /* Address pointing to tow assist data buffer */
uint16_t size; /* assist data size */
};
/* utc model data and size for AGPS */
struct cxd56_gnss_agps_utc_model_s
{
FAR uint8_t *data; /* Address pointing to utc model data buffer */
uint16_t size; /* utc model data size */
};
/* Time from frame start[sec]. */
struct cxd56_gnss_agps_frametime_s
{
uint16_t sec; /* Integer part */
uint32_t frac; /* Fraction part */
};
/* High precision receiver time */
struct cxd56_gnss_agps_time_gps_s
{
struct cxd56_gnss_date_s date; /* Date */
struct cxd56_gnss_time_s time; /* Time */
};
/* different time between AGPS and GLONASS Time */
struct cxd56_gnss_agps_tau_gps_s
{
double taugps; /* tau Time */
};
/* Signal spectrum output control parameter */
struct cxd56_gnss_spectrum_control_s
{
uint8_t enable; /* Spectrum data output enable */
uint32_t time; /* Passed Time */
uint8_t point1; /* Monitor point1 (7-9) */
uint8_t point2; /* Monitor point2 (7-9) */
uint8_t step1; /* Sampling step1 (0-7) */
uint8_t step2; /* Sampling step2 (0-7) */
};
struct cxd56_gnss_test_info_s
{
uint32_t satellite; /* Specify satellite by svID */
uint32_t reserve1; /* Reserve (always specify 0) */
uint32_t reserve2; /* Reserve (always specify 0) */
uint32_t reserve3; /* Reserve (always specify 0) */
};
struct cxd56_gnss_test_result_s
{
float cn; /* CN ratio [dB-Hz] */
float doppler; /* Doppler [Hz] */
};
/* signal setting for reading data asychronously
* The field 'enable' of struct #cxd56_gnss_signal_setting_s to be given as a
* parameter must be specified as 1 when setting and 0 when unsetting.
* Field 'gnsssig' specifies the value of 'Signal types from GNSS',
* this is not POSIX signal.
* Field 'signo' is application specific number of POSIX signal.
* 'data' will be passed as an argument to the handler.
*/
struct cxd56_gnss_signal_setting_s
{
int fd; /* The descriptor for signal handler */
uint8_t enable; /* 1 when set this setting, 0 is clear */
uint8_t gnsssig; /* GNSS signal as CXD56_GNSS_SIG_GNSS, _AGPS, etc. */
int signo; /* system signal number to notify read completion */
FAR void *data; /* user data */
};
/* Information for use after being signaled to read data asychronously */
struct cxd56_gnss_signal_info_s
{
int fd; /* The file descriptor to use in signal handler */
uint8_t gnsssig; /* GNSS signal as CXD56_GNSS_SIG_GNSS, _AGPS, etc. */
int signo; /* system signal number to notify read completion */
FAR void *data; /* user data */
};
/* PVTLOG setting Parameter.
* If the log interval(cycle) is smaller than the positioning interval,
* it is logged every positioning interval.
* The output timing is specified by the ratio to the log buffer in the
* GNSS device by threshold. Possible values are
* #CXD56_GNSS_PVTLOG_THRESHOLD_FULL, #CXD56_GNSS_PVTLOG_THRESHOLD_HALF,
* and #CXD56_GNSS_PVTLOG_THRESHOLD_ONE_DATA.
*/
struct cxd56_pvtlog_setting_s
{
uint32_t cycle; /* PVT log interval in seconds */
uint32_t threshold; /* Notification threshold of log storage amount */
};
struct cxd56_pvtlog_status_s
{
struct cxd56_gnss_status_s status; /* The stored logs status */
};
struct cxd56_rtk_setting_s
{
int interval; /* RTK data output interval */
uint32_t gnss; /* RTK satellite setting */
int ephout; /* Ephemeris notify enable setting */
uint64_t sbasout; /* sbas notify enable setting */
};
struct cxd56_gnss_set_var_ephemeris_s
{
uint32_t *data; /* Address pointing to ephemeris data buffer */
uint32_t size; /* ephemeris data buffer size */
};
struct cxd56_gnss_get_var_ephemeris_s
{
uint32_t type; /* One of #CXD56_GNSS_DATA_GPS, #CXD56_GNSS_DATA_GLONASS. */
uint32_t *data; /* Address pointing to ephemeris data buffer */
uint32_t size; /* ephemeris data buffer size */
};
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif /* ARCH_ARM_INCLUDE_CXD56XX_GNSS_H */

View File

@ -0,0 +1,710 @@
/****************************************************************************
* arch/arm/include/cxd56xx/gnss_type.h
*
* Copyright 2018,2019 Sony Semiconductor Solutions Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name of Sony Semiconductor Solutions Corporation nor
* the names of its contributors may be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
#ifndef __ARCH_ARM_INCLUDE_CXD56XX_GNSS_TYPE_H
#define __ARCH_ARM_INCLUDE_CXD56XX_GNSS_TYPE_H
/* NOTICE:
* This file defines a structure that stores GNSS positioning
* data of CXD 56xx. The public header file gnss_type.h for NuttX
* of the CXD 56xx SDK has been copied as gd_type.h in the nxloader
* build system and used. Therefore, if you change the definitions
* in this file, please synchronize and change the other.
*/
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C" {
#else
#define EXTERN extern
#endif
/****************************************************************************
* include files
****************************************************************************/
#include <stdint.h>
/* Max number of satellites */
#define CXD56_GNSS_MAX_SV_NUM 32
/* GNSS satellite system */
#define CXD56_GNSS_SAT_NONE (0) /* None */
#define CXD56_GNSS_SAT_GPS (1U << 0) /* GPS */
#define CXD56_GNSS_SAT_GLONASS (1U << 1) /* Glonass */
#define CXD56_GNSS_SAT_SBAS (1U << 2) /* SBAS */
#define CXD56_GNSS_SAT_QZ_L1CA (1U << 3) /* QZSS/L1CA */
#define CXD56_GNSS_SAT_IMES (1U << 4) /* IMES */
#define CXD56_GNSS_SAT_QZ_L1S (1U << 5) /* QZSS/L1S */
#define CXD56_GNSS_SAT_BEIDOU (1U << 6) /* BeiDou */
#define CXD56_GNSS_SAT_GALILEO (1U << 7) /* Galileo */
/* GNSS positioning type */
#define CXD56_GNSS_PVT_TYPE_NONE 0 /* Positioning data none */
#define CXD56_GNSS_PVT_TYPE_GNSS 1 /* by GNSS */
#define CXD56_GNSS_PVT_TYPE_IMES 2 /* by IMES */
#define CXD56_GNSS_PVT_TYPE_USER 3 /* API setting */
/* GNSS position fix mode */
#define CXD56_GNSS_PVT_POSFIX_INVALID 1 /* No measurement */
#define CXD56_GNSS_PVT_POSFIX_2D 2 /* 2D fix */
#define CXD56_GNSS_PVT_POSFIX_3D 3 /* 3D fix */
/* GNSS velocity fix mode */
#define CXD56_GNSS_PVT_VELFIX_INVALID 1 /* No measurement */
#define CXD56_GNSS_PVT_VELFIX_2DVZ 2 /* 2D VZ fix */
#define CXD56_GNSS_PVT_VELFIX_2DOFFSET 3 /* 2D Offset fix */
#define CXD56_GNSS_PVT_VELFIX_3D 4 /* 3D fix */
#define CXD56_GNSS_PVT_VELFIX_1D 5 /* 1D fix */
#define CXD56_GNSS_PVT_VELFIX_PRED 6 /* Prediction */
/* GNSS oribital infomation data type, almanac & ephemeris */
#define CXD56_GNSS_DATA_GPS 0 /* GPS data type */
#define CXD56_GNSS_DATA_GLONASS 1 /* Glonass data type */
#define CXD56_GNSS_DATA_QZSSL1CA 2 /* QZSS/L1CA data type */
/* GNSS satellite status */
#define CXD56_GNSS_SV_STAT_NONE (0) /* None */
#define CXD56_GNSS_SV_STAT_TRACKING (1 << 0) /* Tracking */
#define CXD56_GNSS_SV_STAT_POSITIONING (1 << 1) /* Positioning */
#define CXD56_GNSS_SV_STAT_CALC_VELOCITY (1 << 2) /* Calc Velocity */
#define CXD56_GNSS_SV_STAT_VISIBLE (1 << 3) /* Visible */
#define CXD56_GNSS_SV_STAT_SUB_CH (1 << 4) /* Sub Ch */
/* GNSS 1PPS synchronization status (internal use) */
#define CXD56_GNSS_PPS_NOT_ADJUSTED 0 /* not adjusted */
#define CXD56_GNSS_PPS_ADJUSTED 1 /* adjusted */
#define CXD56_GNSS_PPS_ADJUSTED_SSDGLN 2 /* adjusted SSDGLN */
#define CXD56_GNSS_PPS_ADJUSTED_SSD 3 /* adjusted SSD */
#define CXD56_GNSS_PPS_ADJUSTED_POS 4 /* adjusted POS */
#define CXD56_GNSS_PPS_DEGRADE2 5 /* Degrade2 */
#define CXD56_GNSS_PPS_DEGRADE 6 /* Degrade */
#define CXD56_GNSS_PPS_COMPLETE 7 /* Complete */
/* GNSS Output interval of carrier phase info. */
#define CXD56_GNSS_RTK_INTERVAL_1HZ 1000 /* 1Hz */
#define CXD56_GNSS_RTK_INTERVAL_2HZ 500 /* 2Hz */
#define CXD56_GNSS_RTK_INTERVAL_5HZ 200 /* 5Hz */
#define CXD56_GNSS_RTK_INTERVAL_10HZ 100 /* 10Hz */
#define CXD56_GNSS_RTK_INTERVAL_20HZ 50 /* 20H */
/* Carrier phase max satellite number */
#define CXD56_GNSS_RTK_MAX_SV_NUM 24
/* GNSS Spectrum data size */
/* Spectrum Data Max(adjusted as CXD56_GNSS_SPECTRUM_DATA will be 116byte.) */
#define CXD56_GNSS_SPECTRUM_MAXNUM 37
/* Peak Spectrum Data */
#define CXD56_GNSS_PEAK_SPECTRUM_MAXNUM 3
/* SPZ_INT_API */
/* DC Report data size */
#define CXD56_GNSS_QSM_MSG_BIT_NUM 250
#define CXD56_GNSS_QSM_NUM_BITS_IN_BYTE 8
/* AGPS Measurement tracking data */
#define CXD56_GNSS_SUPL_TRK_DATA_SIZE (16)
/* PVTLOG Max stored log number */
#define CXD56_GNSS_PVTLOG_MAXNUM 170
/* assist bit fields */
#define CXD56_GNSS_PVT_RECEIVER_ASSIST_NONE (0x00)
#define CXD56_GNSS_PVT_RECEIVER_ASSIST_USER (0x01)
#define CXD56_GNSS_PVT_RECEIVER_ASSIST_CEPPOS (0x02)
#define CXD56_GNSS_PVT_RECEIVER_ASSIST_CEPVEL (0x04)
#define CXD56_GNSS_PVT_RECEIVER_ASSIST_AEPPOS (0x08)
#define CXD56_GNSS_PVT_RECEIVER_ASSIST_AEPVEL (0x10)
/* GNSS positionig data elements */
/* Day (UTC) */
struct cxd56_gnss_date_s
{
uint16_t year; /* year */
uint8_t month; /* month */
uint8_t day; /* day */
};
/* Time (UTC) */
struct cxd56_gnss_time_s
{
uint8_t hour; /* hour */
uint8_t minute; /* minitue */
uint8_t sec; /* sec */
uint32_t usec; /* usec */
};
/* Time (GPS) */
struct cxd56_gnss_wntow_s
{
uint32_t tow; /* truncated TOW (1 = 6sec, 0 ... 100799) */
uint16_t weeknumber; /* week number (0 ... 1023) */
uint8_t sec; /* offset (0 ... 5) */
uint8_t rollover; /* Number of WN Roll Over (0 ... 255) */
double frac; /* fraction */
};
/* struct cxd56_gnss_dop_s - Dilution Of Precision */
struct cxd56_gnss_dop_s
{
float pdop; /* Position DOP */
float hdop; /* Horizontal DOP */
float vdop; /* Vertical DOP */
float tdop; /* Time DOP */
float ewdop; /* East-West DOP */
float nsdop; /* North-South DOP */
float majdop; /* Stdev of semi-major axis */
float mindop; /* Stdev of semi-minor axis */
float oridop; /* Orientation of semi-major axis [deg] */
};
/* struct cxd56_gnss_var_s - Variance */
struct cxd56_gnss_var_s
{
float hvar; /* Horizontal */
float vvar; /* Vertical */
};
/* Extra data for debugging */
#define CXD56_GNSS_PVT_RECEIVER_EXTRA_DATA_SIZE (520)
#define CXD56_GNSS_PVT_RECEIVER_EXTRA_DATA \
uint8_t extra[CXD56_GNSS_PVT_RECEIVER_EXTRA_DATA_SIZE]
#define CXD56_GNSS_PVT_SV_EXTRA_DATA_SIZE 40
#define CXD56_GNSS_PVT_SV_EXTRA_DATA \
uint8_t extra[CXD56_GNSS_PVT_SV_EXTRA_DATA_SIZE]
#define CXD56_GNSS_FFT_MAXPOOLNUM (8)
/* GNSS AGPS clear flag */
#define CXD56_GNSS_GCLR_EPH 0x00000001 /* ephemeris */
#define CXD56_GNSS_GCLR_ALM 0x00000002 /* almanac */
#define CXD56_GNSS_GCLR_PV 0x00000004 /* position and velocity */
#define CXD56_GNSS_GCLR_TIME 0x00000008 /* time */
#define CXD56_GNSS_GCLR_TCXO 0x00010000 /* TCXO offset */
#define CXD56_GNSS_GCLR_ALL 0xffffffff /* all of above */
/* GNSS Receiver data */
struct cxd56_gnss_receiver_s
{
uint8_t type; /* [out] Position type; 0:Invalid, 1:GNSS,
* 2:IMES, 3:user set, 4:previous
*/
uint8_t dgps; /* [out] FALSE:SGPS, TRUE:DGPS */
uint8_t pos_fixmode; /* [out] 1:Invalid, 2:2D, 3:3D */
uint8_t vel_fixmode; /* [out] 1:Invalid, 2:2D VZ, 3:2D Offset,
* 4:3D, 5:1D, 6:PRED
*/
uint8_t numsv; /* [out] Nr of visible satellites */
uint8_t numsv_tracking; /* [out] Nr of tracking satellites */
uint8_t numsv_calcpos; /* [out] Nr of satellites to calculate position */
uint8_t numsv_calcvel; /* [out] Nr of satellites to calculate velocity */
uint8_t assist; /* [out] bit field
* [7..5]Reserved
* [4]AEP Velocity
* [3]AEP Position
* [2]CEP Velocity
* [1]CEP Position,
* [0]user set
*/
uint8_t pos_dataexist; /* [out] 0:none, 1:exist */
uint16_t svtype; /* [out] Using sv system, bit field;
* bit0:GPS, bit1:GLONASS, bit2:SBAS,
* bit3:QZSS_L1CA, bit4:IMES,
* bit5:QZSS_L1SAIF, bit6:Beidu,
* bit7:Galileo
*/
uint16_t pos_svtype; /* [out] using sv system, bit field;
* bit0:GPS, bit1:GLONASS, bit2:SBAS,
* bit3:QZSS_L1CA, bit4:IMES,
* bit5:QZSS_L1SAIF, bit6:Beidu,
* bit7:Galileo
* */
uint16_t vel_svtype; /* [out] using sv system, bit field; bit0:GPS,
* bit0:GPS, bit1:GLONASS, bit2:SBAS,
* bit3:QZSS_L1CA, bit4:IMES,
* bit5:QZSS_L1SAIF, bit6:Beidu,
* bit7:Galileo
*/
uint32_t possource; /* [out] position source; 0:Invalid, 1:GNSS,
* 2:IMES, 3:user set, 4:previous
*/
int32_t tcxo_offset; /* [out] TCXO offset[Hz] */
struct cxd56_gnss_dop_s pos_dop; /* [out] DOPs of Position */
struct cxd56_gnss_dop_s vel_idx; /* [out] Weighted DOPs of Velocity */
struct cxd56_gnss_var_s pos_accuracy; /* [out] Accuracy of Position */
double latitude; /* [out] Latitude [degree] */
double longitude; /* [out] Longitude [degree] */
double altitude; /* [out] Altitude [m] */
double geoid; /* [out] Geoid height [m] */
float velocity; /* [out] Velocity [m/s] */
float direction; /* [out] Direction [degree] */
struct cxd56_gnss_date_s date; /* [out] Current day (UTC) */
struct cxd56_gnss_time_s time; /* [out] Current time (UTC) */
struct cxd56_gnss_date_s gpsdate; /* [out] Current day (GPS) */
struct cxd56_gnss_time_s gpstime; /* [out] Current time (GPS) */
struct cxd56_gnss_time_s receivetime; /* [out] Receive time (UTC) */
uint32_t priv; /* [out] For internal use */
CXD56_GNSS_PVT_RECEIVER_EXTRA_DATA; /* [out] Receiver extra data */
};
/* GNSS satellite data */
struct cxd56_gnss_sv_s
{
uint16_t type; /* [out] Using sv system, bit field; bit0:GPS,
* bit1:GLONASS, bit2:SBAS, bit3:QZSS_L1CA,
* bit4:IMES, bit5:QZSS_L1SAIF, bit6:Beidu,
* bit7:Galileo
* same as struct cxd56_gnss_receiver_s::svtype
*/
uint8_t svid; /* [out] Satellite id */
uint8_t stat; /* Using sv info, bit field; bit0:tracking,
* bit1:positioning, bit2:calculating velocity,
* bit3:visible satellite
*/
uint8_t elevation; /* [out] Elevation [degree] */
int16_t azimuth; /* [out] Azimuth [degree] */
float siglevel; /* [out] CN */
CXD56_GNSS_PVT_SV_EXTRA_DATA; /* [out] Sv extra data */
};
/* Positioning data with SV data */
struct cxd56_gnss_positiondata_s
{
uint64_t data_timestamp; /* [out] Timestamp */
uint32_t status; /* [out] Positioning data status 0 : Valid, <0: Invalid */
uint32_t svcount; /* [out] Sv data count */
struct cxd56_gnss_receiver_s receiver; /* [out] Receiver data */
struct cxd56_gnss_sv_s sv[CXD56_GNSS_MAX_SV_NUM]; /* [out] Sv data array */
};
/* QZSS DC report data */
struct cxd56_gnss_dcreport_data_s
{
uint8_t sf[CXD56_GNSS_QSM_MSG_BIT_NUM /
CXD56_GNSS_QSM_NUM_BITS_IN_BYTE + 1]; /* [out] Message body */
uint8_t svid; /* [out] Satellite id */
};
/* SF_EVENT_GNSS_MEASUREMENT_VALUE */
/* SUPL tracking data */
struct cxd56_supl_trkdata_s
{
uint8_t gnssid; /* [out] sv system
* GPS: 0x01
* GLONASS: 0x02
* SBAS : 0x04
* QZSS_L1C/A:0x08
*/
uint8_t signalid; /* [out] Always 0 */
uint8_t svid; /* [out] Satellite Id
* GPS: 1-32
* GLONASS: 1-24
* SBAS: 120-158
* QZSS_L1C/A 193-197
*/
uint8_t cn; /* [out] CN ratio [dBHz] */
uint8_t codephase_ambiguty; /* Currently version not supported. */
uint8_t carriorquality_indicator; /* Currently version not supported. */
uint8_t codephase_rmserr; /* Currently version not supported. */
uint8_t multipath_indicator; /* Currently version not supported. */
uint32_t codephase; /* [out] Code Phase[ms] scale: 2-21[ms] */
uint16_t wholechip; /* [out] Chip integer part */
uint16_t fracchip; /* [out] Chip frac part */
uint32_t adr; /* Currently version not supported. */
int16_t doppler; /* [out] Doppler [Hz] */
};
/* SUPL positioning data */
struct cxd56_supl_posdata_s
{
double uncertainty_semi_major; /* [out] Uncertainty semi-major */
double uncertainty_semi_minor; /* [out] Uncertainty semi-minor */
double orientation_of_major_axis; /* [out] Orientation of major axis */
double uncertainty_altitude; /* [out] Uncertainty Altitude */
uint32_t tow; /* [out] Time of week [sec]
* acquisition TOW : 0-604799
* no acquisition TOW : 0xffffffff
*/
float frac_sec; /* [out] Under second part[sec]
* no acquisition TOW : -1
*/
float horizontal_accuracy; /* [out] Horizontal accuracy [m]
* disable : -1
*/
uint16_t ref_frame; /* Currently version not supported */
uint8_t tod_unc; /* [out] Acquisition : 1
* no acquisition : 0
*/
uint8_t num_of_sat; /* [out] Tracking Sv number */
};
/* SUPL Measurement data struct */
struct cxd56_supl_mesurementdata_s
{
/* [out] Supl positioning data */
struct cxd56_supl_posdata_s supl_pos;
/* [out] Tracking satellite data */
struct cxd56_supl_trkdata_s trackingsat[CXD56_GNSS_SUPL_TRK_DATA_SIZE];
};
/* struct cxd56_gnss_timetag_s - Internal time tag */
struct cxd56_gnss_timetag_s
{
uint32_t msec; /* [ms] whole millisecond part */
uint32_t frac; /* Under millisecond part (0 ... cycle-1) */
uint16_t cycle; /* Resolution of 1ms */
};
/* Time and frequency information for RTK */
struct cxd56_rtk_info_s
{
uint64_t timestamp; /* [out] system timestamp */
uint64_t timesnow; /* [out] system now times */
struct cxd56_gnss_wntow_s wntow; /* [out] GPS time */
struct cxd56_gnss_date_s date; /* [out] Date (UTC time) */
struct cxd56_gnss_time_s time; /* [out] Time (UTC time) */
struct cxd56_gnss_timetag_s tag; /* [out] TimeTag */
double clockdrift; /* [out] [Hz] clock drift @1.5GHz
* (valid only if cdvalidity is 1)
*/
int8_t cdvalidity; /* [out] clock drift validity
* (0: invalid, 1: valid)
*/
uint8_t ppsstatus; /* [out] 1PPS synchronization status */
int8_t svcount; /* [out] Num of sv */
};
/* Carrier phase and related data for RTK */
struct cxd56_rtk_sv_s
{
double pseudorange; /* [out] [m] pseudo range */
double carrierphase; /* [out] [wave number] carrier phase */
uint32_t gnss; /* [out] GNSS type (CXD56_GNSS_GNSS_XXX) */
int8_t svid; /* [out] Satellite id */
int8_t fdmch; /* [out] Frequency slot for GLONASS (-7 ... 6) */
int16_t cn; /* [out] [0.01dBHz] CN */
int8_t polarity; /* [out] Carrier polarity
* (0: not inverted, 1: inverted)
*/
int8_t lastpreamble; /* [out] Parity of last premable (0: ok, 1: ng) */
int8_t lli; /* [out] Lock loss indicator
* (0: no lock loss, 1: lock loss)
*/
int8_t ch; /* [out] TRK channel number */
float c2p; /* [out] C2P (0 ... 1.0) */
float doppler; /* [out] [Hz] Doppler shift */
};
/* RTK Carrier phase data */
struct cxd56_rtk_carrierphase_s
{
/* [out] Time and frequency information */
struct cxd56_rtk_info_s infoout;
/* [out] Carrier phase and related data */
struct cxd56_rtk_sv_s svout[CXD56_GNSS_RTK_MAX_SV_NUM];
};
/* Ephemeris data (GPS) */
struct cxd56_rtk_gpsephemeris_s
{
uint64_t timesnow; /* [out] system now times */
uint8_t ppsstatus; /* [out] 1PPS synchronization status */
uint16_t t_oc; /* [out] SV Clock Correction */
double af0; /* [out] SV Clock Correction */
double af1; /* [out] SV Clock Correction */
double af2; /* [out] SV Clock Correction */
double crs; /* [out] Amplitude correction term of orbital radius(sin) */
double delta_n; /* [out] Average motion difference [rad] */
double m0; /* [out] Average near point separation at t_oe [rad] */
double cuc; /* [out] Latitude amplitude correction term(cos) */
double e; /* [out] Eccentricity of orbit */
double cus; /* [out] Latitude amplitude correction term(sin) */
double sqrt_a; /* [out] Square root of the orbital length radius */
double cic; /* [out] Amplitude correction term of orbital inclination angle(cos) */
double omega0; /* [out] Rise of ascension at Weekly Epoch [rad] */
double cis; /* [out] Amplitude correction term of orbital inclination angle(sin) */
double i0; /* [out] Orbital inclination angle at t_oe */
double crc; /* [out] Amplitude correction term of orbital radius(cos) */
double omega; /* [out] Perigee argument [rad] */
double omega_dot; /* [out] Ascension of ascending node correction [rad] */
double i_dot; /* [out] Orbital inclination angle correction [rad] */
double accuracy; /* [out] nominal URA (User Range Accuracy) [m] */
double tgd; /* [out] Estimated Group Delay Differential */
/* tocwntow, tocdate, toctime are valid if ppsstatus >= 1(adjusted) */
struct cxd56_gnss_wntow_s tocwntow; /* [out] toc */
struct cxd56_gnss_date_s tocdate; /* [out] toc Date */
struct cxd56_gnss_time_s toctime; /* [out] toc Time */
int32_t toe; /* [out] Reference time [s] */
int32_t tow; /* [out] Time of Week (truncated) */
int16_t id; /* [out] Satellite id */
uint8_t iode; /* [out] Issue of Data (Ephemeris) Subframe 2 */
int8_t codes_on_l2; /* [out] Code(s) on L2 Channel */
int16_t weeknumber; /* [out] Full week number */
int8_t l2p; /* [out] Data Flag for L2 P-Code */
uint8_t health; /* [out] SV Health (6bit for ephemeris / 8bit for almanac) */
int16_t iodc; /* [out] Issue of Data, Clock (IODC) */
int8_t fitinterval; /* [out] Fit interval flag */
};
/* Ephemeris data (GLONASS) */
struct cxd56_rtk_glonassephemeris_s
{
uint64_t timesnow; /* [out] system now times */
uint32_t valid; /* [out] valid */
uint8_t ppsstatus; /* [out] 1PPS synchronization status */
uint8_t slot; /* [out] slot 1...24 (It generates from svid. Usually same as me->n) */
int8_t ch; /* [out] ch -7...6 */
uint8_t p1; /* [out] The difference of t_b from the previous frame */
uint8_t tk_h; /* [out] Current frame first time (hours) */
uint8_t tk_m; /* [out] Current frame first time (minutes) */
uint8_t tk_s; /* [out] Current frame first time (seconds) */
double xv; /* [out] The velocity vector components of t_b */
float xa; /* [out] The acceleration components of t_b */
double xp; /* [out] The position of t_b */
uint8_t bn; /* [out] The health info */
uint8_t p2; /* [out] flag of oddness ("1") or evenness ("0") of the value of t_b */
uint16_t tb; /* [out] Reference time t_b (15...1425) */
uint8_t hn_e; /* [out] Carrier frequency number (0...31, (25...31)=(7...-1)) */
double yv; /* [out] The velocity vector components of t_b */
float ya; /* [out] The acceleration components of t_b */
double yp; /* [out] The position of t_b */
uint8_t p3; /* [out] Number of almanacs in the current frame */
float gn; /* [out] Carrier frequency relative deviation of t_b */
uint8_t p; /* [out] Origin of tau variable */
uint8_t health; /* [out] Health flag */
double zv; /* [out] The velocity vector components of t_b */
float za; /* [out] The acceleration components of t_b */
double zp; /* [out] The position of t_b */
float tn; /* [out] Correction to the satellite time t_n relative to GLONASS time t_c */
float dtn; /* [out] Difference in internal delay between L2 and L1 */
uint8_t en; /* [out] Number of days from when data was uploaded until t_b (0...31) */
uint8_t p4; /* [out] Flag of ephemeris parameters updating */
uint8_t ft; /* [out] The URA (index) of t_b */
uint16_t nt; /* [out] Number of days since 1/1 of a leap year */
uint8_t n; /* [out] Slot number of the signaling satellite (0...31) */
uint8_t m; /* [out] Satellite type (0...3) */
};
/* Spectrum Data */
struct cxd56_gnss_spectrum_s
{
uint8_t status; /* FFT Sampling Point 0-1 */
uint8_t samplingstep; /* FFT Sampling Step 1-16 */
uint8_t sizemode; /* FFT Sampling Num 0:1024 1:512 2:256 */
uint8_t datacount; /* Spectrum data count */
uint8_t datanum; /* Spectrum data Size */
uint8_t ifgain; /* IfGain 0-15 */
uint16_t dataindex; /* Spectrum data Inex */
uint16_t spectrum[CXD56_GNSS_SPECTRUM_MAXNUM]; /* Spectrum Data Buffer */
double peak[CXD56_GNSS_PEAK_SPECTRUM_MAXNUM]; /* Peak Spectrum */
};
#define CXD56_GNSS_SBAS_MESSAGE_DATA_LEN (27)
/* SBAS Data */
struct cxd56_gnss_sbasdata_s
{
uint64_t timesnow; /* system now times */
uint32_t gpstow; /* GPS Time of Week */
uint16_t gpswn; /* GPS week number */
uint16_t svid; /* satellite id */
uint8_t msgid; /* sbas message ID */
uint8_t sbasmsg[CXD56_GNSS_SBAS_MESSAGE_DATA_LEN]; /* sbas message data */
};
/******** PVTLog Parameter ***********/
/* Latitude of PVT data */
struct cxd56_pvtlog_latitude_s
{
uint32_t frac :14; /* Decimal */
uint32_t minute :6; /* Minute */
uint32_t degree :7; /* Degree */
uint32_t sign :1; /* Sign */
uint32_t rsv :4; /* Reserved */
};
/* Longitude of PVT data */
struct cxd56_pvtlog_longitude_s
{
uint32_t frac :14; /* Decimal */
uint32_t minute :6; /* Minute */
uint32_t degree :8; /* Degree */
uint32_t sign :1; /* Sign */
uint32_t rsv :3; /* Reserved */
};
/* Altitude of PVT data */
struct cxd56_pvtlog_altitude_s
{
uint32_t frac :4; /* Decimal */
uint32_t rsv1 :12; /* Reserved */
uint32_t meter :14; /* Integer */
uint32_t sign :1; /* Sign */
uint32_t rsv2 :1; /* Reserved */
};
/* Velocity of PVT data */
struct cxd56_pvtlog_velocity_s
{
uint16_t knot :14; /* Integer */
uint16_t rsv :2; /* Reserved */
};
/* Direction of PVT data */
struct cxd56_pvtlog_direction_s
{
uint16_t frac :4; /* Decimal */
uint16_t degree :9; /* Integer */
uint16_t rsv :3; /* Reserved */
};
/* Time (UTC) of PVT data */
struct cxd56_pvtlog_time_s
{
uint32_t msec :7; /* msec */
uint32_t rsv1 :1; /* Reserved */
uint32_t sec :6; /* Second */
uint32_t rsv2 :2; /* Reserved */
uint32_t minute :6; /* Minute */
uint32_t rsv3 :2; /* Reserved */
uint32_t hour :5; /* Hour */
uint32_t rsv4 :3; /* Reserved */
};
/* Date (UTC) of PVT data */
struct cxd56_pvtlog_date_s
{
uint32_t year :7; /* Year */
uint32_t day :5; /* Day */
uint32_t month :4; /* Month */
uint32_t rsv :16; /* Reserved */
};
/* PVTLog save data struct */
struct cxd56_pvtlog_data_s
{
struct cxd56_pvtlog_latitude_s latitude; /* Latitude of data 4B */
struct cxd56_pvtlog_longitude_s longitude; /* Longitude of data 4B */
struct cxd56_pvtlog_altitude_s altitude; /* Altitude of data 4B */
struct cxd56_pvtlog_velocity_s velocity; /* Velocity of data 2B */
struct cxd56_pvtlog_direction_s direction; /* Direction of data 2B */
struct cxd56_pvtlog_time_s time; /* Time (UTC) 4B */
struct cxd56_pvtlog_date_s date; /* Date (UTC) 4B */
};
/* PVTLog notification data struct */
struct cxd56_pvtlog_s
{
uint32_t log_count; /* [in] Valid log count of log_data */
struct cxd56_pvtlog_data_s log_data[CXD56_GNSS_PVTLOG_MAXNUM]; /* [in] Stored log data */
};
/* PVTLog Status Data */
struct cxd56_gnss_status_s
{
uint32_t log_count; /* [in] Saved log count */
struct cxd56_pvtlog_time_s start_time; /* [in] Time (UTC) 4B */
struct cxd56_pvtlog_date_s start_date; /* [in] Date (UTC) 4B */
struct cxd56_pvtlog_time_s end_time; /* [in] Time (UTC) 4B */
struct cxd56_pvtlog_date_s end_date; /* [in] Date (UTC) 4B */
};
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* ARCH_ARM_INCLUDE_CXD56XX_GNSS_TYPE_H */

View File

@ -0,0 +1,68 @@
/****************************************************************************
* arch/arm/include/cxd56xx/cxd56_uart0.h
*
* Copyright 2018 Sony Semiconductor Solutions Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name of Sony Semiconductor Solutions Corporation nor
* the names of its contributors may be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
#ifndef __ARM_ARCH_INCLUDE_CXD56XX_CXD56_UART0_H
#define __ARM_ARCH_INCLUDE_CXD56XX_CXD56_UART0_H
/****************************************************************************
* Public Types
****************************************************************************/
#ifndef __ASSEMBLY__
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
int cxd56_uart0initialize(FAR const char *devname);
void cxd56_uart0uninitialize(FAR const char *devname);
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* __ASSEMBLY__ */
#endif /* __ARM_ARCH_INCLUDE_CXD56XX_CXD56_UART0_H */

View File

@ -224,6 +224,46 @@ config CXD56_GPIO_IRQ
---help---
Enable support for GPIO interrupts
config CXD56_UART0
bool "UART0"
default n
---help---
UART interface with hardware flow control in the application subsystem.
if CXD56_UART0
config CXD56_UART0_BAUD
int "CXD56 UART0 BAUD"
default 921600
config CXD56_UART0_PARITY
int "CXd56 UART0 parity"
default 0
range 0 2
---help---
CXD56 UART0 parity. 0=None, 1=Odd, 2=Even. Default: None
config CXD56_UART0_BITS
int "CXD56 UART0 number of bits"
default 8
range 5 8
---help---
CXD56 UART0 number of bits. Default: 8
config CXD56_UART0_2STOP
int "CXD56 UART0 two stop bits"
default 0
---help---
0=1 stop bit, 1=Two stop bits. Default: 1 stop bit
config CXD56_UART0_FLOWCONTROL
bool "CXD56 UART0 flow control"
default n
---help---
Enable CXD56 UART0 RTS flow control
endif
config CXD56_UART1
bool "UART1"
default y
@ -1183,4 +1223,71 @@ config CXD56_GE2D
default n
---help---
A hardware image processor device.
config CXD56_GNSS
bool "GNSS device"
default n
if CXD56_GNSS
menu "GNSS settings"
config CXD56_GNSS_NPOLLWAITERS
int "GNSS max poll waiters"
default 4
config CXD56_GNSS_NSIGNALRECEIVERS
int "GNSS max signal receivers"
default 4
config CXD56_GNSS_WORKER_STACKSIZE
int "GNSS worker thread stack size"
default 128
config CXD56_GNSS_WORKER_THREAD_PRIORITY
int "GNSS worker thread priority"
default 255
config CXD56_GNSS_BACKUP_FILENAME
string "GNSS backup file name"
default "/mnt/spif/gnss_backup.bin"
---help---
Specify the path and file name of backup data.
config CXD56_GNSS_CEP_FILENAME
string "GNSS CEP file name"
default "/mnt/sd0/gnss_cep.bin"
---help---
Specify the path and file name of cep data.
config CXD56_GNSS_FW_RTK
bool "Support carrier-phase data output for Real-Time Kinematic"
default n
---help---
This is experimental function.
config CXD56_GNSS_DEBUG_FEATURE
bool "GNSS debug feature"
if CXD56_GNSS_DEBUG_FEATURE
config CXD56_GNSS_DEBUG_ERROR
bool "GNSS debug error"
config CXD56_GNSS_DEBUG_WARN
bool "GNSS debug warn"
config CXD56_GNSS_DEBUG_INFO
bool "GNSS debug info"
endif # CXD56_GNSS_DEBUG_FEATURE
endmenu
config CXD56_GEOFENCE
bool "Geofence Support"
default y
depends on CXD56_GNSS
endif
endmenu

View File

@ -101,6 +101,10 @@ CHIP_CSRCS += cxd56_powermgr.c
CHIP_CSRCS += cxd56_farapi.c
CHIP_CSRCS += cxd56_sysctl.c
ifeq ($(CONFIG_CXD56_UART0),y)
CHIP_CSRCS += cxd56_uart0.c
endif
ifeq ($(CONFIG_CXD56_PM_PROCFS),y)
CHIP_CSRCS += cxd56_powermgr_procfs.c
endif
@ -181,3 +185,12 @@ endif
ifeq ($(CONFIG_CXD56_WDT),y)
CHIP_CSRCS += cxd56_wdt.c
endif
ifeq ($(CONFIG_CXD56_GNSS),y)
CHIP_CSRCS += cxd56_gnss.c
CHIP_CSRCS += cxd56_cpu1signal.c
endif
ifeq ($(CONFIG_CXD56_GEOFENCE),y)
CHIP_CSRCS += cxd56_geofence.c
endif

View File

@ -0,0 +1,281 @@
/****************************************************************************
* arch/arm/src/cxd56xx/cxd56_cpu1signal.c
*
* Copyright 2018 Sony Semiconductor Solutions Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name of Sony Semiconductor Solutions Corporation nor
* the names of its contributors may be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdlib.h>
#include <errno.h>
#include <sched.h>
#include <pthread.h>
#include <debug.h>
#include "cxd56_icc.h"
#include "cxd56_cpu1signal.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#ifndef CONFIG_CXD56CPU1_WORKER_STACKSIZE
# define CONFIG_CXD56CPU1_WORKER_STACKSIZE 1024
#endif
#ifndef CONFIG_CXD56CPU1_WORKER_THREAD_PRIORITY
# define CONFIG_CXD56CPU1_WORKER_THREAD_PRIORITY (SCHED_PRIORITY_MAX)
#endif
#define CXD56CPU1_CPUID 1
/****************************************************************************
* Private Type
****************************************************************************/
struct cxd56_sigtype_s
{
int use;
cxd56_cpu1sighandler_t handler;
FAR void * data;
};
struct cxd56cpu1_info_s
{
pthread_t workertid;
int ndev;
struct cxd56_sigtype_s sigtype[CXD56_CPU1_DATA_TYPE_MAX];
};
/****************************************************************************
* Private Data
****************************************************************************/
static struct cxd56cpu1_info_s g_cpu1_info = {0};
/****************************************************************************
* Private Functions
****************************************************************************/
static FAR void *cxd56cpu1_worker(FAR void *arg)
{
struct cxd56cpu1_info_s *priv = (struct cxd56cpu1_info_s *)arg;
iccmsg_t msg;
uint8_t sigtype;
int ret;
msg.cpuid = CXD56CPU1_CPUID;
while (1)
{
ret = cxd56_iccrecvmsg(&msg, 0);
if (ret < 0)
{
continue;
}
sigtype = (uint8_t)CXD56_CPU1_GET_DEV(msg.data);
if (sigtype >= CXD56_CPU1_DATA_TYPE_MAX)
{
_info("Caught invalid sigtype %d.\n", sigtype);
continue;
}
if (priv->sigtype[sigtype].handler)
{
priv->sigtype[sigtype].handler(msg.data,
priv->sigtype[sigtype].data);
}
}
return arg;
}
/****************************************************************************
* Public Functions
****************************************************************************/
int cxd56_cpu1sigsend(uint8_t sigtype, uint32_t data)
{
iccmsg_t msg;
msg.cpuid = CXD56CPU1_CPUID;
msg.msgid = sigtype;
msg.data = data;
return cxd56_iccsend(CXD56_PROTO_GNSS, &msg, 0);
}
void cxd56_cpu1sigregisterhandler(uint8_t sigtype,
cxd56_cpu1sighandler_t handler)
{
struct cxd56cpu1_info_s *priv = &g_cpu1_info;
if (sigtype >= CXD56_CPU1_DATA_TYPE_MAX)
{
return;
}
priv->sigtype[sigtype].handler = handler;
}
void cxd56_cpu1sigunregisterhandler(uint8_t sigtype)
{
struct cxd56cpu1_info_s *priv = &g_cpu1_info;
if (sigtype >= CXD56_CPU1_DATA_TYPE_MAX)
{
return;
}
priv->sigtype[sigtype].handler = NULL;
}
int cxd56_cpu1siginit(uint8_t sigtype, FAR void *data)
{
struct cxd56cpu1_info_s *priv = &g_cpu1_info;
pthread_attr_t tattr;
struct sched_param param;
pthread_t tid;
int ret;
if (sigtype >= CXD56_CPU1_DATA_TYPE_MAX)
{
return -ENODEV;
}
sched_lock();
if (priv->sigtype[sigtype].use)
{
ret = -EBUSY;
goto _err1;
}
priv->sigtype[sigtype].use = true;
priv->sigtype[sigtype].data = data;
if (priv->ndev > 0)
{
ret = OK;
goto _err1;
}
priv->ndev++;
sched_unlock();
cxd56_iccinit(CXD56_PROTO_GNSS);
ret = cxd56_iccinitmsg(CXD56CPU1_CPUID);
if (ret < 0)
{
_err("Failed to initialize ICC for GPS CPU: %d\n", ret);
goto _err0;
}
pthread_attr_init(&tattr);
tattr.stacksize = CONFIG_CXD56CPU1_WORKER_STACKSIZE;
param.sched_priority = CONFIG_CXD56CPU1_WORKER_THREAD_PRIORITY;
pthread_attr_setschedparam(&tattr, &param);
ret = pthread_create(&tid, &tattr, cxd56cpu1_worker,
(pthread_addr_t)priv);
if (ret != 0)
{
cxd56_iccuninitmsg(CXD56CPU1_CPUID);
ret = -ret; /* pthread_create does not modify errno. */
goto _err0;
}
priv->workertid = tid;
return ret;
_err0:
priv->sigtype[sigtype].use = false;
priv->sigtype[sigtype].data = NULL;
return ret;
_err1:
sched_unlock();
return ret;
}
int cxd56_cpu1siguninit(uint8_t sigtype)
{
struct cxd56cpu1_info_s *priv = &g_cpu1_info;
pthread_t tid;
int ret;
if (sigtype >= CXD56_CPU1_DATA_TYPE_MAX)
{
return -ENODEV;
}
sched_lock();
if (!priv->sigtype[sigtype].use)
{
ret = -EBUSY;
goto _err1;
}
priv->ndev--;
priv->sigtype[sigtype].use = false;
priv->sigtype[sigtype].data = NULL;
if (priv->ndev > 0)
{
ret = OK;
goto _err0;
}
tid = priv->workertid;
priv->workertid = 0;
sched_unlock();
pthread_cancel(tid);
pthread_join(tid, NULL);
cxd56_iccuninit(CXD56CPU1_CPUID);
return 0;
_err1:
sched_unlock();
_err0:
return ret;
}

View File

@ -0,0 +1,81 @@
/****************************************************************************
* arch/arm/src/cxd56xx/cxd56_cpu1signal.h
*
* Copyright 2018 Sony Semiconductor Solutions Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name of Sony Semiconductor Solutions Corporation nor
* the names of its contributors may be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
#ifndef __ARCH_ARM_SRC_CXD56XX_CXD56_CPU1SIGNAL_H
#define __ARCH_ARM_SRC_CXD56XX_CXD56_CPU1SIGNAL_H
/* CPU1 Notifyable functions */
#define CXD56_CPU1_DATA_TYPE_GNSS 0
#define CXD56_CPU1_DATA_TYPE_GEOFENCE 1
#define CXD56_CPU1_DATA_TYPE_PVTLOG 2
#define CXD56_CPU1_DATA_TYPE_AGPS 3
#define CXD56_CPU1_DATA_TYPE_RTK 4
#define CXD56_CPU1_DATA_TYPE_SPECTRUM 5
#define CXD56_CPU1_DATA_TYPE_INFO 6
#define CXD56_CPU1_DATA_TYPE_BACKUP 7
#define CXD56_CPU1_DATA_TYPE_CEP 8
#define CXD56_CPU1_DATA_TYPE_CEPFILE 9
#define CXD56_CPU1_DATA_TYPE_BKUPFILE 10
#define CXD56_CPU1_DATA_TYPE_GPSEPHEMERIS 11
#define CXD56_CPU1_DATA_TYPE_GLNEPHEMERIS 12
#define CXD56_CPU1_DATA_TYPE_CPUFIFOAPI 13
#define CXD56_CPU1_DATA_TYPE_SBAS 14
#define CXD56_CPU1_DATA_TYPE_DCREPORT 15
#define CXD56_CPU1_DATA_TYPE_MAX 16
/* CPU1 devices */
#define CXD56_CPU1_DEV_GNSS (CXD56_CPU1_DATA_TYPE_GNSS)
#define CXD56_CPU1_DEV_GEOFENCE (CXD56_CPU1_DATA_TYPE_GEOFENCE)
#define CXD56_CPU1_DEV_MASK 0xff
#define CXD56_CPU1_GET_DEV(DATA) ((DATA) & CXD56_CPU1_DEV_MASK)
#define CXD56_CPU1_GET_DATA(DATA) ((DATA) >> 8)
#if CXD56_CPU1_DATA_TYPE_MAX > (CXD56_CPU1_DEV_MASK + 1)
#error "CXD56_CPU1_DEV must be smaller than 0xf"
#endif
typedef void (*cxd56_cpu1sighandler_t)(uint32_t data, FAR void *userdata);
extern int cxd56_cpu1siginit(uint8_t cpu1dev, FAR void *data);
extern int cxd56_cpu1siguninit(uint8_t cpu1dev);
extern void cxd56_cpu1sigregisterhandler(uint8_t cpu1dev,
cxd56_cpu1sighandler_t handler);
extern void cxd56_cpu1sigunregisterhandler(uint8_t cpu1dev);
extern int cxd56_cpu1sigsend(uint8_t sigtype, uint32_t data);
#endif /* __ARCH_ARM_SRC_CXD56XX_CXD56_CPU1SIGNAL_H */

View File

@ -0,0 +1,777 @@
/****************************************************************************
* arch/arm/src/cxd56xx/cxd56_geofence.c
*
* Copyright 2018 Sony Semiconductor Solutions Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name of Sony Semiconductor Solutions Corporation nor
* the names of its contributors may be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fixedmath.h>
#include <poll.h>
#include <errno.h>
#include <debug.h>
#include <nuttx/kmalloc.h>
#include <nuttx/fs/fs.h>
#include <nuttx/board.h>
#include <nuttx/spi/spi.h>
#include <arch/chip/geofence.h>
#include "cxd56_gnss_api.h"
#include "cxd56_cpu1signal.h"
#include "cxd56_gnss.h"
#if defined(CONFIG_CXD56_GEOFENCE)
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#ifndef CONFIG_GEOFENCE_NPOLLWAITERS
# define CONFIG_GEOFENCE_NPOLLWAITERS 4
#endif
/****************************************************************************
* Private Types
****************************************************************************/
struct cxd56_geofence_dev_s
{
sem_t devsem;
FAR struct pollfd *fds[CONFIG_GEOFENCE_NPOLLWAITERS];
};
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
/* file operation functions */
static int cxd56_geofence_open(FAR struct file *filep);
static int cxd56_geofence_close(FAR struct file *filep);
static ssize_t cxd56_geofence_read(FAR struct file *filep, FAR char *buffer,
size_t len);
static int cxd56_geofence_ioctl(FAR struct file *filep, int cmd,
unsigned long arg);
#ifndef CONFIG_DISABLE_POLL
static int cxd56_geofence_poll(FAR struct file *filep, FAR struct pollfd *fds,
bool setup);
#endif
/* ioctl command functions */
static int cxd56_geofence_start(unsigned long arg);
static int cxd56_geofence_stop(unsigned long arg);
static int cxd56_geofence_add_region(unsigned long arg);
static int cxd56_geofence_modify_region(unsigned long arg);
static int cxd56_geofence_delete_region(unsigned long arg);
static int cxd56_geofence_delete_all_region(unsigned long arg);
static int cxd56_geofence_get_region_data(unsigned long arg);
static int cxd56_geofence_get_used_id(unsigned long arg);
static int cxd56_geofence_get_all_status(unsigned long arg);
static int cxd56_geofence_set_mode(unsigned long arg);
/****************************************************************************
* Private Data
****************************************************************************/
/* This the vtable that supports the character driver interface */
static const struct file_operations g_geofencefops =
{
cxd56_geofence_open, /* open */
cxd56_geofence_close, /* close */
cxd56_geofence_read, /* read */
0, /* write */
0, /* seek */
cxd56_geofence_ioctl, /* ioctl */
#ifndef CONFIG_DISABLE_POLL
cxd56_geofence_poll, /* poll */
#endif
};
/* ioctl command list */
FAR static int (*g_cmdlist[CXD56_GEOFENCE_IOCTL_MAX])(unsigned long) =
{
NULL, /* CXD56_GEOFENCE_IOCTL_INVAL = 0 */
cxd56_geofence_start,
cxd56_geofence_stop,
cxd56_geofence_add_region,
cxd56_geofence_modify_region,
cxd56_geofence_delete_region,
cxd56_geofence_delete_all_region,
cxd56_geofence_get_region_data,
cxd56_geofence_get_used_id,
cxd56_geofence_get_all_status,
cxd56_geofence_set_mode,
/* max CXD56_GEOFENCE_IOCTL_MAX */
};
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: cxd56_geofence_start
*
* Description:
* Process CXD56_GEOFENCE_IOCTL_START command.
* Start GEOFENCE Detect
*
* Input Parameters:
* arg - Data for command
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
static int cxd56_geofence_start(unsigned long arg)
{
return GD_RegisterGeofence();
}
/****************************************************************************
* Name: cxd56_geofence_stop
*
* Description:
* Process CXD56_GEOFENCE_IOCTL_STOP command.
* Stop GEOFENCE Detect
*
* Input Parameters:
* arg - Data for command
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
static int cxd56_geofence_stop(unsigned long arg)
{
return GD_ReleaseGeofence();
}
/****************************************************************************
* Name: cxd56_geofence_add_region
*
* Description:
* Process CXD56_GEOFENCE_IOCTL_ADD command.
* Add region
*
* Input Parameters:
* arg - Data for command
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
static int cxd56_geofence_add_region(unsigned long arg)
{
int ret;
FAR struct cxd56_geofence_region_s *reg_data;
if (!arg)
{
return -EINVAL;
}
reg_data = (FAR struct cxd56_geofence_region_s *)arg;
ret = GD_GeoAddRegion(reg_data->id, reg_data->latitude, reg_data->longitude,
reg_data->radius);
return ret;
}
/****************************************************************************
* Name: cxd56_geofence_modify_region
*
* Description:
* Process CXD56_GEOFENCE_IOCTL_MODIFY command.
* Modify region
*
* Input Parameters:
* arg - Data for command
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
static int cxd56_geofence_modify_region(unsigned long arg)
{
int ret;
FAR struct cxd56_geofence_region_s *reg_data;
if (!arg)
{
return -EINVAL;
}
reg_data = (FAR struct cxd56_geofence_region_s *)arg;
ret = GD_GeoModifyRegion(reg_data->id, reg_data->latitude,
reg_data->longitude, reg_data->radius);
return ret;
}
/****************************************************************************
* Name: cxd56_geofence_delete_region
*
* Description:
* Process CXD56_GEOFENCE_IOCTL_DELETE command.
* Delete region
*
* Input Parameters:
* arg - Data for command
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
static int cxd56_geofence_delete_region(unsigned long arg)
{
int ret;
FAR uint8_t id;
if (UINT8_MAX < arg)
{
return -EINVAL;
}
id = (uint8_t)arg;
ret = GD_GeoDeleteRegione(id);
return ret;
}
/****************************************************************************
* Name: cxd56_geofence_delete_all_region
*
* Description:
* Process CXD56_GEOFENCE_IOCTL_ALL_DELETE command.
* All delete region
*
* Input Parameters:
* arg - Data for command
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
static int cxd56_geofence_delete_all_region(unsigned long arg)
{
int ret;
ret = GD_GeoDeleteAllRegion();
return ret;
}
/****************************************************************************
* Name: cxd56_geofence_get_region_data
*
* Description:
* Process CXD56_GEOFENCE_IOCTL_GET_REGION_DATA command.
* Get used region ID
*
* Input Parameters:
* arg - Data for command
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
static int cxd56_geofence_get_region_data(unsigned long arg)
{
int ret;
FAR struct cxd56_geofence_region_s *reg_data;
if (!arg)
{
return -EINVAL;
}
reg_data = (FAR struct cxd56_geofence_region_s *)arg;
ret = GD_GeoGetRegionData(reg_data->id, &reg_data->latitude,
&reg_data->longitude, &reg_data->radius);
return ret;
}
/****************************************************************************
* Name: cxd56_geofence_get_used_id
*
* Description:
* Process CXD56_GEOFENCE_IOCTL_GET_USED_ID command.
* Get used region ID
*
* Input Parameters:
* arg - Data for command
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
static int cxd56_geofence_get_used_id(unsigned long arg)
{
if (!arg)
{
return -EINVAL;
}
*(uint32_t *)arg = GD_GeoGetUsedRegionId();
return 0;
}
/****************************************************************************
* Name: cxd56_geofence_get_all_status
*
* Description:
* Process CXD56_GEOFENCE_IOCTL_GET_ALL_STATUS command.
* Get All transition status
*
* Input Parameters:
* arg - Data for command
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
static int cxd56_geofence_get_all_status(unsigned long arg)
{
int ret;
ret = GD_GeoSetAllRgionNotifyRequest();
return ret;
}
/****************************************************************************
* Name: cxd56_geofence_set_mode
*
* Description:
* Process CXD56_GEOFENCE_IOCTL_SET_MODE command.
* Set geofence operation mode
*
* Input Parameters:
* arg - Data for command
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
static int cxd56_geofence_set_mode(unsigned long arg)
{
int ret;
FAR struct cxd56_geofence_mode_s *mode;
if (!arg)
{
return -EINVAL;
}
mode = (FAR struct cxd56_geofence_mode_s *)arg;
ret = GD_GeoSetOpMode(mode->deadzone, mode->dwell_detecttime);
return ret;
}
/****************************************************************************
* Name: cxd56_geofence_sighandler
*
* Description:
* Common signal handler from GNSS CPU.
*
* Input Parameters:
* data - Received data from GNSS CPU
* userdata - User data, this is the device information specified by the
* second argument of the function cxd56_cpu1siginit.
*
* Returned Value:
* None
*
****************************************************************************/
static void cxd56_geofence_sighandler(uint32_t data, FAR void *userdata)
{
FAR struct cxd56_geofence_dev_s *priv =
(FAR struct cxd56_geofence_dev_s *)userdata;
int i;
int ret;
ret = sem_wait(&priv->devsem);
if (ret < 0)
{
return;
}
for (i = 0; i < CONFIG_GEOFENCE_NPOLLWAITERS; i++)
{
struct pollfd *fds = priv->fds[i];
if (fds)
{
fds->revents |= POLLIN;
gnssinfo("Report events: %02x\n", fds->revents);
sem_post(fds->sem);
}
}
sem_post(&priv->devsem);
}
/****************************************************************************
* Name: cxd56_geofence_initialize
*
* Description:
* initialize GEOFENCE device
*
* Input Parameters:
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
static int cxd56_geofence_initialize(FAR struct cxd56_geofence_dev_s* dev)
{
int32_t ret = 0;
return ret;
}
/****************************************************************************
* Name: cxd56_geofence_open
*
* Description:
* Standard character driver open method.
*
* Input Parameters:
* filep - File structure pointer
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
static int cxd56_geofence_open(FAR struct file *filep)
{
int32_t ret = 0;
return ret;
}
/****************************************************************************
* Name: cxd56_geofence_close
*
* Description:
* Standard character driver close method.
*
* Input Parameters:
* filep - File structure pointer
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
static int cxd56_geofence_close(FAR struct file *filep)
{
int32_t ret = 0;
return ret;
}
/****************************************************************************
* Name: cxd56_geofence_read
*
* Description:
* Standard character driver read method.
*
* Input Parameters:
* filep - File structure pointer
* buffer - Buffer to write
* buflen - The write length of the buffer
*
* Returned Value:
* Always returns -ENOENT error.
*
****************************************************************************/
static ssize_t cxd56_geofence_read(FAR struct file *filep, FAR char *buffer,
size_t len)
{
int32_t ret = 0;
/* Check argument */
if (!buffer)
{
ret = -EINVAL;
goto _err;
}
if (len == 0)
{
ret = 0;
goto _err;
}
/* GD_ReadBuffer returns copied data size or negative error code */
ret = GD_ReadBuffer(CXD56_CPU1_DEV_GEOFENCE, 0, buffer, len);
_err:
return ret;
}
/****************************************************************************
* Name: cxd56_geofence_ioctl
*
* Description:
* Standard character driver ioctl method.
*
* Input Parameters:
* filep - File structure pointer
* fds - Array of file descriptor
* setup - 1 if start poll, 0 if stop poll
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
static int cxd56_geofence_ioctl(FAR struct file *filep, int cmd,
unsigned long arg)
{
if (cmd <= CXD56_GEOFENCE_IOCTL_INVAL || cmd >= CXD56_GEOFENCE_IOCTL_MAX)
{
return -EINVAL;
}
return g_cmdlist[cmd](arg);
}
/****************************************************************************
* Name: cxd56_geofence_poll
*
* Description:
* Standard character driver poll method.
*
* Input Parameters:
* filep - File structure pointer
* fds - array of file descriptor
* setup - 1 if start poll, 0 if stop poll
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
#ifndef CONFIG_DISABLE_POLL
static int cxd56_geofence_poll(FAR struct file *filep, FAR struct pollfd *fds,
bool setup)
{
FAR struct inode * inode;
FAR struct cxd56_geofence_dev_s *priv;
int ret = OK;
int i;
inode = filep->f_inode;
priv = (FAR struct cxd56_geofence_dev_s *)inode->i_private;
ret = sem_wait(&priv->devsem);
if (ret < 0)
{
return ret;
}
if (setup)
{
if ((fds->events & POLLIN) == 0)
{
ret = -EDEADLK;
goto errout;
}
for (i = 0; i < CONFIG_GEOFENCE_NPOLLWAITERS; i++)
{
/* Find an unused slot */
if (priv->fds[i] == NULL)
{
/* Bind the poll structure and this slot */
priv->fds[i] = fds;
fds->priv = &priv->fds[i];
GD_SetNotifyMask(CXD56_CPU1_DEV_GEOFENCE, FALSE);
break;
}
}
/* No space in priv fds array for poll handling */
if (i >= CONFIG_GEOFENCE_NPOLLWAITERS)
{
fds->priv = NULL;
ret = -EBUSY;
goto errout;
}
}
else if (fds->priv)
{
/* This is a request to tear down the poll. */
struct pollfd **slot = (struct pollfd **)fds->priv;
/* Remove all memory of the poll setup */
*slot = NULL;
fds->priv = NULL;
}
errout:
sem_post(&priv->devsem);
return ret;
}
#endif
/****************************************************************************
* Name: cxd56_geofence_register
*
* Description:
* Register the GEOFENCE character device as 'devpath'
*
* Input Parameters:
* devpath - The full path to the driver to register. E.g., "/dev/geofence"
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
static int cxd56_geofence_register(FAR const char *devpath)
{
FAR struct cxd56_geofence_dev_s *priv;
int ret;
priv = (FAR struct cxd56_geofence_dev_s *)kmm_malloc(
sizeof(struct cxd56_geofence_dev_s));
if (!priv)
{
gnsserr("Failed to allocate instance\n");
return -ENOMEM;
}
memset(priv, 0, sizeof(struct cxd56_geofence_dev_s));
sem_init(&priv->devsem, 0, 1);
ret = cxd56_geofence_initialize(priv);
if (ret < 0)
{
gnsserr("Failed to initialize geofence device!\n");
goto _err0;
}
ret = register_driver(devpath, &g_geofencefops, 0666, priv);
if (ret < 0)
{
gnsserr("Failed to register driver: %d\n", ret);
goto _err0;
}
ret = cxd56_cpu1siginit(CXD56_CPU1_DEV_GEOFENCE, priv);
if (ret < 0)
{
gnsserr("Failed to initialize ICC for GPS CPU: %d\n", ret);
goto _err2;
}
cxd56_cpu1sigregisterhandler(CXD56_CPU1_DEV_GEOFENCE,
cxd56_geofence_sighandler);
gnssinfo("GEOFENCE driver loaded successfully!\n");
return ret;
_err2:
unregister_driver(devpath);
_err0:
kmm_free(priv);
return ret;
}
/****************************************************************************
* Name: cxd56_geofenceinitialize
*
* Description:
* Initialize GEOFENCE device
*
* Input Parameters:
* devpath - The full path to the driver to register. E.g., "/dev/geofence"
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
int cxd56_geofenceinitialize(FAR const char *devpath)
{
int ret;
gnssinfo("Initializing GEOFENCE..\n");
ret = cxd56_geofence_register(devpath);
if (ret < 0)
{
gnsserr("Error registering GEOFENCE\n");
}
return ret;
}
#endif

View File

@ -0,0 +1,86 @@
/****************************************************************************
* arch/arm/src/cxd56xx/cxd56_geofence.h
*
* Copyright 2018 Sony Semiconductor Solutions Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name of Sony Semiconductor Solutions Corporation nor
* the names of its contributors may be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
#ifndef __ARCH_ARM_SRC_CXD56XX_CXD56_GEOFENCE_H
#define __ARCH_ARM_SRC_CXD56XX_CXD56_GEOFENCE_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#ifndef __ASSEMBLY__
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: cxd56_geofenceinitialize
*
* Description:
* Initialize GEOFENCE device
*
* Input Parameters:
* devpath - The full path to the driver to register. E.g., "/dev/geofence"
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
int cxd56_geofenceinitialize(FAR const char *devpath);
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* __ASSEMBLY__ */
#endif /* __ARCH_ARM_SRC_CXD56XX_CXD56_GEOFENCE_H */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,108 @@
/****************************************************************************
* arch/arm/src/cxd56xx/cxd56_gnss.h
*
* Copyright 2018 Sony Semiconductor Solutions Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name of Sony Semiconductor Solutions Corporation nor
* the names of its contributors may be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
#ifndef __ARCH_ARM_SRC_CXD56XX_CXD56_GNSS_H
#define __ARCH_ARM_SRC_CXD56XX_CXD56_GNSS_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <debug.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#ifndef __ASSEMBLY__
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/* GNSS specific debug */
#ifdef CONFIG_CXD56_GNSS_DEBUG_ERROR
# define gnsserr(fmt, ...) logerr(fmt, ## __VA_ARGS__)
#else
# define gnsserr(fmt, ...)
#endif
#ifdef CONFIG_CXD56_GNSS_DEBUG_WARN
# define gnsswarn(fmt, ...) logwarn(fmt, ## __VA_ARGS__)
#else
# define gnsswarn(fmt, ...)
#endif
#ifdef CONFIG_CXD56_GNSS_DEBUG_INFO
# define gnssinfo(fmt, ...) loginfo(fmt, ## __VA_ARGS__)
#else
# define gnssinfo(fmt, ...)
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: cxd56_gnssinitialize
*
* Description:
* Initialize GNSS device
*
* Input Parameters:
* devpath - The full path to the driver to register. E.g., "/dev/gps"
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
int cxd56_gnssinitialize(FAR const char *devpath);
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* __ASSEMBLY__ */
#endif /* __ARCH_ARM_SRC_CXD56XX_CXD56_GNSS_H */

View File

@ -0,0 +1,356 @@
/****************************************************************************
* arch/arm/src/cxd56xx/cxd56_gnss_api.h
*
* Copyright 2018 Sony Semiconductor Solutions Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name of Sony Semiconductor Solutions Corporation nor
* the names of its contributors may be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
#ifndef __ARCH_ARM_SRC_CXD56XX_CXD56_GNSS_API_H
#define __ARCH_ARM_SRC_CXD56XX_CXD56_GNSS_API_H
#include <arch/chip/gnss_type.h>
#include <arch/chip/gnss.h>
/* GD Start mode */
#define CXD56_GNSS_STMOD_COLD 0
#define CXD56_GNSS_STMOD_WARM 1
#define CXD56_GNSS_STMOD_WARMACC2 2
#define CXD56_GNSS_STMOD_HOT 3
#define CXD56_GNSS_STMOD_HOTACC 4
#define CXD56_GNSS_STMOD_HOTACC2 5
#define CXD56_GNSS_STMOD_HOTACC3 6
#define CXD56_GNSS_STMOD_XTC1 7
#define CXD56_GNSS_STMOD_XTC2 8
/* GD operation mode */
/* GD_SetOperationMode, GD_GetOperationMode */
#define CXD56_GNSS_OPMOD_NORMAL 1
#define CXD56_GNSS_OPMOD_LOWPOWER 2
#define CXD56_GNSS_OPMOD_BALANCE 4
#define CXD56_GNSS_OPMOD_1PSS 5
/* Start a positioning
* begining to search the satellites and measure the receiver position
*/
int GD_Start(uint8_t startMode);
/* Stop a positioning */
int GD_Stop(void);
/* Select GNSSs to positioning
* These are able to specified by CXD56_GNSS_B_SAT_XXX defines.
*/
int GD_SelectSatelliteSystem(uint32_t system);
/* Get current using GNSSs to positioning
* A argument 'satellite' indicates current GNSSs by bit fields defined
* by CXD56_GNSS_B_SAT_XXX.
*/
int GD_GetSatelliteSystem(FAR uint32_t *system);
/* Set the rough receiver position */
int GD_SetReceiverPositionEllipsoidal(FAR double *dLat, FAR double *dLon,
FAR double *dHeight);
/* Set the rough receiver position as orgothonal */
int GD_SetReceiverPositionOrthogonal(int32_t dX, int32_t dY, int32_t dZ);
/* Set enable or disable the 1PPS output. */
int GD_Set1ppsOutput(uint32_t enable);
/* Get the current 1PPS output setting. */
int GD_Get1ppsOutput(FAR uint32_t *enable);
/* Set the receiver operation mode
* 1st argument 'mode' is a operation mode defined by CXD56_GNSS_OPMOD_XXX.
* 2nd argument 'cycle' is a positioning period[ms], default is 1000[ms].
*/
int GD_SetOperationMode(uint32_t mode, uint32_t cycle);
/* Get the receiver operation mode */
int GD_GetOperationMode(FAR uint32_t *mode, FAR uint32_t *cycle);
/* Set the TCXO offset */
int GD_SetTcxoOffset(int32_t offset);
/* Get the TCXO offset */
int GD_GetTcxoOffset(FAR int32_t *offset);
/* Set the estimated current time of the receiver.
* 1st argument date & time are in UTC.
*/
int GD_SetTime(FAR struct cxd56_gnss_date_s *date,
FAR struct cxd56_gnss_time_s *time);
/* Set the network time */
int GD_SetFrameTime(uint16_t sec, uint32_t fracSec);
/* Get the almanac data */
int GD_GetAlmanac(uint32_t satellite, FAR uint32_t* almanac,
FAR uint32_t *almanacSize);
/* Set the almanac data */
int GD_SetAlmanac(uint32_t satellite, FAR uint32_t *almanac);
/* Get the Ephemeris data */
int GD_GetEphemeris(uint32_t satellite, FAR uint32_t* ephemeris,
FAR uint32_t *ephemerisSize);
/* Set the Ephemeris data */
int GD_SetEphemeris(uint32_t satellite, FAR uint32_t *ephemeris);
/* Select to use or not use the initial position calculation supporting
* information of the QZSS L1-SAIF.
*/
int GD_SetQzssPosAssist(uint32_t enable);
/* Get a setting of the initial position calculation supporting
* information of the QZSS L1-SAIF.
*/
int GD_GetQzssPosAssist(FAR uint32_t *enable);
/* Set IMES bitrates. */
int GD_SetImesBitrate(uint32_t bitrate);
/* Get IMES bitrates. */
int GD_GetImesBitrate(FAR uint32_t *bitrate);
/* Set IMES center frequency offset. */
int GD_SetImesCenterFreqOffset(uint32_t offset);
/* Set IMES preamble. */
int GD_SetImesPreamble(uint32_t preamble);
/* Start GPS test */
void GD_StartGpsTest(uint32_t satellite, uint32_t reserve1,
uint32_t reserve2, uint32_t reserve3);
/* Stop GPS test */
int GD_StopGpsTest(void);
/* Get GPS test result */
int GD_GetGpsTestResult(FAR float* cn, FAR float* doppler);
/* Control Spectrum output */
int GD_SpectrumControl(unsigned long time, unsigned int enable,
unsigned char moniPoint1, unsigned char step1,
unsigned char moniPoint2, unsigned char step2);
/* Save the backup data to a Flash memory. */
int GD_SaveBackupdata(void);
/* CEP Check Assist Data Valid */
int GD_CepCheckAssistData(void);
/* CEP Get Age Data */
int GD_CepGetAgeData(FAR float *age, FAR float *cepi);
/* CEP Reset Assist Data init flag & valid flag */
int GD_CepInitAssistData(void);
/* AGPS Set tau */
int GD_SetTauGps(FAR double *tau);
/* AGPS Set Acquist */
int GD_SetAcquist(FAR uint8_t *pAcquistData, uint16_t acquistSize);
/* Set the estimated current time of the receiver.
* 1st argument date & time are in GPS time.
*/
int GD_SetTimeGps(FAR struct cxd56_gnss_date_s *date,
FAR struct cxd56_gnss_time_s *time);
/* Clear Receiver Infomation */
int GD_ClearReceiverInfo(uint32_t type);
/* AGPS Set Tow Assist */
int GD_SetTowAssist(FAR uint8_t *pAssistData, uint16_t dataSize);
/* AGPS Set UTC Model */
int GD_SetUtcModel(FAR uint8_t *pModelData, uint16_t dataSize);
/* Read GNSS data to specified buffer */
int GD_ReadBuffer(uint8_t type, int32_t offset, FAR void *buf,
uint32_t length);
/* Write GNSS data from specified buffer */
int GD_WriteBuffer(uint8_t type, int32_t offset, FAR void *buf,
uint32_t length);
/* Set notify mask, this mask flag is cleared when notified(poll/signal) */
int GD_SetNotifyMask(uint8_t type, uint8_t clear);
/* Geofence Add Region */
int GD_GeoAddRegion(uint8_t id, long lat, long lon, uint16_t rad);
/* Geofence Modify Region */
int GD_GeoModifyRegion(uint8_t id, long lat, long lon, uint16_t rad);
/* Geofence Delete Region */
int GD_GeoDeleteRegione(uint8_t id);
/* Geofence All delete Region */
int GD_GeoDeleteAllRegion(void);
/* Geofence Region check */
int GD_GeoGetRegionData(uint8_t id, FAR long *lat, FAR long *lon,
FAR uint16_t *rad);
/* Geofence Get Used Region ID */
uint32_t GD_GeoGetUsedRegionId(void);
/* Geofence Set mode */
int GD_GeoSetOpMode(uint16_t deadzone, uint16_t dwell_detecttime);
/* Geofence Request All region notify */
int GD_GeoSetAllRgionNotifyRequest(void);
/* Geofence Register to gnss_provider */
int GD_RegisterGeofence(void);
/* Geofence Release from gnss_provider */
int GD_ReleaseGeofence(void);
/* Pvtlog Register to gnss_provider */
int GD_RegisterPvtlog(uint32_t cycle, uint32_t threshold);
/* Pvtlog Release */
int GD_ReleasePvtlog(void);
/* Pvtlog Delete log data */
int GD_PvtlogDeleteLog(void);
/* Pvtlog Get Log status */
int GD_PvtlogGetLogStatus(FAR struct cxd56_gnss_status_s *pLogStatus);
/* Start outputting carrier phase info. */
int GD_RtkStart(FAR struct cxd56_rtk_setting_s *pParam);
/* Stop outputting carrier phase info. */
int GD_RtkStop(void);
/* Set output interval of carrier phase info.
*
* interval : CXD56_GNSS_RTK_INTERVAL_XXX (gd_type.h)
*/
int GD_RtkSetOutputInterval(int interval);
/* Get output interval of carrier phase info. [ms] */
int GD_RtkGetOutputInterval(FAR int* interval);
/* Set GNSS of outputting carrier phase info. */
int GD_RtkSetGnss(uint32_t gnss);
/* Get GNSS of outputting carrier phase info. */
int GD_RtkGetGnss(FAR uint32_t* pGnss);
/* Set enable/disable GD to notify updating ephemeris */
int GD_RtkSetEphNotify(int enable);
/* Get enable/disable GD to notify updating ephemeris */
int GD_RtkGetEphNotify(FAR int* enable);
/* Set the Ephemeris data Ephemeris data size is variable. */
int GD_SetVarEphemeris(uint32_t *ephemeris, uint32_t ephemerisSize);
/* Get the Ephemeris data Ephemeris data size is variable. */
int GD_GetVarEphemeris(uint32_t satellite, uint32_t* ephemeris,
uint32_t ephemerisSize);
#endif /* __ARCH_ARM_SRC_CXD56XX_CXD56_GNSS_API_H */

View File

@ -0,0 +1,325 @@
/****************************************************************************
* arch/arm/src/cxd56xx/cxd56_uart0.c
*
* Copyright 2018 Sony Semiconductor Solutions Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name of Sony Semiconductor Solutions Corporation nor
* the names of its contributors may be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/kmalloc.h>
#include <nuttx/fs/fs.h>
#include <nuttx/irq.h>
#include <queue.h>
#include <semaphore.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <debug.h>
#include <errno.h>
#include "up_arch.h"
#include "chip.h"
#include "cxd56_pinconfig.h"
#ifdef CONFIG_CXD56_UART0
#include <arch/chip/uart0.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#ifndef CONFIG_CXD56_UART0_BAUD
# define CONFIG_CXD56_UART0_BAUD 921600
#endif
#ifndef CONFIG_CXD56_UART0_BITS
# define CONFIG_CXD56_UART0_BITS 8
#endif
#ifndef CONFIG_CXD56_UART0_PARITY
# define CONFIG_CXD56_UART0_PARITY 0
#endif
#ifndef CONFIG_CXD56_UART0_2STOP
# define CONFIG_CXD56_UART0_2STOP 0
#endif
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
static int uart0_open(FAR struct file *filep);
static int uart0_close(FAR struct file *filep);
static ssize_t uart0_read(FAR struct file *filep,
FAR char *buffer, size_t len);
static ssize_t uart0_write(FAR struct file *filep,
FAR const char *buffer, size_t len);
static int uart0_ioctl(FAR struct file *filep, int cmd, unsigned long arg);
static int uart0_semtake(sem_t *id);
static void uart0_semgive(sem_t *id);
/****************************************************************************
* FarAPI prototypes
****************************************************************************/
int PD_UartInit(int ch);
int PD_UartUninit(int ch);
int PD_UartConfiguration(int ch, int baudrate, int databits,
int parity, int stopbit, int flowctrl);
int PD_UartEnable(int ch);
int PD_UartDisable(int ch);
int PD_UartReceive(int ch, void *buf, int size, int leave);
int PD_UartSend(int ch, void *buf, int size, int leave);
/****************************************************************************
* Private Data
****************************************************************************/
static const struct file_operations g_uart0fops =
{
.open = uart0_open,
.close = uart0_close,
.read = uart0_read,
.write = uart0_write,
.seek = 0,
.ioctl = uart0_ioctl,
};
static sem_t g_lock;
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: uart0_semtake
****************************************************************************/
static int uart0_semtake(sem_t *id)
{
while (sem_wait(id) != 0)
{
ASSERT(errno == EINTR);
}
return OK;
}
/****************************************************************************
* Name: uart0_semgive
****************************************************************************/
static void uart0_semgive(sem_t *id)
{
sem_post(id);
}
/****************************************************************************
* Name: uart0_open
****************************************************************************/
static int uart0_open(FAR struct file *filep)
{
FAR struct inode *inode = filep->f_inode;
int flowctl;
int bits;
int stop;
int ret;
if (inode->i_crefs > 1)
{
return OK;
}
ret = PD_UartInit(0);
if (ret < 0)
{
set_errno(EFAULT);
return ERROR;
}
/* 0 = 5bit, 1 = 6bit, 2 = 7bit, 3 = 8bit */
bits = CONFIG_CXD56_UART0_BITS - 5;
/* 1 = 1 stop, 2 = 2 stop bit */
stop = CONFIG_CXD56_UART0_2STOP + 1;
/* Enable UART0 pin configuration */
#ifdef CONFIG_UART0_FLOWCONTROL
flowctl = 1;
CXD56_PIN_CONFIGS(PINCONFS_SPI2_UART0);
#else
flowctl = 0;
CXD56_PIN_CONFIGS(PINCONFS_SPI2A_UART0);
#endif
ret = PD_UartConfiguration(0, CONFIG_CXD56_UART0_BAUD,
bits,
CONFIG_CXD56_UART0_PARITY,
stop, flowctl);
if (ret < 0)
{
PD_UartUninit(0);
set_errno(EINVAL);
return ERROR;
}
ret = PD_UartEnable(0);
if (ret < 0)
{
PD_UartUninit(0);
set_errno(EFAULT);
return ERROR;
}
return OK;
}
/****************************************************************************
* Name: uart0_close
****************************************************************************/
static int uart0_close(FAR struct file *filep)
{
FAR struct inode *inode = filep->f_inode;
if (inode->i_crefs == 1)
{
PD_UartDisable(0);
PD_UartUninit(0);
/* Disable UART0 pin by changing Hi-Z GPIO */
#ifdef CONFIG_UART0_FLOWCONTROL
CXD56_PIN_CONFIGS(PINCONFS_SPI2_GPIO);
#else
CXD56_PIN_CONFIGS(PINCONFS_SPI2A_GPIO);
#endif
}
return 0;
}
/****************************************************************************
* Name: uart0_read
****************************************************************************/
static ssize_t uart0_read(FAR struct file *filep,
FAR char *buffer, size_t len)
{
int ret;
uart0_semtake(&g_lock);
/* Always blocking */
ret = PD_UartReceive(0, buffer, len, 0);
uart0_semgive(&g_lock);
if (ret < 0)
{
set_errno(-ret);
ret = 0; /* Receive no data */
}
return (ssize_t)ret;
}
/****************************************************************************
* Name: uart0_write
****************************************************************************/
static ssize_t uart0_write(FAR struct file *filep,
FAR const char *buffer, size_t len)
{
int ret;
uart0_semtake(&g_lock);
/* Always blocking */
ret = PD_UartSend(0, (FAR void *)buffer, len, 0);
uart0_semgive(&g_lock);
if (ret < 0)
{
set_errno(-ret);
ret = 0;
}
return (ssize_t)ret;
}
/****************************************************************************
* Name: uart0_ioctl
****************************************************************************/
static int uart0_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
{
return -ENOTTY;
}
/****************************************************************************
* Name: cxd56_uart0initialize
****************************************************************************/
int cxd56_uart0initialize(FAR const char *devname)
{
int ret;
sem_init(&g_lock, 0, 1);
ret = register_driver(devname, &g_uart0fops, 0666, NULL);
if (ret != 0)
{
return ERROR;
}
return OK;
}
/****************************************************************************
* Name: cxd56_uart0uninitialize
****************************************************************************/
void cxd56_uart0uninitialize(FAR const char *devname)
{
unregister_driver(devname);
sem_destroy(&g_lock);
}
#endif /* CONFIG_CXD56_UART0 */

View File

@ -1,5 +1,5 @@
/****************************************************************************
* bsp/board/spresense/src/spresense_main.c
* configs/spresense/src/spresense_main.c
*
* Copyright 2018 Sony Semiconductor Solutions Corporation
*