mirror of
https://github.com/espruino/Espruino.git
synced 2025-12-08 19:06:15 +00:00
hacks for TinyBLE board. No USART, but BLE
This commit is contained in:
parent
30c0941d19
commit
9362edb33c
@ -19,10 +19,10 @@ info = {
|
||||
'name' : "nRF51 Tag",
|
||||
'link' : [ "" ],
|
||||
'default_console' : "EV_SERIAL1",
|
||||
'default_console_tx' : "D17",
|
||||
'default_console_rx' : "D15",
|
||||
'default_console_tx' : "D15",
|
||||
'default_console_rx' : "D17",
|
||||
'default_console_baudrate' : "9600",
|
||||
'variables' : 200, # How many variables are allocated for Espruino to use. RAM will be overflowed if this number is too high and code won't compile.
|
||||
'variables' : 95, # How many variables are allocated for Espruino to use. RAM will be overflowed if this number is too high and code won't compile.
|
||||
'binary_name' : 'espruino_%v_nrf51tag.bin',
|
||||
};
|
||||
|
||||
@ -30,7 +30,7 @@ chip = {
|
||||
'part' : "NRF51822",
|
||||
'family' : "NRF51",
|
||||
'package' : "QFN48",
|
||||
'ram' : 32,
|
||||
'ram' : 16,
|
||||
'flash' : 256,
|
||||
'speed' : 16,
|
||||
'usart' : 1, #THIS IS INCORRECT!!!
|
||||
@ -40,13 +40,13 @@ chip = {
|
||||
'dac' : 0,
|
||||
};
|
||||
|
||||
# left-right, or top-bottom order THIS IS INCORRECT!!!!!
|
||||
board = {
|
||||
'left' : [ 'VDD', 'VDD', 'RESET', 'VDD','5V','GND','GND','PD3','PD4','PD28','PD29','PD30','PD31'],
|
||||
'right' : [ 'PD27', 'PD26', 'PD2', 'GND', 'PD25','PD24','PD23', 'PD22','PD20','PD19','PD18','PD17','PD16','PD15','PD14','PD13','PD12','PD11','PD10','PD9','PD8','PD7','PD6','PD5','PD21','PD1','PD0'],
|
||||
};
|
||||
|
||||
devices = {
|
||||
'LED1' : { 'pin' : 'D22' },
|
||||
'LED2' : { 'pin' : 'D21' },
|
||||
'LED3' : { 'pin' : 'D23' }
|
||||
};
|
||||
|
||||
board_css = """
|
||||
|
||||
@ -54,7 +54,7 @@ of beta. */
|
||||
#define APP_ADV_TIMEOUT_IN_SECONDS 180 /**< The advertising timeout (in units of seconds). */
|
||||
|
||||
#define APP_TIMER_PRESCALER 0 /**< Value of the RTC1 PRESCALER register. */
|
||||
#define APP_TIMER_MAX_TIMERS (2 /*+ BSP_APP_TIMERS_NUMBER*/) /**< Maximum number of simultaneously created timers. */
|
||||
#define APP_TIMER_MAX_TIMERS (2 + 2/*+ BSP_APP_TIMERS_NUMBER*/) /**< Maximum number of simultaneously created timers. */
|
||||
#define APP_TIMER_OP_QUEUE_SIZE 4 /**< Size of timer operation queues. */
|
||||
|
||||
#define MIN_CONN_INTERVAL MSEC_TO_UNITS(20, UNIT_1_25_MS) /**< Minimum acceptable connection interval (20 ms), Connection interval uses 1.25 ms units. */
|
||||
@ -134,6 +134,7 @@ static void nus_data_handler(ble_nus_t * p_nus, uint8_t * p_data, uint16_t lengt
|
||||
for (i = 0; i < length; i++) {
|
||||
jshPushIOCharEvent(EV_USBSERIAL, (char) p_data[i]);
|
||||
}
|
||||
if (length>0) jshPushIOCharEvent(EV_USBSERIAL,'\n');
|
||||
}
|
||||
/**@snippet [Handling the data received over BLE] */
|
||||
|
||||
@ -449,7 +450,7 @@ void jswrap_nrf_bluetooth_init(void)
|
||||
|
||||
// Initialize.
|
||||
APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_MAX_TIMERS, APP_TIMER_OP_QUEUE_SIZE, false);
|
||||
buttons_leds_init(&erase_bonds);
|
||||
//buttons_leds_init(&erase_bonds);
|
||||
ble_stack_init();
|
||||
gap_params_init();
|
||||
services_init();
|
||||
@ -513,6 +514,6 @@ bool jswrap_nrf_idle() {
|
||||
buf[idx++] = ch;
|
||||
ch = jshGetCharToTransmit(EV_USBSERIAL);
|
||||
}
|
||||
ble_nus_string_send(&m_nus, buf, idx);
|
||||
if (idx>0) ble_nus_string_send(&m_nus, buf, idx);
|
||||
return idx>0;
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@ GROUP(-lgcc -lc -lnosys)
|
||||
MEMORY
|
||||
{
|
||||
FLASH (rx) : ORIGIN = 0x18000, LENGTH = 0x28000
|
||||
RAM (rwx) : ORIGIN = 0x20002000, LENGTH = 0x6000
|
||||
RAM (rwx) : ORIGIN = 0x20002000, LENGTH = 0x2000
|
||||
}
|
||||
|
||||
INCLUDE "gcc_nrf5x_espruino_common.ld"
|
||||
|
||||
@ -26,8 +26,8 @@
|
||||
#include "app_uart.h"
|
||||
|
||||
#define MAX_TEST_DATA_BYTES (15U)
|
||||
#define UART_TX_BUF_SIZE 64 /**< UART TX buffer size. */
|
||||
#define UART_RX_BUF_SIZE 32 /**< UART RX buffer size. */
|
||||
#define UART_TX_BUF_SIZE 16 /**< UART TX buffer size. */
|
||||
#define UART_RX_BUF_SIZE 16 /**< UART RX buffer size. */
|
||||
|
||||
// UART callback function. Registered in uart_init(). Allows to asynchronously read characters from UART.
|
||||
void uart_event_handle(app_uart_evt_t * p_event);
|
||||
|
||||
@ -41,6 +41,8 @@ void jshInit()
|
||||
jshUSARTSetup(EV_SERIAL1, &inf); // Initialize UART for communication with Espruino/terminal.
|
||||
init = 1;
|
||||
|
||||
//
|
||||
|
||||
}
|
||||
|
||||
// When 'reset' is called - we try and put peripherals back to their power-on state
|
||||
@ -54,9 +56,20 @@ void jshKill()
|
||||
|
||||
}
|
||||
|
||||
static int cnt = 0;
|
||||
|
||||
// stuff to do on idle
|
||||
void jshIdle()
|
||||
{
|
||||
cnt++;
|
||||
if (cnt==1000) {
|
||||
jswrap_nrf_bluetooth_init();
|
||||
jsiSetConsoleDevice( EV_USBSERIAL);
|
||||
}
|
||||
#ifdef LED1_PININDEX
|
||||
// turn led on (status)
|
||||
jshPinOutput(LED1_PININDEX, (cnt>>5)&1);
|
||||
#endif
|
||||
if (init == 1)
|
||||
{
|
||||
jsiOneSecondAfterStartup(); // Do this the first time we enter jshIdle() after we have called jshInit() and never again.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user