Low-Level functions

Low-level module consists of callback-only functions, which are called by middleware and must be implemented by final application.

Tip

Check Porting guide for actual implementation

group LWCELL_LL

Low-level communication functions.

Typedefs

typedef size_t (*lwcell_ll_send_fn)(const void *data, size_t len)

Function prototype for AT output data.

Param data

[in] Pointer to data to send. This parameter can be set to NULL, indicating to the low-level that (if used) DMA could be started to transmit data to the device

Param len

[in] Number of bytes to send. This parameter can be set to 0 to indicate that internal buffer can be flushed to stream. This is implementation defined and feature might be ignored

Return

Number of bytes sent

typedef uint8_t (*lwcell_ll_reset_fn)(uint8_t state)

Function prototype for hardware reset of GSM device.

Param state

[in] State indicating reset. When set to 1, reset must be active (usually pin active low), or set to 0 when reset is cleared

Return

1 on successful action, 0 otherwise

Functions

lwcellr_t lwcell_ll_init(lwcell_ll_t *ll)

Callback function called from initialization process.

Callback function called from initialization process.

Note

This function may be called multiple times if AT baudrate is changed from application. It is important that every configuration except AT baudrate is configured only once!

Note

This function may be called from different threads in GSM stack when using OS. When LWCELL_CFG_INPUT_USE_PROCESS is set to 1, this function may be called from user UART thread.

Parameters
  • ll – [inout] Pointer to lwcell_ll_t structure to fill data for communication functions

  • ll – [in] Pointer to low-level structure

Returns

lwcellOK on success, member of lwcellr_t enumeration otherwise

Returns

lwcellOK on success, member of lwcellr_t otherwise

lwcellr_t lwcell_ll_deinit(lwcell_ll_t *ll)

Callback function to de-init low-level communication part.

Parameters

ll – [inout] Pointer to lwcell_ll_t structure to fill data for communication functions

Returns

lwcellOK on success, member of lwcellr_t enumeration otherwise

uint8_t lwcell_ll_wait_module_ready(uint32_t max_wait_ms, uint32_t settle_ms)

Wait until modem responds to AT autobaud sync attempts, or until timeout expires.

Implementation is platform-specific and must be provided by the low-level driver (see lwcell_ll_init).

Wait until modem responds to AT autobaud sync attempts, or until timeout expires.

Sends “AT\r” repeatedly until the module produces its first response. Since SIM7000E has local echo enabled by default (ATE1), every “AT\r” we send will be echoed back by the module itself once it is alive - so we must stop sending pings as soon as we see a response, otherwise our own echo traffic would keep the “quiet period” from ever being reached.

After the first response, we stop pinging entirely and just passively wait for quiet_ms of silence, which then reliably indicates that the module has finished its boot banner and is ready for real commands.

Parameters
  • max_wait_ms – [in] Maximum time to wait for first response, in ms

  • settle_ms – [in] Extra time to wait after first response is seen

Returns

1 if module responded within max_wait_ms, 0 on timeout

lwcellr_t lwcell_ll_rx_clear(void)

Discard any pending/unprocessed data in the platform’s RX buffer and reset RX position tracking.

Used after autobaud sync (cold power-up or warm reset via AT+CFUN=1,1) to make sure lwcell starts parsing from a clean state, without any leftover “OK” responses from the sync “AT\r” pings still pending.

Implementation is platform-specific and must be provided by the low-level driver (see lwcell_ll_init).

Discard any pending/unprocessed data in the platform’s RX buffer and reset RX position tracking.

Returns

lwcellOK on success, member of lwcellr_t otherwise

struct lwcell_ll_t
#include <lwcell_types.h>

Low level user specific functions.

Public Members

lwcell_ll_send_fn send_fn

Callback function to transmit data

lwcell_ll_reset_fn reset_fn

Reset callback function

uint32_t baudrate

UART baudrate value

struct lwcell_ll_t::[anonymous] uart

UART communication parameters