PK
G BT200/PK
GFQ BT200/bluetooth_command.c/*
* (C) COPYRIGHT 2013 CRZ
*
* File Name : mcu_comm_command.c
* Author : POOH
* Version : V1.0
*/
/* includes */
#include "hw_config.h"
#include "bluetooth_command.h"
/* Defines */
/* Variables */
uint8_t g_mcu_comm_buffer_tx[MCU_COMM_BUFFER_SIZE];
/* Static Functions */
static void make_cmd_common_send(void)
{
uint8_t i;
g_mcu_comm_buffer_tx[MCU_COMM_BUFFER_SIZE - 2] = MCU_COMM_TAIL_CR;
g_mcu_comm_buffer_tx[MCU_COMM_BUFFER_SIZE - 1] = MCU_COMM_TAIL_LF;
Uart_2_Comm_SendData_Chars(g_mcu_comm_buffer_tx, MCU_COMM_BUFFER_SIZE);
#ifdef MCU_COMM_DEBUG_ON
/* Print All */
printf("%s\n", g_mcu_comm_buffer_tx);
for(i = 0; i < MCU_COMM_BUFFER_SIZE; i++)
{
printf("%02X ", g_mcu_comm_buffer_tx[i]);
}
printf("\n");
#endif
}
#define CMD_MODULE_STATE "ATC80=03"
void make_cmd_module_state(void)
{
memset(g_mcu_comm_buffer_tx, 0, sizeof(g_mcu_comm_buffer_tx));
memcpy(g_mcu_comm_buffer_tx, CMD_MODULE_STATE, sizeof(CMD_MODULE_STATE));
make_cmd_common_send();
}
#define CMD_MODULE_SENSITIVITY "ATC06=00"
void make_cmd_module_sensitivity(void)
{
memset(g_mcu_comm_buffer_tx, 0, sizeof(g_mcu_comm_buffer_tx));
memcpy(g_mcu_comm_buffer_tx, CMD_MODULE_SENSITIVITY, sizeof(CMD_MODULE_SENSITIVITY));
make_cmd_common_send();
}
#define CMD_FIRMWARE_VERSION "ATC02=04"
void make_cmd_firmware_version(void)
{
memset(g_mcu_comm_buffer_tx, 0, sizeof(g_mcu_comm_buffer_tx));
memcpy(g_mcu_comm_buffer_tx, CMD_FIRMWARE_VERSION, sizeof(CMD_FIRMWARE_VERSION));
make_cmd_common_send();
}
// crazyboy 2015/02/03
#define CMD_USER_FRIENDLY_NAME "ATC02=01"
void make_cmd_user_friendly_name(char *user_friendly_name)
{
int cmd_size = sizeof(CMD_USER_FRIENDLY_NAME);
printf("%s cmd_size = %d user friendly name : %s\n", __func__, cmd_size, user_friendly_name);
memset(g_mcu_comm_buffer_tx, 0, sizeof(g_mcu_comm_buffer_tx));
memcpy(g_mcu_comm_buffer_tx, CMD_USER_FRIENDLY_NAME, cmd_size);
g_mcu_comm_buffer_tx[cmd_size-1] = strlen(user_friendly_name);
memcpy(g_mcu_comm_buffer_tx+cmd_size, user_friendly_name, strlen(user_friendly_name));
make_cmd_common_send();
}
// crazyboy 2015/02/06
#define CMD_PIN_CODE "ATC02=00"
void make_cmd_pin_code(char *pin_code)
{
int cmd_size = sizeof(CMD_PIN_CODE);
printf("%s cmd_size = %d pin code : %s\n", __func__, cmd_size, pin_code);
memset(g_mcu_comm_buffer_tx, 0, sizeof(g_mcu_comm_buffer_tx));
memcpy(g_mcu_comm_buffer_tx, CMD_PIN_CODE, cmd_size);
g_mcu_comm_buffer_tx[cmd_size-1] = strlen(pin_code);
memcpy(g_mcu_comm_buffer_tx+cmd_size, pin_code, strlen(pin_code));
make_cmd_common_send();
}
#define CMD_INQUIRY_START "ATC00=02"
void make_cmd_inquiry_start(void)
{
int cmd_size = sizeof(CMD_INQUIRY_START);
memset(g_mcu_comm_buffer_tx, 0, sizeof(g_mcu_comm_buffer_tx));
memcpy(g_mcu_comm_buffer_tx, CMD_INQUIRY_START, cmd_size);
g_mcu_comm_buffer_tx[cmd_size - 1] = 0x02;
g_mcu_comm_buffer_tx[cmd_size] = 0x30; /* 0x30 is decimal 48, 48 * 1.28 = 61.44 seconds is max */
g_mcu_comm_buffer_tx[cmd_size + 1] = 0x14; /* 0x14 is decimal 20, max 20 devices */
make_cmd_common_send();
}
#define CMD_INQUIRY_STOP "ATC00=03"
void make_cmd_inquiry_stop(void)
{
int cmd_size = sizeof(CMD_INQUIRY_STOP);
memset(g_mcu_comm_buffer_tx, 0, sizeof(g_mcu_comm_buffer_tx));
memcpy(g_mcu_comm_buffer_tx, CMD_INQUIRY_STOP, cmd_size);
make_cmd_common_send();
}
uint8_t g_slave_bt_address_tmp[6];
#define CMD_SPP_CONNECT "ATC80=00"
void make_cmd_spp_connect(void)
{
int cmd_size = sizeof(CMD_SPP_CONNECT);
memset(g_mcu_comm_buffer_tx, 0, sizeof(g_mcu_comm_buffer_tx));
memcpy(g_mcu_comm_buffer_tx, CMD_SPP_CONNECT, cmd_size);
g_mcu_comm_buffer_tx[cmd_size - 1] = 0x06;
memcpy(&(g_mcu_comm_buffer_tx[cmd_size]), g_slave_bt_address_tmp, 6);
make_cmd_common_send();
Delay(150);
}
#define RES_PIN_CODE "ATC01=01"
void make_res_pin_code(void)
{
int cmd_size = sizeof(RES_PIN_CODE);
memset(g_mcu_comm_buffer_tx, 0, sizeof(g_mcu_comm_buffer_tx));
memcpy(g_mcu_comm_buffer_tx, RES_PIN_CODE, cmd_size);
/* PIN Code "1234" */
g_mcu_comm_buffer_tx[cmd_size - 1] = 0x04;
memcpy(&(g_mcu_comm_buffer_tx[cmd_size]), "1234", 4);
make_cmd_common_send();
}
#define CMD_SPP_DISCONNECT "ATC80=02"
void make_cmd_spp_disconnect(void)
{
int cmd_size = sizeof(CMD_SPP_DISCONNECT);
memset(g_mcu_comm_buffer_tx, 0, sizeof(g_mcu_comm_buffer_tx));
memcpy(g_mcu_comm_buffer_tx, CMD_SPP_DISCONNECT, cmd_size);
make_cmd_common_send();
Delay(150);
}
/* Discoverable Start */
#define CMD_DISCOVERABLE_START "ATC00=01"
void make_cmd_discoverable_start(void)
{
int cmd_size = sizeof(CMD_DISCOVERABLE_START);
memset(g_mcu_comm_buffer_tx, 0, sizeof(g_mcu_comm_buffer_tx));
memcpy(g_mcu_comm_buffer_tx, CMD_DISCOVERABLE_START, cmd_size);
make_cmd_common_send();
}
PK
țGpƉ BT200/bluetooth_command.h#ifndef __MCU_COMMM_COMMAND_H
#define __MCU_COMMM_COMMAND_H
/* Includes ------------------------------------------------------------------*/
#include "hw_config.h"
#include "global_types.h"
/* Exported types ------------------------------------------------------------*/
#define MCU_COMM_DEBUG_ON
/* Exported constants --------------------------------------------------------*/
#define MCU_COMM_BUFFER_SIZE 32
#define MCU_COMM_TAIL_CR 0x0D
#define MCU_COMM_TAIL_LF 0x0A
#define RSP_INQUIRY_RESULT "ATA00=01"
#define REQ_REMOTE_PIN_CODE "ATA01=01"
/* Exported macro ------------------------------------------------------------*/
/* External variables --------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */
bool Mcu_Comm_Get_1_Packet(unsigned int timeout_msec);
void Mcu_Comm_Receive_Process(void);
void make_cmd_module_state(void);
void make_cmd_module_sensitivity(void);
void make_cmd_firmware_version(void);
void make_cmd_user_friendly_name(char *user_friendly_name);
void make_cmd_pin_code(char *pin_code);
void make_cmd_inquiry_start(void);
void make_cmd_inquiry_stop(void);
void make_cmd_spp_connect(void);
void make_res_pin_code(void);
void make_cmd_spp_disconnect(void);
void make_cmd_discoverable_start(void);
#endif /* __MCU_COMMM_COMMAND_H */
PK
XF Q
Q
BT200/bluetooth_rx_proc.c/*
* (C) COPYRIGHT 2013 CRZ
*
* File Name : mcu_comm_rx_proc.c
* Author : POOH
* Version : V1.0
* Date : 03/22/2013
*/
/* includes */
#include "hw_config.h"
#include "global_types.h"
#include "uart_queue.h"
/* Defines */
typedef enum
{
MCU_COMM_RX_STATE_START = 0,
MCU_COMM_RX_STATE_HEADER_A1_RECEIVED = 1,
MCU_COMM_RX_STATE_HEADER_T_RECEIVED = 2,
MCU_COMM_RX_STATE_HEADER_A2_RECEIVED = 2,
MCU_COMM_RX_STATE_ID_OPCODE_RECEIVED = 3,
MCU_COMM_RX_STATE_ID_LENGTH_RECEIVED = 4,
MCU_COMM_RX_STATE_DATA_RECEIVED = 5,
MCU_COMM_RX_STATE_TAIL_DLE_RECEIVED = 6,
MCU_COMM_RX_STATE_TAIL_ETX_RECEIVED = 7,
MCU_COMM_RX_STATE_CRC1_RECEIVED = 8,
} Mcu_Comm_Rx_State_E;
/* Variables */
uint16_t g_micom_id_data;
uint8_t g_mcu_comm_buffer_rx[MCU_COMM_BUFFER_SIZE];
uint8_t g_rx_index = 0;
uint8_t g_rx_data_size = 0;
uint8_t g_rx_data_count = 0;
Mcu_Comm_Rx_State_E g_rx_curr_state = MCU_COMM_RX_STATE_START;
/* Static Functions */
static void initialize_all_data(void)
{
memset(g_mcu_comm_buffer_rx, 0, MCU_COMM_BUFFER_SIZE);
g_rx_index = 0;
}
static bool is_packet_receive_done(void)
{
uint8_t rx_curr_value, i;
if(true == UartQueue_Bluetooth_Is_Empty())
{
return false;
}
if(UartQueue_Bluetooth_CurrSize() < MCU_COMM_BUFFER_SIZE)
{
initialize_all_data();
return false;
}
rx_curr_value = UartQueue_Bluetooth_DeQueue();
g_mcu_comm_buffer_rx[g_rx_index++] = rx_curr_value;
if('A' != g_mcu_comm_buffer_rx[0])
{
initialize_all_data();
return false;
}
rx_curr_value = UartQueue_Bluetooth_DeQueue();
g_mcu_comm_buffer_rx[g_rx_index++] = rx_curr_value;
if('T' != g_mcu_comm_buffer_rx[1])
{
initialize_all_data();
return false;
}
rx_curr_value = UartQueue_Bluetooth_DeQueue();
g_mcu_comm_buffer_rx[g_rx_index++] = rx_curr_value;
if('A' != g_mcu_comm_buffer_rx[2])
{
initialize_all_data();
return false;
}
for(i = 3; i < MCU_COMM_BUFFER_SIZE; i ++)
{
rx_curr_value = UartQueue_Bluetooth_DeQueue();
g_mcu_comm_buffer_rx[g_rx_index++] = rx_curr_value;
}
if((MCU_COMM_TAIL_CR == g_mcu_comm_buffer_rx[MCU_COMM_BUFFER_SIZE - 2])
&& (MCU_COMM_TAIL_LF == g_mcu_comm_buffer_rx[MCU_COMM_BUFFER_SIZE - 1]))
{
return true;
}
else
{
return false;
}
}
/* Global Functions */
#define MCU_COMM_GET_PACKET_TIME_QUANTUM 900
bool Mcu_Comm_Get_1_Packet(unsigned int timeout_msec)
{
int i;
bool check_packet_done = false;
while(1)
{
check_packet_done = is_packet_receive_done();
if(true == check_packet_done)
{
printf("RX: %s\n", g_mcu_comm_buffer_rx);
for(i = 0; i < g_rx_index; i ++)
{
printf("%02X ", g_mcu_comm_buffer_rx[i]);
}
printf("\n");
return true;
}
if(0 == timeout_msec)
{
return false;
}
timeout_msec --;
usleep(MCU_COMM_GET_PACKET_TIME_QUANTUM);
}
}
void Mcu_Comm_Receive_Process(void)
{
/* */
initialize_all_data();
}
PK
=GU%d! d! BT200/test_BT200.c/*
* (C) COPYRIGHT 2015 CRZ
*
* File Name : test_BT200.c
* Author :
* Version : V1.0
* Date : 04/29/2015
*/
/* includes */
#include "hw_config.h"
#include "global_types.h"
#include "test_BT200.h"
#include "uart_queue.h"
#include "bluetooth_command.h"
/* functions */
/* PA4 (Reset) Output */
void Reset_BT200(void)
{
GPIO_ResetBits(GPIO_MCU_PA, GPIO_MCU_PA_4_PIN);
Delay(100);
GPIO_SetBits(GPIO_MCU_PA, GPIO_MCU_PA_4_PIN);
Delay(200);
}
void ModeChange_PartronBT_to_Stream(void)
{
#if 0
GPIO_SetBits(GPIO_MCU_PA, GPIO_MCU_PA_6_PIN);
Delay(10);
#endif
GPIO_ResetBits(GPIO_MCU_PA, GPIO_MCU_PA_6_PIN);
Delay(150);
}
void ModeChange_PartronBT_to_Normal(void)
{
#if 0
GPIO_ResetBits(GPIO_MCU_PA, GPIO_MCU_PA_6_PIN);
Delay(10);
#endif
GPIO_SetBits(GPIO_MCU_PA, GPIO_MCU_PA_6_PIN);
Delay(150);
}
void Init_BT200(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Pin = GPIO_MCU_PA_4_PIN | GPIO_MCU_PA_6_PIN;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_40MHz;
GPIO_Init(GPIO_MCU_PA, &GPIO_InitStructure);
Reset_BT200();
/* PA5 - PIO2 input mode */
GPIO_InitStructure.GPIO_Pin = GPIO_MCU_PA_5_PIN;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_40MHz;
GPIO_Init(GPIO_MCU_PA, &GPIO_InitStructure);
ModeChange_PartronBT_to_Normal();
}
#define BT_RX_BUFFER_SIZE 256
extern uint8_t g_slave_bt_address_tmp[6];
void Print_Receive_Data(uint8_t * rx_data_p, int rx_size)
{
int i;
printf("RX Size: %d, RX Data: ", rx_size);
for(i = 0; i < rx_size; i ++)
{
if(0 == rx_data_p[i])
printf("%c", ' ');
else if((MCU_COMM_TAIL_CR != rx_data_p[i]) && (MCU_COMM_TAIL_LF != rx_data_p[i]))
printf("%c", rx_data_p[i]);
}
printf("\n");
for(i = 0; i < rx_size; i ++)
{
printf("%02X ", rx_data_p[i]);
}
printf("\n");
}
void Process_Receive_Data(uint8_t * rx_data_p)
{
int i;
if(0 == strncmp((char *)rx_data_p, (char *)RSP_INQUIRY_RESULT, sizeof(RSP_INQUIRY_RESULT) - 1))
{
printf("<< Receive Inquiry Result >>\n");
memset(g_slave_bt_address_tmp, 0, sizeof(g_slave_bt_address_tmp));
memcpy((char *)g_slave_bt_address_tmp, (char *)(&(rx_data_p[10])), 6);
printf("Slave BT Addr: ");
for(i = 0; i < 6; i ++)
{
printf("%02X ", g_slave_bt_address_tmp[i]);
}
printf("\n");
}
if(0 == strncmp((char *)rx_data_p, (char *)REQ_REMOTE_PIN_CODE, sizeof(REQ_REMOTE_PIN_CODE) - 1))
{
printf("<< Receive Request Remote PIN Code >>\n");
make_res_pin_code();
}
}
void test_rx_process(void)
{
int i;
uint8_t rx_data_prev = 0;
uint8_t rx_data[BT_RX_BUFFER_SIZE];
if(FALSE == Uart_2_Queue_Comm_Is_Empty())
{
rx_data_prev = 0;
memset(rx_data, 0, sizeof(rx_data));
for(i = 0; i < (BT_RX_BUFFER_SIZE - 1); i ++)
{
rx_data[i] = Uart_2_Queue_Comm_DeQueue();
Delay(20);
if(TRUE == Uart_2_Queue_Comm_Is_Empty())
{
i ++;
break;
}
if((MCU_COMM_TAIL_CR == rx_data_prev) && (MCU_COMM_TAIL_LF == rx_data[i]))
{
i ++;
break;
}
else
{
rx_data_prev = rx_data[i];
}
}
Print_Receive_Data(rx_data, i);
Process_Receive_Data(rx_data);
}
}
static bool g_print_menu_control_flag_master = TRUE;
static void print_menu_command_master(void)
{
if(TRUE == g_print_menu_control_flag_master)
{
printf("\n---------------------\n");
printf("Press menu key - Master Mode\n");
printf("---------------------\n");
printf("0> Reset BT\n");
printf("---------------------\n");
printf("1> Normal Mode\n");
printf("2> Stream Mode\n");
printf("---------------------\n");
printf("5> AT CMD: state\n");
printf("7> AT CMD: firmware version\n");
printf("---------------------\n");
printf("8> Send Data: ABCDEFGH01234\n");
printf("---------------------\n");
printf("a> AT CMD: inquiry start\n");
printf("b> AT CMD: inquiry stop\n");
printf("c> AT CMD: spp connect\n");
printf("d> AT CMD: spp disconnect\n");
printf("---------------------\n");
}
g_print_menu_control_flag_master = FALSE;
}
void Test_BT200_Master(void)
{
uint8_t ch;
DEBUG_MSG_FUNC_START;
while(1)
{
print_menu_command_master();
if(FALSE == UartQueue_Serial_Is_Empty())
{
ch = UartQueue_Serial_DeQueue();
printf("%c is selected\n\n", (char)ch);
switch((char)ch)
{
case '0':
Reset_BT200();
break;
case '1':
ModeChange_PartronBT_to_Normal();
break;
case '2':
ModeChange_PartronBT_to_Stream();
break;
case '5':
make_cmd_module_state();
break;
case '7':
make_cmd_firmware_version();
break;
case '8':
Uart_2_Comm_SendData_Chars("ABCDEFGH01234", sizeof("ABCDEFGH01234"));
break;
case 'a':
make_cmd_inquiry_start();
break;
case 'b':
make_cmd_inquiry_stop();
break;
case 'c':
make_cmd_spp_connect();
ModeChange_PartronBT_to_Stream();
break;
case 'd':
ModeChange_PartronBT_to_Normal();
make_cmd_spp_disconnect();
break;
}
g_print_menu_control_flag_master = TRUE;
}
test_rx_process();
}
}
static bool g_print_menu_control_flag_slave = TRUE;
static void print_menu_command_slave(void)
{
if(TRUE == g_print_menu_control_flag_slave)
{
printf("\n---------------------\n");
printf("Press menu key - Slave Mode\n");
printf("---------------------\n");
printf("0> Reset BT\n");
printf("---------------------\n");
printf("1> Normal Mode\n");
printf("2> Stream Mode\n");
printf("---------------------\n");
printf("5> AT CMD: state\n");
printf("7> AT CMD: firmware version\n");
printf("---------------------\n");
printf("8> Send Data: ABCDEFGH01234\n");
printf("---------------------\n");
printf("a> AT CMD: discoverable start\n");
printf("---------------------\n");
}
g_print_menu_control_flag_slave = FALSE;
}
void Test_BT200_Slave(void)
{
uint8_t ch;
DEBUG_MSG_FUNC_START;
while(1)
{
print_menu_command_slave();
if(FALSE == UartQueue_Serial_Is_Empty())
{
ch = UartQueue_Serial_DeQueue();
printf("%c is selected\n\n", (char)ch);
switch((char)ch)
{
case '0':
Reset_BT200();
break;
case '1':
ModeChange_PartronBT_to_Normal();
break;
case '2':
ModeChange_PartronBT_to_Stream();
break;
case '5':
make_cmd_module_state();
break;
case '7':
make_cmd_firmware_version();
break;
case '8':
Uart_2_Comm_SendData_Chars("ABCDEFGH01234", sizeof("ABCDEFGH01234"));
break;
case 'a':
make_cmd_discoverable_start();
break;
}
g_print_menu_control_flag_slave = TRUE;
}
test_rx_process();
}
}
PK
%G}J BT200/test_BT200.h/*
* BT200
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __TEST_BT200_H
#define __TEST_BT200_H
#ifdef __cplusplus
extern "C" {
#endif
void ModeChange_PartronBT_to_Stream(void);
void ModeChange_PartronBT_to_Normal(void);
void Init_BT200(void);
void Test_BT200_Master(void);
void Test_BT200_Slave(void);
#ifdef __cplusplus
}
#endif
#endif /* __TEST_BT200_H */
PK
G inc/PK
+{DJζ inc/debug.h#ifndef __DEBUG_H
#define __DEBUG_H
/* Includes ------------------------------------------------------------------*/
#include "stm32l1xx.h"
#include "stdio.h"
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
#define DEBUG_MSG_LEVEL0
// #define DEBUG_MSG_LEVEL1
#define DEBUG_MSG_FUNC_START (DebugMsg_FunctionStart(__FUNCTION__))
#define DEBUG_MSG_FUNC_END (DebugMsg_FunctionEnd(__FUNCTION__))
#define DEBUG_MSG_FUNC_NOTIFY (DebugMsg_FunctionNotify(__FUNCTION__, __LINE__))
#define DEBUG_MSG_FUNC_ERROR (DebugMsg_FunctionError(__FUNCTION__, __LINE__))
#ifdef USE_FULL_ASSERT
#define DEBUG_MSG_ASSERT (DebugMsg_Assert(__FUNCTION__, __LINE__))
#else
#define DEBUG_MSG_ASSERT ((void)0)
#endif /* USE_FULL_ASSERT */
/* Exported macro ------------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */
void DebugMsg_FunctionStart(char const * fName_p);
void DebugMsg_FunctionEnd(char const * fName_p);
void DebugMsg_FunctionNotify(char const * fName_p, int lineNum);
void DebugMsg_FunctionError(char const * fName_p, int lineNum);
void DebugMsg_Assert(char const * fName_p, int lineNum);
/* External variables --------------------------------------------------------*/
#endif /* __DEBUG_H */
PK
v(Dϕ inc/global_types.h/*
* (C) COPYRIGHT 2014 CRZ
*
* File Name : global_types.h
*/
#ifndef __GLOBAL_TYPES_H
#define __GLOBAL_TYPES_H
typedef enum
{
FALSE = 0, TRUE = !FALSE
}
bool;
#endif /* __GLOBAL_TYPES_H */
PK
Gj[ inc/hw_config.h/*
* (C) COPYRIGHT 2009 CRZ
*
* File Name : hw_config.h
* Author : POOH
* Version : V1.0
* Date : 08/12/2009
*/
#ifndef __HW_CONFIG_H
#define __HW_CONFIG_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* includes */
#include "stm32l1xx.h"
#include
*/
/* Includes ------------------------------------------------------------------*/
#include "stm32l1xx.h"
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __I2CROUTINES_H
#define __I2CROUTINES_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* I2C SPE mask */
#define CR1_PE_Set ((uint16_t)0x0001)
#define CR1_PE_Reset ((uint16_t)0xFFFE)
/* I2C START mask */
#define CR1_START_Set ((uint16_t)0x0100)
#define CR1_START_Reset ((uint16_t)0xFEFF)
#define CR1_POS_Set ((uint16_t)0x0800)
#define CR1_POS_Reset ((uint16_t)0xF7FF)
/* I2C STOP mask */
#define CR1_STOP_Set ((uint16_t)0x0200)
#define CR1_STOP_Reset ((uint16_t)0xFDFF)
/* I2C ACK mask */
#define CR1_ACK_Set ((uint16_t)0x0400)
#define CR1_ACK_Reset ((uint16_t)0xFBFF)
/* I2C ENARP mask */
#define CR1_ENARP_Set ((uint16_t)0x0010)
#define CR1_ENARP_Reset ((uint16_t)0xFFEF)
/* I2C NOSTRETCH mask */
#define CR1_NOSTRETCH_Set ((uint16_t)0x0080)
#define CR1_NOSTRETCH_Reset ((uint16_t)0xFF7F)
/* I2C registers Masks */
#define CR1_CLEAR_Mask ((uint16_t)0xFBF5)
/* I2C DMAEN mask */
#define CR2_DMAEN_Set ((uint16_t)0x0800)
#define CR2_DMAEN_Reset ((uint16_t)0xF7FF)
/* I2C LAST mask */
#define CR2_LAST_Set ((uint16_t)0x1000)
#define CR2_LAST_Reset ((uint16_t)0xEFFF)
/* I2C FREQ mask */
#define CR2_FREQ_Reset ((uint16_t)0xFFC0)
/* I2C ADD0 mask */
#define OAR1_ADD0_Set ((uint16_t)0x0001)
#define OAR1_ADD0_Reset ((uint16_t)0xFFFE)
/* I2C ENDUAL mask */
#define OAR2_ENDUAL_Set ((uint16_t)0x0001)
#define OAR2_ENDUAL_Reset ((uint16_t)0xFFFE)
/* I2C ADD2 mask */
#define OAR2_ADD2_Reset ((uint16_t)0xFF01)
/* I2C F/S mask */
#define CCR_FS_Set ((uint16_t)0x8000)
/* I2C CCR mask */
#define CCR_CCR_Set ((uint16_t)0x0FFF)
/* I2C FLAG mask */
#define FLAG_Mask ((uint32_t)0x00FFFFFF)
/* I2C Interrupt Enable mask */
#define ITEN_Mask ((uint32_t)0x07000000)
#define I2C_IT_BUF ((uint16_t)0x0400)
#define I2C_IT_EVT ((uint16_t)0x0200)
#define I2C_IT_ERR ((uint16_t)0x0100)
#define ClockSpeed 400000
#define I2C_DIRECTION_TX 0
#define I2C_DIRECTION_RX 1
#define OwnAddress1 0x28
#define OwnAddress2 0x30
typedef enum
{
Polling = 0x00,
Interrupt = 0x01,
DMA = 0x02
} I2C_ProgrammingModel;
typedef enum
{
Error = 0,
Success = !Error
}Status;
/* Exported macro ------------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */
Status I2C_Master_BufferRead(I2C_TypeDef* I2Cx, uint8_t* pBuffer, uint32_t NumByteToRead, I2C_ProgrammingModel Mode, uint8_t SlaveAddress);
Status I2C_Master_BufferWrite(I2C_TypeDef* I2Cx, uint8_t* pBuffer, uint32_t NumByteToWrite, I2C_ProgrammingModel Mode, uint8_t SlaveAddress);
void I2C_Slave_BufferReadWrite(I2C_TypeDef* I2Cx,I2C_ProgrammingModel Mode);
void I2C_LowLevel_Init(void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
/******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
PK
QD/0 inc/led.h#ifndef __LED_H
#define __LED_H
/* Includes ------------------------------------------------------------------*/
#include "stm32l1xx.h"
#include "stdio.h"
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
typedef enum
{
LED1 = 0,
LED2 = 1,
LED3 = 2
} LED_NUM_E;
#define NUM_OF_LEDS 3
/* Exported macro ------------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */
void LED_On(LED_NUM_E ledNum);
void LED_Off(LED_NUM_E ledNum);
void LED_Toggle(LED_NUM_E ledNum);
void LED_On_All(void);
void LED_Off_All(void);
void LED_Blink_All(uint32_t count, uint32_t delayMSec);
/* External variables --------------------------------------------------------*/
#endif /* __LED_H */
PK
4Di
inc/stm32l1xx_conf.h/**
******************************************************************************
* @file Project/STM32L1xx_StdPeriph_Templates/stm32l1xx_conf.h
* @author MCD Application Team
* @version V1.2.0
* @date 16-May-2014
* @brief Library configuration file.
******************************************************************************
* @attention
*
*
*
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.st.com/software_license_agreement_liberty_v2
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __STM32L1xx_CONF_H
#define __STM32L1xx_CONF_H
/* Includes ------------------------------------------------------------------*/
/* Uncomment/Comment the line below to enable/disable peripheral header file inclusion */
#include "stm32l1xx_adc.h"
#include "stm32l1xx_aes.h"
#include "stm32l1xx_comp.h"
#include "stm32l1xx_crc.h"
#include "stm32l1xx_dac.h"
#include "stm32l1xx_dbgmcu.h"
#include "stm32l1xx_dma.h"
#include "stm32l1xx_exti.h"
#include "stm32l1xx_flash.h"
#include "stm32l1xx_fsmc.h"
#include "stm32l1xx_gpio.h"
#include "stm32l1xx_i2c.h"
#include "stm32l1xx_iwdg.h"
#include "stm32l1xx_lcd.h"
#include "stm32l1xx_opamp.h"
#include "stm32l1xx_pwr.h"
#include "stm32l1xx_rcc.h"
#include "stm32l1xx_rtc.h"
#include "stm32l1xx_sdio.h"
#include "stm32l1xx_spi.h"
#include "stm32l1xx_syscfg.h"
#include "stm32l1xx_tim.h"
#include "stm32l1xx_usart.h"
#include "stm32l1xx_wwdg.h"
#include "misc.h" /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* Uncomment the line below to expanse the "assert_param" macro in the
Standard Peripheral Library drivers code */
/* #define USE_FULL_ASSERT 1 */
/* Exported macro ------------------------------------------------------------*/
#ifdef USE_FULL_ASSERT
/**
* @brief The assert_param macro is used for function's parameters check.
* @param expr: If expr is false, it calls assert_failed function which reports
* the name of the source file and the source line number of the call
* that failed. If expr is true, it returns no value.
* @retval None
*/
#define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__))
/* Exported functions ------------------------------------------------------- */
void assert_failed(uint8_t* file, uint32_t line);
#else
#define assert_param(expr) ((void)0)
#endif /* USE_FULL_ASSERT */
#endif /* __STM32L1xx_CONF_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
PK
4Dat inc/stm32l1xx_it.h/**
******************************************************************************
* @file Project/STM32L1xx_StdPeriph_Templates/stm32l1xx_it.h
* @author MCD Application Team
* @version V1.2.0
* @date 16-May-2014
* @brief This file contains the headers of the interrupt handlers.
******************************************************************************
* @attention
*
*
*
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.st.com/software_license_agreement_liberty_v2
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __STM32L1xx_IT_H
#define __STM32L1xx_IT_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "stm32l1xx.h"
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* Exported macro ------------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */
void NMI_Handler(void);
void HardFault_Handler(void);
void MemManage_Handler(void);
void BusFault_Handler(void);
void UsageFault_Handler(void);
void SVC_Handler(void);
void DebugMon_Handler(void);
void PendSV_Handler(void);
void SysTick_Handler(void);
#ifdef __cplusplus
}
#endif
#endif /* __STM32L1xx_IT_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
PK
wFOTW inc/uart_comm.h#ifndef __UART_COMM_H
#define __UART_COMM_H
/* Includes ------------------------------------------------------------------*/
#include "stm32l1xx.h"
#include "stdio.h"
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* Exported macro ------------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */
void Uart_2_Comm_SendData_OneChar(uint8_t ch);
void Uart_2_Comm_SendData_Chars(uint8_t * ch_p, uint32_t data_size);
void Uart_3_Comm_SendData_OneChar(uint8_t ch);
void Uart_3_Comm_SendData_Chars(uint8_t * ch_p, uint32_t data_size);
//uint8_t UartComm_GetChar_Wait(void);
//int8_t UartComm_GetChar_Timeout(uint8_t * data_p);
/* External variables --------------------------------------------------------*/
#endif /* __UART_COMM_H */
PK
YFV, , inc/uart_queue.h#ifndef __UART_QUEUE_H
#define __UART_QUEUE_H
/* Includes */
#include "hw_config.h"
#include "global_types.h"
/* Exported constants */
/* Exported functions */
void UartQueue_Initialize(void);
// UART 2 Queue for Comm
bool Uart_2_Queue_Comm_Is_Empty(void);
uint32_t Uart_2_Queue_Comm_CurrSize(void);
void Uart_2_Queue_Comm_EnQueue(uint16_t data);
uint16_t Uart_2_Queue_Comm_DeQueue(void);
// UART 3 Queue for Comm
bool Uart_3_Queue_Comm_Is_Empty(void);
uint32_t Uart_3_Queue_Comm_CurrSize(void);
void Uart_3_Queue_Comm_EnQueue(uint16_t data);
uint16_t Uart_3_Queue_Comm_DeQueue(void);
// UART Queue for Serial
bool UartQueue_Serial_Is_Empty(void);
void UartQueue_Serial_EnQueue(uint16_t data);
uint16_t UartQueue_Serial_DeQueue(void);
#endif /* __UART_QUEUE_H */
PK
G
Libraries/PK
G Libraries/CMSIS/PK
놯D`Ra Ra 4 Libraries/CMSIS/CMSIS END USER LICENCE AGREEMENT.pdf%PDF-1.5
%
2 0 obj
<>>>
endobj
4 0 obj
<>stream
x=r7?ISei6<ɗd؊wS [ec[^ʮ@lǻ3 ĝܽ=hp4o_m7wh>:{}ůQ utߎoysNݶ9yӆ_lp|>lNfzMl7w经w1o{~8,e<J7'.0~ 6a<}İm1nAH&xǣtCt6Mu|9{9A/&pӶ/&g`# C{ð;əF1AoaxANòtg}aHB1Nvܡۆ?jɅ*ÔNLpPt*^D0|F=ns:j@]$u痊"vA[m(rw =2-Ўn;A7(G&-SxaЙN?Ѐ\}2Gބ^ʍ]Q[|v]c!ɏ~zFe3 O DIqxs2hG׆!~ڸ9oa aA
iZc\7ΰAj#!揟hz@+GT #D3ap?R6)ϐ -g?6!p56C+gh
cG.XqKi;֑g*NY g$Aq
ߜ#<tUv "N`yC^ޏ?W0m 6hu ZX(&Ah/"'~%WF1 wqǎl92OA&^ xú< XSwy &
ǿ~r0L@zV
@2S>-g
Jac7yJzA%S- jU̸\ndhלV`-76VP"(3[XO`ZBZ_D$,HJ,o69r z(8S"Ja
eLwa=80ab.ӭhw.L;Xa$۰62O ^EʗmhW1/,n(C}[30*0U@낎CK n _w˶{M~`f~W`0JvР|H.|mROCȋ) xVwF*%UJ'o#$>}AeS`ٓ7"Cv2T"&>߉"߀mtl${كc`xdxqU_@L[(ͶeT֤BӇx%
"<3a,{|kq?A5rxds
C8TK !:X%: "q٭m9|
KPr>`]:5/g;IEnC[3J"lXq]v(]h,nD.QkPT];M!R0eD
?]{;"U+hCmDM8aKM2ڱpퟶO[mI
%+ŕUFU)bJjJ7%(.
~pp3i1DKP˥_/q3L<