RCBControllerでモータを制御します。うおーるぼっとも動かせました。
Dependencies: BLE_API_Native_IRC TB6612FNG2 mbed
Fork of BLE_RCBController by
- 古いBLEライブラリを使っているのでプラットフォームは”Nordic nRF51822”を選択してください。
- ライブラリ類はUpdateしないでください。コンパイルエラーになります。
うまく接続できない時は、iPhone/iPadのBluetoothをOFF->ONしてキャッシュをクリアしてみてください。
RCBControllerでうおーるぼっとを操縦する例
RCBControllerでの操縦は次の4種類あります。 それぞれうおーるぼっとの動きが異なりますので試してみてください。
- 左十字ボタン
- 左のみアナログ
- 右のみアナログ
- 両方アナログ
うおーるぼっと(LPC1768のソケット)とHRM1017の接続はこれです。
LPC1768 ー HRM1017
p11 ーーー P0_0
p12 ーーー P0_1
p13 ーーー P0_28
p14 ーーー P0_29
p21 ーーー P0_30
p22 ーーー P0_25
GND ーーー GND
HRM1017の電源はうおーるぼっとのUSBコネクタからとります。
BLE_API_Native_IRC/hw/nRF51822n/nordic/nrf-sdk/app_common/hci_mem_pool.h@0:8c643bfe55b7, 2014-07-10 (annotated)
- Committer:
- jksoft
- Date:
- Thu Jul 10 14:21:52 2014 +0000
- Revision:
- 0:8c643bfe55b7
??
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jksoft | 0:8c643bfe55b7 | 1 | /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. |
jksoft | 0:8c643bfe55b7 | 2 | * |
jksoft | 0:8c643bfe55b7 | 3 | * The information contained herein is property of Nordic Semiconductor ASA. |
jksoft | 0:8c643bfe55b7 | 4 | * Terms and conditions of usage are described in detail in NORDIC |
jksoft | 0:8c643bfe55b7 | 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. |
jksoft | 0:8c643bfe55b7 | 6 | * |
jksoft | 0:8c643bfe55b7 | 7 | * Licensees are granted free, non-transferable use of the information. NO |
jksoft | 0:8c643bfe55b7 | 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from |
jksoft | 0:8c643bfe55b7 | 9 | * the file. |
jksoft | 0:8c643bfe55b7 | 10 | * |
jksoft | 0:8c643bfe55b7 | 11 | */ |
jksoft | 0:8c643bfe55b7 | 12 | |
jksoft | 0:8c643bfe55b7 | 13 | /** @file |
jksoft | 0:8c643bfe55b7 | 14 | * |
jksoft | 0:8c643bfe55b7 | 15 | * @defgroup memory_pool Memory pool |
jksoft | 0:8c643bfe55b7 | 16 | * @{ |
jksoft | 0:8c643bfe55b7 | 17 | * @ingroup app_common |
jksoft | 0:8c643bfe55b7 | 18 | * |
jksoft | 0:8c643bfe55b7 | 19 | * @brief Memory pool implementation |
jksoft | 0:8c643bfe55b7 | 20 | * |
jksoft | 0:8c643bfe55b7 | 21 | * Memory pool implementation, based on circular buffer data structure, which supports asynchronous |
jksoft | 0:8c643bfe55b7 | 22 | * processing of RX data. The current default implementation supports 1 TX buffer and 4 RX buffers. |
jksoft | 0:8c643bfe55b7 | 23 | * The memory managed by the pool is allocated from static storage instead of heap. The internal |
jksoft | 0:8c643bfe55b7 | 24 | * design of the circular buffer implementing the RX memory layout is illustrated in the picture |
jksoft | 0:8c643bfe55b7 | 25 | * below. |
jksoft | 0:8c643bfe55b7 | 26 | * |
jksoft | 0:8c643bfe55b7 | 27 | * @image html memory_pool.png "Circular buffer design" |
jksoft | 0:8c643bfe55b7 | 28 | * |
jksoft | 0:8c643bfe55b7 | 29 | * The expected call order for the RX APIs is as follows: |
jksoft | 0:8c643bfe55b7 | 30 | * - hci_mem_pool_rx_produce |
jksoft | 0:8c643bfe55b7 | 31 | * - hci_mem_pool_rx_data_size_set |
jksoft | 0:8c643bfe55b7 | 32 | * - hci_mem_pool_rx_extract |
jksoft | 0:8c643bfe55b7 | 33 | * - hci_mem_pool_rx_consume |
jksoft | 0:8c643bfe55b7 | 34 | * |
jksoft | 0:8c643bfe55b7 | 35 | * @warning If the above mentioned expected call order is violated the end result can be undefined. |
jksoft | 0:8c643bfe55b7 | 36 | * |
jksoft | 0:8c643bfe55b7 | 37 | * \par Component specific configuration options |
jksoft | 0:8c643bfe55b7 | 38 | * |
jksoft | 0:8c643bfe55b7 | 39 | * The following compile time configuration options are available to suit various implementations: |
jksoft | 0:8c643bfe55b7 | 40 | * - TX_BUF_SIZE TX buffer size in bytes. |
jksoft | 0:8c643bfe55b7 | 41 | * - RX_BUF_SIZE RX buffer size in bytes. |
jksoft | 0:8c643bfe55b7 | 42 | * - RX_BUF_QUEUE_SIZE RX buffer element size. |
jksoft | 0:8c643bfe55b7 | 43 | */ |
jksoft | 0:8c643bfe55b7 | 44 | |
jksoft | 0:8c643bfe55b7 | 45 | #ifndef HCI_MEM_POOL_H__ |
jksoft | 0:8c643bfe55b7 | 46 | #define HCI_MEM_POOL_H__ |
jksoft | 0:8c643bfe55b7 | 47 | |
jksoft | 0:8c643bfe55b7 | 48 | #include <stdint.h> |
jksoft | 0:8c643bfe55b7 | 49 | #include "nordic_global.h" |
jksoft | 0:8c643bfe55b7 | 50 | #include "nrf_error.h" |
jksoft | 0:8c643bfe55b7 | 51 | |
jksoft | 0:8c643bfe55b7 | 52 | /**@brief Function for opening the module. |
jksoft | 0:8c643bfe55b7 | 53 | * |
jksoft | 0:8c643bfe55b7 | 54 | * @retval NRF_SUCCESS Operation success. |
jksoft | 0:8c643bfe55b7 | 55 | */ |
jksoft | 0:8c643bfe55b7 | 56 | uint32_t hci_mem_pool_open(void); |
jksoft | 0:8c643bfe55b7 | 57 | |
jksoft | 0:8c643bfe55b7 | 58 | /**@brief Function for closing the module. |
jksoft | 0:8c643bfe55b7 | 59 | * |
jksoft | 0:8c643bfe55b7 | 60 | * @retval NRF_SUCCESS Operation success. |
jksoft | 0:8c643bfe55b7 | 61 | */ |
jksoft | 0:8c643bfe55b7 | 62 | uint32_t hci_mem_pool_close(void); |
jksoft | 0:8c643bfe55b7 | 63 | |
jksoft | 0:8c643bfe55b7 | 64 | /**@brief Function for allocating requested amount of TX memory. |
jksoft | 0:8c643bfe55b7 | 65 | * |
jksoft | 0:8c643bfe55b7 | 66 | * @param[out] pp_buffer Pointer to the allocated memory. |
jksoft | 0:8c643bfe55b7 | 67 | * |
jksoft | 0:8c643bfe55b7 | 68 | * @retval NRF_SUCCESS Operation success. Memory was allocated. |
jksoft | 0:8c643bfe55b7 | 69 | * @retval NRF_ERROR_NO_MEM Operation failure. No memory available for allocation. |
jksoft | 0:8c643bfe55b7 | 70 | * @retval NRF_ERROR_NULL Operation failure. NULL pointer supplied. |
jksoft | 0:8c643bfe55b7 | 71 | */ |
jksoft | 0:8c643bfe55b7 | 72 | uint32_t hci_mem_pool_tx_alloc(void ** pp_buffer); |
jksoft | 0:8c643bfe55b7 | 73 | |
jksoft | 0:8c643bfe55b7 | 74 | /**@brief Function for freeing previously allocated TX memory. |
jksoft | 0:8c643bfe55b7 | 75 | * |
jksoft | 0:8c643bfe55b7 | 76 | * @note Memory management follows the FIFO principle meaning that free() order must match the |
jksoft | 0:8c643bfe55b7 | 77 | * alloc(...) order, which is the reason for omitting exact memory block identifier as an |
jksoft | 0:8c643bfe55b7 | 78 | * input parameter. |
jksoft | 0:8c643bfe55b7 | 79 | * |
jksoft | 0:8c643bfe55b7 | 80 | * @retval NRF_SUCCESS Operation success. Memory was freed. |
jksoft | 0:8c643bfe55b7 | 81 | */ |
jksoft | 0:8c643bfe55b7 | 82 | uint32_t hci_mem_pool_tx_free(void); |
jksoft | 0:8c643bfe55b7 | 83 | |
jksoft | 0:8c643bfe55b7 | 84 | /**@brief Function for producing a free RX memory block for usage. |
jksoft | 0:8c643bfe55b7 | 85 | * |
jksoft | 0:8c643bfe55b7 | 86 | * @note Upon produce request amount being 0, NRF_SUCCESS is returned. |
jksoft | 0:8c643bfe55b7 | 87 | * |
jksoft | 0:8c643bfe55b7 | 88 | * @param[in] length Amount, in bytes, of free memory to be produced. |
jksoft | 0:8c643bfe55b7 | 89 | * @param[out] pp_buffer Pointer to the allocated memory. |
jksoft | 0:8c643bfe55b7 | 90 | * |
jksoft | 0:8c643bfe55b7 | 91 | * @retval NRF_SUCCESS Operation success. Free RX memory block produced. |
jksoft | 0:8c643bfe55b7 | 92 | * @retval NRF_ERROR_NO_MEM Operation failure. No suitable memory available for allocation. |
jksoft | 0:8c643bfe55b7 | 93 | * @retval NRF_ERROR_DATA_SIZE Operation failure. Request size exceeds limit. |
jksoft | 0:8c643bfe55b7 | 94 | * @retval NRF_ERROR_NULL Operation failure. NULL pointer supplied. |
jksoft | 0:8c643bfe55b7 | 95 | */ |
jksoft | 0:8c643bfe55b7 | 96 | uint32_t hci_mem_pool_rx_produce(uint32_t length, void ** pp_buffer); |
jksoft | 0:8c643bfe55b7 | 97 | |
jksoft | 0:8c643bfe55b7 | 98 | /**@brief Function for setting the length of the last produced RX memory block. |
jksoft | 0:8c643bfe55b7 | 99 | * |
jksoft | 0:8c643bfe55b7 | 100 | * @warning If call to this API is omitted the end result is that the following call to |
jksoft | 0:8c643bfe55b7 | 101 | * mem_pool_rx_extract will return incorrect data in the p_length output parameter. |
jksoft | 0:8c643bfe55b7 | 102 | * |
jksoft | 0:8c643bfe55b7 | 103 | * @param[in] length Amount, in bytes, of actual memory used. |
jksoft | 0:8c643bfe55b7 | 104 | * |
jksoft | 0:8c643bfe55b7 | 105 | * @retval NRF_SUCCESS Operation success. Length was set. |
jksoft | 0:8c643bfe55b7 | 106 | */ |
jksoft | 0:8c643bfe55b7 | 107 | uint32_t hci_mem_pool_rx_data_size_set(uint32_t length); |
jksoft | 0:8c643bfe55b7 | 108 | |
jksoft | 0:8c643bfe55b7 | 109 | /**@brief Function for extracting a packet, which has been filled with read data, for further |
jksoft | 0:8c643bfe55b7 | 110 | * processing. |
jksoft | 0:8c643bfe55b7 | 111 | * |
jksoft | 0:8c643bfe55b7 | 112 | * @param[out] pp_buffer Pointer to the packet data. |
jksoft | 0:8c643bfe55b7 | 113 | * @param[out] p_length Length of packet data in bytes. |
jksoft | 0:8c643bfe55b7 | 114 | * |
jksoft | 0:8c643bfe55b7 | 115 | * @retval NRF_SUCCESS Operation success. |
jksoft | 0:8c643bfe55b7 | 116 | * @retval NRF_ERROR_NO_MEM Operation failure. No packet available to extract. |
jksoft | 0:8c643bfe55b7 | 117 | * @retval NRF_ERROR_NULL Operation failure. NULL pointer supplied. |
jksoft | 0:8c643bfe55b7 | 118 | */ |
jksoft | 0:8c643bfe55b7 | 119 | uint32_t hci_mem_pool_rx_extract(uint8_t ** pp_buffer, uint32_t * p_length); |
jksoft | 0:8c643bfe55b7 | 120 | |
jksoft | 0:8c643bfe55b7 | 121 | /**@brief Function for freeing previously extracted packet, which has been filled with read data. |
jksoft | 0:8c643bfe55b7 | 122 | * |
jksoft | 0:8c643bfe55b7 | 123 | * @param[in] p_buffer Pointer to consumed buffer. |
jksoft | 0:8c643bfe55b7 | 124 | * |
jksoft | 0:8c643bfe55b7 | 125 | * @retval NRF_SUCCESS Operation success. |
jksoft | 0:8c643bfe55b7 | 126 | * @retval NRF_ERROR_NO_MEM Operation failure. No packet available to free. |
jksoft | 0:8c643bfe55b7 | 127 | * @retval NRF_ERROR_INVALID_ADDR Operation failure. Not a valid pointer. |
jksoft | 0:8c643bfe55b7 | 128 | */ |
jksoft | 0:8c643bfe55b7 | 129 | uint32_t hci_mem_pool_rx_consume(uint8_t * p_buffer); |
jksoft | 0:8c643bfe55b7 | 130 | |
jksoft | 0:8c643bfe55b7 | 131 | #endif // HCI_MEM_POOL_H__ |
jksoft | 0:8c643bfe55b7 | 132 | |
jksoft | 0:8c643bfe55b7 | 133 | /** @} */ |