Skip to content

Commit

Permalink
Merge pull request #23 from rspolyak/gsm_sleep_mode
Browse files Browse the repository at this point in the history
Gsm sleep mode
  • Loading branch information
Rostyslav Spolyak authored Feb 22, 2017
2 parents 04f1793 + a0563cf commit 38ca1f6
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion bsp/gtrack/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@
PIN_ODR_LOW(GPIOA_PIN3) | \
PIN_ODR_HIGH(GPIOA_PIN4) | \
PIN_ODR_HIGH(GPIOA_PIN5) | \
PIN_ODR_LOW(GPIOA_PIN6) | \
PIN_ODR_HIGH(GPIOA_PIN6) | \
PIN_ODR_LOW(GPIOA_PIN7) | \
PIN_ODR_HIGH(GPIOA_PIN8) | \
PIN_ODR_HIGH(GPIOA_PIN9) | \
Expand Down
8 changes: 4 additions & 4 deletions bsp/gtrack/bsp.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ extern void bspSystemPowerOff(void);
#undef GSM_SERIAL_PORT
#define GSM_SERIAL_PORT SD2

#define CTRL_TASK_STACK_SIZE 768
#define CTRL_TASK_STACK_SIZE 1024

#define LOGGING_THREAD_STACK_SIZE 512
#define LOGGING_THREAD_STACK_SIZE 768

#define CLI_THREAD_STACK_SIZE 512
#define CLI_THREAD_STACK_SIZE 1024

#define ACCEL_THREAD_STACK_SIZE 768
#define ACCEL_THREAD_STACK_SIZE 1024

#define BSP_SYS_PWR_PORT GPIOA
#define BSP_SYS_PWR_PIN GPIOA_PIN7
Expand Down
2 changes: 2 additions & 0 deletions drivers/include/gsm_ll.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
*/
#define GSM_SERIAL_SPEED 19200

#define GSM_THREAD_STACK_SIZE 1536

#define MED_BUF_LEN 64
#define GSM_SMS_INTERNAL_BLOCKS 3

Expand Down
14 changes: 7 additions & 7 deletions drivers/network/gsm_ll.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
//#define GSM_ERROR_HANDLE

/* Enables GSM low power mode */
//#define GSM_SLEEP
#define GSM_SLEEP

gsmCbFunc_t gsmCbArray_g[GSM_EVENT_LAST];
phoneBook_t phoneBook_g;
Expand All @@ -59,7 +59,7 @@ static struct
float balance;
} balance_s = {.state = false, .balance = 0.0};

static THD_WORKING_AREA(gsmThread, 1024);
static THD_WORKING_AREA(gsmThread, GSM_THREAD_STACK_SIZE);

static bool gsm_is_ready = FALSE;
static MUTEX_DECL(gsm_ready_mutex);
Expand Down Expand Up @@ -256,7 +256,7 @@ void gsmModuleCfg(void)

//gsmCmdSend(GSM_PHONEBOOK_READ_ALL);

//gsmCmdSend(GSM_SLEEP_MODE_DTR);
gsmCmdSend(GSM_SLEEP_MODE_DTR);
}

void gsmModulePhoneNumberAdd(char* number, char* name)
Expand Down Expand Up @@ -694,9 +694,9 @@ static THD_FUNCTION(gsmTask, arg)
if (res == MSG_OK)
{
cur_command.id++;
#if GSM_SLEEP
#ifdef GSM_SLEEP
/* exit sleep mode. serial port will be active after about 50ms */
palClearPad(GPIOA, GPIOA_PIN2);
palClearPad(GPIOA, GPIOA_PIN6);
chThdSleepMilliseconds(100);
#endif
LOG_TRACE(GSM_CMP, "Sending a command #%d:%s", cur_command.id, pBuf);
Expand Down Expand Up @@ -769,9 +769,9 @@ static THD_FUNCTION(gsmTask, arg)
#endif
/* allow next command to be dispatched to GSM module */
cur_command.ack = true;
#if GSM_SLEEP
#ifdef GSM_SLEEP
/* enter sleep mode */
palSetPad(GPIOA, GPIOA_PIN2);
palSetPad(GPIOA, GPIOA_PIN6);
#endif
}
val = 0;
Expand Down

0 comments on commit 38ca1f6

Please sign in to comment.