Compare commits
11 Commits
ble_uart
...
dev/MMMv1.0
| Author | SHA1 | Date | |
|---|---|---|---|
| 5939c83e07 | |||
| 13a3bc2bac | |||
| 057cd37031 | |||
| 2fe3c96281 | |||
| 8c90802ce3 | |||
| 0cd2355014 | |||
| 41decad72e | |||
| 57e6ab5af2 | |||
| 453278fa33 | |||
| b94ad89af7 | |||
| 41227c9877 |
+47
-2
@@ -109,7 +109,8 @@ extern "C"
|
||||
#define DEF_ELITE_EDC_V2_0 0x00020109
|
||||
#define DEF_ELITE_PEL_V2_0 0x00070001
|
||||
#define DEF_ELITE_CPG_V1_1 0x00080001
|
||||
#define DEF_ELITE_MODEL DEF_ELITE_DEV
|
||||
#define DEF_ELITE_MMM_V1_0 0x00090001
|
||||
#define DEF_ELITE_MODEL DEF_ELITE_MMM_V1_0
|
||||
|
||||
#define DEF_ELITE_DEMO_W_SOFTDEVICE 0
|
||||
|
||||
@@ -148,6 +149,8 @@ extern "C"
|
||||
|
||||
#define DEF_USBD_ENABLED 1
|
||||
|
||||
#define DEF_UART_ENABLED 0
|
||||
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_EDC_V2_0)
|
||||
#define ELITE_DEVICE_NAME "Elite-EDC"
|
||||
#define ELITE_HW_NAME "Elite-EDCv2.0"
|
||||
@@ -183,6 +186,8 @@ extern "C"
|
||||
|
||||
#define DEF_USBD_ENABLED 1
|
||||
|
||||
#define DEF_UART_ENABLED 0
|
||||
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_PEL_V2_0)
|
||||
#define BOARD_IOPH 1
|
||||
#define BOARD_IOPL 0
|
||||
@@ -222,6 +227,8 @@ extern "C"
|
||||
|
||||
#define DEF_USBD_ENABLED 1
|
||||
|
||||
#define DEF_UART_ENABLED 0
|
||||
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_CPG_V1_1)
|
||||
#define ELITE_DEVICE_NAME "Elite-CPG"
|
||||
#define ELITE_HW_NAME "Elite-CPGv1.1"
|
||||
@@ -257,6 +264,45 @@ extern "C"
|
||||
|
||||
#define DEF_USBD_ENABLED 1
|
||||
|
||||
#define DEF_UARTE_ENABLED 0
|
||||
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_MMM_V1_0)
|
||||
#define ELITE_DEVICE_NAME "Elite-MMM"
|
||||
#define ELITE_HW_NAME "Elite-MMM"
|
||||
#define MAJOR_PRODUCT_NUMBER 0
|
||||
#define MINOR_PRODUCT_NUMBER 9
|
||||
#define MAJOR_VERSION_NUMBER 0
|
||||
#define MINOR_VERSION_NUMBER 1
|
||||
|
||||
#define DEF_TW1508_ENABLED 0
|
||||
|
||||
#define DEF_LED_COUNT 0
|
||||
#define DEF_LED_DRV_ENABLED 0
|
||||
#define DEF_APA102_2020_ENABLED 0
|
||||
|
||||
#define DEF_ADC_DRV_ENABLED 0
|
||||
#define DEF_ADS8691_ENABLED 0
|
||||
#define DEF_BULTIN_ADC_ENABED 0
|
||||
|
||||
#define DEF_DAC_DRV_ENABLED 0
|
||||
#define DEF_MAX5136_ENABLED 0
|
||||
|
||||
#define DEF_SW_DRV_ENABLED 0
|
||||
#define DEF_MAX14802_ENABLED 0
|
||||
#define DEF_ADGS1412_ENABLED 0
|
||||
|
||||
#define DEF_FS_ENABLED 0
|
||||
#define DEF_FS_RTT_DIR 0
|
||||
#define DEF_GD25D10C_ENABLED 0
|
||||
|
||||
#define DEF_BTN_ENABLED 0
|
||||
|
||||
#define DEF_RTT_JSCOP_ENABLED 0
|
||||
|
||||
#define DEF_USBD_ENABLED 1
|
||||
|
||||
#define DEF_UARTE_ENABLED 1
|
||||
|
||||
#endif
|
||||
|
||||
#define BLE_ELITE_SRV_ENABLED 1
|
||||
@@ -294,7 +340,6 @@ extern "C"
|
||||
#define BLE_UART_SRV_ENABLED 1
|
||||
#define BLE_UART_OBSERVER_PRIO 3
|
||||
#define NRF_UARTE_ENABLED 1
|
||||
#define DEF_UARTE_ENABLED 1
|
||||
|
||||
// DFU
|
||||
#define NRF_DFU_TRANSPORT_BLE 1
|
||||
|
||||
@@ -205,6 +205,7 @@
|
||||
<ClCompile Include="dac_drv.c" />
|
||||
<ClCompile Include="elite_dev.c" />
|
||||
<ClCompile Include="edc20_cycle_iv_mode.c" />
|
||||
<ClCompile Include="elite_mmm.c" />
|
||||
<ClCompile Include="fs.c" />
|
||||
<ClCompile Include="gd25d10c.c" />
|
||||
<ClCompile Include="le_uart_srv.c" />
|
||||
@@ -233,6 +234,7 @@
|
||||
<ClCompile Include="uart.drv.c" />
|
||||
<ClCompile Include="usbd.c" />
|
||||
<ClCompile Include="usbd_dfu_trigger.c" />
|
||||
<ClInclude Include="elite_mmm.h" />
|
||||
<ClInclude Include="le_uart_srv.h" />
|
||||
<ClInclude Include="max14802.h" />
|
||||
<ClInclude Include="pel20_io.h" />
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
#include "pel.h"
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_CPG_V1_1)
|
||||
#include "cpg.h"
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_MMM_V1_0)
|
||||
#include "elite_mmm.h"
|
||||
#else
|
||||
#error "Unknown DEF_ELITE_MODEL"
|
||||
#endif
|
||||
@@ -109,6 +111,8 @@ void elite_init(void)
|
||||
p_instance = pel_init();
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_CPG_V1_1)
|
||||
p_instance = cpg_init();
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_MMM_V1_0)
|
||||
p_instance = mmm_init();
|
||||
#else
|
||||
#error "Unknown DEF_ELITE_MODEL"
|
||||
#endif
|
||||
|
||||
@@ -23,6 +23,7 @@ extern "C"
|
||||
#include "pel20_io.h"
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_CPG_V1_1)
|
||||
#include "cpg11_io.h"
|
||||
#elif (DEF_ELITE_MODEL == DEF_ELITE_MMM_V1_0)
|
||||
#else
|
||||
#error "Not implemented xxx_io.h"
|
||||
#endif
|
||||
|
||||
+256
@@ -0,0 +1,256 @@
|
||||
#include "elite_mmm.h"
|
||||
|
||||
#include "nrf_gpio.h"
|
||||
#include "nrf_log.h"
|
||||
|
||||
#if (DEF_ELITE_MODEL == DEF_ELITE_MMM_V1_0)
|
||||
|
||||
#define VERSION_DATE_YEAR 25
|
||||
#define VERSION_DATE_MONTH 6
|
||||
#define VERSION_DATE_DAY 4
|
||||
#define VERSION_DATE_HOUR 16
|
||||
#define VERSION_DATE_MINUTE 44
|
||||
static void cis_version(uint8_t *ins, uint16_t size)
|
||||
{
|
||||
NRF_LOG_INFO("%s", __FUNCTION__);
|
||||
uint8_t cis_ver[] = {
|
||||
CIS_VERSION,
|
||||
VERSION_DATE_YEAR,
|
||||
VERSION_DATE_MONTH,
|
||||
VERSION_DATE_DAY,
|
||||
VERSION_DATE_HOUR,
|
||||
VERSION_DATE_MINUTE,
|
||||
};
|
||||
extern ret_code_t le_data_update(uint8_t * p_value, uint16_t len);
|
||||
le_data_update((void *)cis_ver, sizeof(cis_ver));
|
||||
}
|
||||
|
||||
static void vis_rst(uint8_t *ins, uint16_t size)
|
||||
{
|
||||
NRF_LOG_INFO("%s", __FUNCTION__);
|
||||
}
|
||||
|
||||
#define UNDEF_GPIO 0xFFFFFFFF
|
||||
|
||||
// The GPIO corresponding to the pin
|
||||
const uint32_t pin_to_gpio_table[] = {
|
||||
[6] = NRF_GPIO_PIN_MAP(0, 22),
|
||||
[8] = NRF_GPIO_PIN_MAP(0, 25),
|
||||
[9] = NRF_GPIO_PIN_MAP(0, 19),
|
||||
[10] = NRF_GPIO_PIN_MAP(0, 21),
|
||||
[11] = NRF_GPIO_PIN_MAP(1, 00),
|
||||
[12] = NRF_GPIO_PIN_MAP(0, 18),
|
||||
[13] = NRF_GPIO_PIN_MAP(0, 17),
|
||||
[14] = NRF_GPIO_PIN_MAP(0, 20),
|
||||
[16] = NRF_GPIO_PIN_MAP(0, 14),
|
||||
[17] = NRF_GPIO_PIN_MAP(0, 13),
|
||||
[18] = NRF_GPIO_PIN_MAP(0, 11),
|
||||
[20] = NRF_GPIO_PIN_MAP(0, 15),
|
||||
[25] = NRF_GPIO_PIN_MAP(1, 8),
|
||||
[26] = NRF_GPIO_PIN_MAP(0, 12),
|
||||
[27] = NRF_GPIO_PIN_MAP(0, 7),
|
||||
[28] = NRF_GPIO_PIN_MAP(1, 9),
|
||||
[29] = NRF_GPIO_PIN_MAP(0, 8),
|
||||
[30] = NRF_GPIO_PIN_MAP(0, 6),
|
||||
[31] = NRF_GPIO_PIN_MAP(0, 5),
|
||||
[32] = NRF_GPIO_PIN_MAP(0, 27),
|
||||
[33] = NRF_GPIO_PIN_MAP(0, 26),
|
||||
[34] = NRF_GPIO_PIN_MAP(0, 4),
|
||||
[36] = NRF_GPIO_PIN_MAP(0, 1),
|
||||
[37] = NRF_GPIO_PIN_MAP(0, 29),
|
||||
[38] = NRF_GPIO_PIN_MAP(0, 0),
|
||||
[39] = NRF_GPIO_PIN_MAP(0, 31),
|
||||
[40] = NRF_GPIO_PIN_MAP(1, 15),
|
||||
[41] = NRF_GPIO_PIN_MAP(0, 2),
|
||||
[42] = NRF_GPIO_PIN_MAP(0, 30),
|
||||
[43] = NRF_GPIO_PIN_MAP(0, 28),
|
||||
[44] = NRF_GPIO_PIN_MAP(1, 12),
|
||||
[45] = NRF_GPIO_PIN_MAP(1, 14),
|
||||
[46] = NRF_GPIO_PIN_MAP(0, 3),
|
||||
[47] = NRF_GPIO_PIN_MAP(1, 13),
|
||||
[48] = NRF_GPIO_PIN_MAP(1, 3),
|
||||
[49] = NRF_GPIO_PIN_MAP(1, 10),
|
||||
[50] = NRF_GPIO_PIN_MAP(1, 6),
|
||||
[51] = NRF_GPIO_PIN_MAP(1, 11),
|
||||
[52] = NRF_GPIO_PIN_MAP(0, 10),
|
||||
[53] = NRF_GPIO_PIN_MAP(0, 9),
|
||||
[59] = NRF_GPIO_PIN_MAP(1, 2),
|
||||
[60] = NRF_GPIO_PIN_MAP(0, 24),
|
||||
[61] = NRF_GPIO_PIN_MAP(0, 23),
|
||||
[62] = NRF_GPIO_PIN_MAP(0, 16),
|
||||
};
|
||||
|
||||
static uint32_t bmd380pins_convert_to_gpio(uint32_t pin)
|
||||
{
|
||||
uint32_t gpio;
|
||||
|
||||
switch (pin)
|
||||
{
|
||||
case 6:
|
||||
case 8:
|
||||
case 9:
|
||||
case 10:
|
||||
case 11:
|
||||
case 12:
|
||||
case 13:
|
||||
case 14:
|
||||
case 16:
|
||||
case 17:
|
||||
case 18:
|
||||
case 20:
|
||||
case 25:
|
||||
case 26:
|
||||
case 27:
|
||||
case 28:
|
||||
case 29:
|
||||
case 30:
|
||||
case 31:
|
||||
case 32:
|
||||
case 33:
|
||||
case 34:
|
||||
case 36:
|
||||
case 37:
|
||||
case 38:
|
||||
case 39:
|
||||
case 40:
|
||||
case 41:
|
||||
case 42:
|
||||
case 43:
|
||||
case 44:
|
||||
case 45:
|
||||
case 46:
|
||||
case 47:
|
||||
case 48:
|
||||
case 49:
|
||||
case 50:
|
||||
case 51:
|
||||
case 52:
|
||||
case 53:
|
||||
case 59:
|
||||
case 60:
|
||||
case 61:
|
||||
case 62:
|
||||
gpio = pin_to_gpio_table[pin];
|
||||
break;
|
||||
default:
|
||||
gpio = UNDEF_GPIO;
|
||||
NRF_LOG_INFO("UNDEF_GPIO: pin %d can't convert to gpio number", pin);
|
||||
break;
|
||||
}
|
||||
|
||||
return gpio;
|
||||
}
|
||||
|
||||
static void set_bmd380_pin_signal(uint32_t pin, uint32_t high_low)
|
||||
{
|
||||
uint32_t gpio = bmd380pins_convert_to_gpio(pin);
|
||||
|
||||
if (gpio != UNDEF_GPIO)
|
||||
{
|
||||
nrf_gpio_cfg_output(gpio);
|
||||
nrf_gpio_pin_write(gpio, high_low);
|
||||
NRF_LOG_INFO("set pin %d (gpio %d) = %d", pin, gpio, high_low);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
dev_mode_gpio_function
|
||||
(1)0x3000FFA000ppss
|
||||
-func: set_bmd380_pin_signal
|
||||
-pp: pin number 06h-3Fh
|
||||
06h: P0.22_GPIO
|
||||
08h: P0.25_GPIO
|
||||
......
|
||||
3Eh: P0.16_GPIO
|
||||
-ss: signal 00h-01h
|
||||
00h: low
|
||||
01h: high
|
||||
|
||||
(2)0x3000FFA001ss
|
||||
-func: set_bmd380 all pin signal high/low
|
||||
-ss: signal 00h-01h
|
||||
00h: low
|
||||
01h: high
|
||||
*/
|
||||
void dev_mode_gpio_function(uint8_t *ins)
|
||||
{
|
||||
struct __PACKED
|
||||
{
|
||||
uint8_t id : 4;
|
||||
uint8_t : 4;
|
||||
uint16_t magic : 16;
|
||||
uint8_t dev_opcode;
|
||||
uint8_t gpio_function_opcode;
|
||||
uint8_t param[];
|
||||
} *p_ins = (void *)ins;
|
||||
|
||||
switch (p_ins->gpio_function_opcode)
|
||||
{
|
||||
case 0x00: {
|
||||
uint32_t pin = p_ins->param[0];
|
||||
uint32_t high_low = p_ins->param[1];
|
||||
set_bmd380_pin_signal(pin, high_low);
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x01: {
|
||||
uint32_t high_low = p_ins->param[0];
|
||||
uint32_t set_pin[44] = { 6, 8, 9, 10, 11, 12, 13, 14, 16, 17, 18, 20, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 59, 60, 61, 62 };
|
||||
|
||||
for (int i = 0; i < sizeof(set_pin) / sizeof(set_pin[0]); i++)
|
||||
{
|
||||
set_bmd380_pin_signal(set_pin[i], high_low);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#define MAGIC_NUM 0xFF00
|
||||
static void dev_mode(uint8_t *ins, uint16_t size)
|
||||
{
|
||||
NRF_LOG_INFO("%s", __FUNCTION__);
|
||||
struct __PACKED
|
||||
{
|
||||
uint8_t id : 4;
|
||||
uint8_t : 4;
|
||||
uint16_t magic : 16;
|
||||
uint8_t opcode;
|
||||
uint8_t param[];
|
||||
} *p_ins = (void *)ins;
|
||||
|
||||
if (p_ins->magic != MAGIC_NUM)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO...
|
||||
switch (p_ins->opcode)
|
||||
{
|
||||
case 0xA0:
|
||||
dev_mode_gpio_function(ins);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const elite_instance_t mmm_elite_instance = {
|
||||
.cis_func = {
|
||||
[CIS_VERSION] = cis_version,
|
||||
},
|
||||
.vis_func = {
|
||||
[VIS_RST] = vis_rst,
|
||||
},
|
||||
.ris_func = {
|
||||
[DEV_MODE] = dev_mode,
|
||||
}
|
||||
};
|
||||
|
||||
const elite_instance_t *mmm_init(void)
|
||||
{
|
||||
return &mmm_elite_instance;
|
||||
}
|
||||
|
||||
#endif /* !DEF_ELITE_MODEL */
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
#ifndef __ELITE_MMM_H__
|
||||
#define __ELITE_MMM_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include "app_config.h"
|
||||
#include "elite.h"
|
||||
|
||||
const elite_instance_t *mmm_init(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ! __ELITE_MMM_H__ */
|
||||
+10
-13
@@ -27,10 +27,10 @@ extern "C"
|
||||
|
||||
#if NRF_MODULE_ENABLED(BLE_UART_SRV)
|
||||
|
||||
#define BLE_UUID_UART_SERVICE 0x0001 /**< The UUID of the Service. */
|
||||
#define BLE_UUID_UART_RX_CHAR 0x0002 /**< The UUID of the RX Characteristic. */
|
||||
#define BLE_UUID_UART_TX_CHAR 0x0003 /**< The UUID of the TX Characteristic. */
|
||||
#define BLE_UUID_UART_BAUD_CHAR 0x0004 /**< The UUID of the Baud Characteristic. */
|
||||
#define BLE_UUID_UART_SERVICE 0xFFF8 /**< The UUID of the Service. */
|
||||
#define BLE_UUID_UART_RX_CHAR 0xFFF9 /**< The UUID of the RX Characteristic. */
|
||||
#define BLE_UUID_UART_TX_CHAR 0xFFFA /**< The UUID of the TX Characteristic. */
|
||||
#define BLE_UUID_UART_BAUD_CHAR 0xFFFB /**< The UUID of the Baud Characteristic. */
|
||||
|
||||
#define BLE_UART_BASE_UUID \
|
||||
{ \
|
||||
@@ -197,20 +197,17 @@ static ret_code_t add_baud_characteristic(uint16_t uuid, uint8_t uuid_type, ble_
|
||||
void le_uart_srv_init(void)
|
||||
{
|
||||
ret_code_t err_code;
|
||||
ble_uuid128_t nus_base_uuid = BLE_UART_BASE_UUID;
|
||||
uint8_t uuid_type = 0;
|
||||
ble_uuid_t ble_uuid;
|
||||
uint8_t uuid_type = 0;
|
||||
|
||||
/**@snippet [Adding proprietary Service to the SoftDevice] */
|
||||
|
||||
// Add a custom base UUID.
|
||||
err_code = sd_ble_uuid_vs_add(&nus_base_uuid, &uuid_type);
|
||||
APP_ERROR_CHECK(err_code);
|
||||
ble_uuid_t ble_uuid = {
|
||||
.type = BLE_UUID_TYPE_BLE,
|
||||
.uuid = BLE_UUID_UART_SERVICE,
|
||||
};
|
||||
|
||||
// Add the service.
|
||||
ble_uuid.type = uuid_type;
|
||||
ble_uuid.uuid = BLE_UUID_UART_SERVICE;
|
||||
err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY,
|
||||
err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY,
|
||||
&ble_uuid,
|
||||
&ble_uart_context.service_handle);
|
||||
APP_ERROR_CHECK(err_code);
|
||||
|
||||
+1
-1
@@ -207,7 +207,7 @@ void uart_init(void)
|
||||
NRF_UARTE0->PSEL.RXD = UART_RX_PIN | (UARTE_PSEL_RXD_CONNECT_Connected << UARTE_PSEL_RXD_CONNECT_Pos);
|
||||
NRF_UARTE0->PSEL.CTS = 0;
|
||||
NRF_UARTE0->PSEL.RTS = 0;
|
||||
NRF_UARTE0->CONFIG = UARTE_CONFIG_STOP_Msk;
|
||||
NRF_UARTE0->CONFIG = 0;
|
||||
NRF_UARTE0->BAUDRATE = UARTE_BAUDRATE_BAUDRATE_Baud115200;
|
||||
NRF_UARTE0->ENABLE = UARTE_ENABLE_ENABLE_Enabled;
|
||||
|
||||
|
||||
+4
-3
@@ -16,9 +16,10 @@ extern "C"
|
||||
int uart_recv(void *p_data, uint32_t max_size);
|
||||
ret_code_t uart_set_baud(uint32_t baudrate);
|
||||
#else
|
||||
#define uart_init()
|
||||
#define uart_send(...) ;
|
||||
#define uart_recv(...) ;
|
||||
#define uart_init()
|
||||
#define uart_send(...) ;
|
||||
#define uart_recv(...) ;
|
||||
#define uart_set_baud(...)
|
||||
#endif /* ! DEF_UARTE_ENABLED */
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
Reference in New Issue
Block a user