同時公開のFunctionGenerator-BLEと同時利用によりファンクション・ジェネレータを実現する。
FunctionGenerator-BLE
/users/ohneta/code/FunctionGenerator-BLE
what's this ? / 概要
あとで、もっとちゃんと書く(とおもう)
同時公開のFunctionGenerator-BLEと同時利用によりmbed LPC1768を使って、ファンクション・ジェネレータを実現する。
detail / 詳細
あとで、もっとちゃんと書く(とおもう)
FunctionGenerator-BLEはI2Cで所定のフォーマットに従ったデータをDACから出力する。
DACは連続するデータを出力し、任意の波形を出力する。
BLE command format / BLEコマンドフォーマット
あとで、ちゃんと書く(とおもう)
BLE App for iPhone
iOS用アプリソースコード App source codes for iOS
https://github.com/ohneta/FuncGenBLE
pictures / とりあえず写真など
外観
アプリ画面
出力波形
more pictures...
- https://twitter.com/ohneta_j/status/610439975549558784
- https://twitter.com/ohneta_j/status/610480383788871680
- https://twitter.com/ohneta_j/status/610733060594647040
FunctionGenCommands.h@0:cbf811b45305, 2015-06-16 (annotated)
- Committer:
- ohneta
- Date:
- Tue Jun 16 07:19:51 2015 +0000
- Revision:
- 0:cbf811b45305
1st release commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ohneta | 0:cbf811b45305 | 1 | //--------------------------------------------------------- |
ohneta | 0:cbf811b45305 | 2 | /** |
ohneta | 0:cbf811b45305 | 3 | * FunctionGenCommands.h |
ohneta | 0:cbf811b45305 | 4 | */ |
ohneta | 0:cbf811b45305 | 5 | //--------------------------------------------------------- |
ohneta | 0:cbf811b45305 | 6 | |
ohneta | 0:cbf811b45305 | 7 | #define FGC_BUFFERTRANSFER_MAX 16 |
ohneta | 0:cbf811b45305 | 8 | |
ohneta | 0:cbf811b45305 | 9 | typedef enum { |
ohneta | 0:cbf811b45305 | 10 | // commands |
ohneta | 0:cbf811b45305 | 11 | FGCommand_Non = 0x00, |
ohneta | 0:cbf811b45305 | 12 | FGCommand_Device, |
ohneta | 0:cbf811b45305 | 13 | FGCommand_Output, |
ohneta | 0:cbf811b45305 | 14 | FGCommand_Frequency, |
ohneta | 0:cbf811b45305 | 15 | FGCommand_WaveformInfo, |
ohneta | 0:cbf811b45305 | 16 | FGCommand_WaveformBlock, |
ohneta | 0:cbf811b45305 | 17 | FGCommand_WaveformToBuffer, |
ohneta | 0:cbf811b45305 | 18 | |
ohneta | 0:cbf811b45305 | 19 | // status |
ohneta | 0:cbf811b45305 | 20 | FGStatus_Device = 0x80 | FGCommand_Device, |
ohneta | 0:cbf811b45305 | 21 | FGStatus_Output = 0x80 | FGCommand_Output, |
ohneta | 0:cbf811b45305 | 22 | FGStatus_Frequency = 0x80 | FGCommand_Frequency, |
ohneta | 0:cbf811b45305 | 23 | |
ohneta | 0:cbf811b45305 | 24 | // special |
ohneta | 0:cbf811b45305 | 25 | FGCommand_Reset = 0xff, |
ohneta | 0:cbf811b45305 | 26 | |
ohneta | 0:cbf811b45305 | 27 | } enumFGCommand; |
ohneta | 0:cbf811b45305 | 28 | |
ohneta | 0:cbf811b45305 | 29 | |
ohneta | 0:cbf811b45305 | 30 | // Characteristics |
ohneta | 0:cbf811b45305 | 31 | #define CHARACTERISTICS_UUID_RESET 0xA100 |
ohneta | 0:cbf811b45305 | 32 | #define CHARACTERISTICS_UUID_DEVICE 0xA101 |
ohneta | 0:cbf811b45305 | 33 | #define CHARACTERISTICS_UUID_OUTPUT 0xA102 |
ohneta | 0:cbf811b45305 | 34 | #define CHARACTERISTICS_UUID_FREQUENCY 0xA103 |
ohneta | 0:cbf811b45305 | 35 | #define CHARACTERISTICS_UUID_WAVEFORMINFO 0xA110 |
ohneta | 0:cbf811b45305 | 36 | #define CHARACTERISTICS_UUID_WAVEFORMBLOCK 0xA111 |
ohneta | 0:cbf811b45305 | 37 | #define CHARACTERISTICS_UUID_WAVEFORMTOBUFFER 0xA112 |
ohneta | 0:cbf811b45305 | 38 | |
ohneta | 0:cbf811b45305 | 39 | //--------------------------------------------------------- |
ohneta | 0:cbf811b45305 | 40 | #pragma pack(1) |
ohneta | 0:cbf811b45305 | 41 | // for BLE waveform transfer format |
ohneta | 0:cbf811b45305 | 42 | |
ohneta | 0:cbf811b45305 | 43 | typedef struct { |
ohneta | 0:cbf811b45305 | 44 | uint16_t waveSize; // Waveform全体のデータ長(byte) = blockSize * blockMaxNum |
ohneta | 0:cbf811b45305 | 45 | uint8_t bitPerData; // 1データあたりのbit数 (8, 10, 12 or 16bit) |
ohneta | 0:cbf811b45305 | 46 | |
ohneta | 0:cbf811b45305 | 47 | uint8_t blockSize; // 1ブロックあたりのデータ転送サイズ(byte) (通常16bytes) |
ohneta | 0:cbf811b45305 | 48 | uint8_t blockMaxNum; // ブロックの最大数 = (waveSize + 1) / blockSize |
ohneta | 0:cbf811b45305 | 49 | } WaveformInfo, FGCommandWaveformInfo; |
ohneta | 0:cbf811b45305 | 50 | |
ohneta | 0:cbf811b45305 | 51 | typedef struct { |
ohneta | 0:cbf811b45305 | 52 | uint16_t blockNo; // ブロックNo. 0 〜 (WaveformInfo.blockMaxNum - 1) |
ohneta | 0:cbf811b45305 | 53 | uint8_t length; // WaveformBlock.bufferの有効な長さ |
ohneta | 0:cbf811b45305 | 54 | uint8_t buffer[FGC_BUFFERTRANSFER_MAX]; // 実際のデータ |
ohneta | 0:cbf811b45305 | 55 | } WaveformBlock, FGCommandWaveformBlock; |
ohneta | 0:cbf811b45305 | 56 | |
ohneta | 0:cbf811b45305 | 57 | //--------------------------------------------------------- |
ohneta | 0:cbf811b45305 | 58 | // for I2C packet format |
ohneta | 0:cbf811b45305 | 59 | |
ohneta | 0:cbf811b45305 | 60 | // header |
ohneta | 0:cbf811b45305 | 61 | typedef struct { |
ohneta | 0:cbf811b45305 | 62 | uint8_t command; |
ohneta | 0:cbf811b45305 | 63 | uint8_t length; |
ohneta | 0:cbf811b45305 | 64 | } FGHeader; |
ohneta | 0:cbf811b45305 | 65 | |
ohneta | 0:cbf811b45305 | 66 | // command bodys |
ohneta | 0:cbf811b45305 | 67 | typedef struct { |
ohneta | 0:cbf811b45305 | 68 | uint8_t device; |
ohneta | 0:cbf811b45305 | 69 | } FGCommandDevice; |
ohneta | 0:cbf811b45305 | 70 | |
ohneta | 0:cbf811b45305 | 71 | typedef struct { |
ohneta | 0:cbf811b45305 | 72 | uint8_t on; |
ohneta | 0:cbf811b45305 | 73 | } FGCommandOutput; |
ohneta | 0:cbf811b45305 | 74 | |
ohneta | 0:cbf811b45305 | 75 | typedef struct { |
ohneta | 0:cbf811b45305 | 76 | uint32_t frequency; |
ohneta | 0:cbf811b45305 | 77 | } FGCommandFrequency; |
ohneta | 0:cbf811b45305 | 78 | |
ohneta | 0:cbf811b45305 | 79 | //#define FGCommandWaveformInfo WaveformInfo |
ohneta | 0:cbf811b45305 | 80 | //#define FGCommandWaveformBlock WaveformInfoBlock |
ohneta | 0:cbf811b45305 | 81 | |
ohneta | 0:cbf811b45305 | 82 | typedef struct { |
ohneta | 0:cbf811b45305 | 83 | } FGCommandWaveformToBuffer; |
ohneta | 0:cbf811b45305 | 84 | |
ohneta | 0:cbf811b45305 | 85 | typedef struct { |
ohneta | 0:cbf811b45305 | 86 | } FGCommandReset; |
ohneta | 0:cbf811b45305 | 87 | |
ohneta | 0:cbf811b45305 | 88 | // status bodys |
ohneta | 0:cbf811b45305 | 89 | typedef struct { |
ohneta | 0:cbf811b45305 | 90 | uint8_t device; |
ohneta | 0:cbf811b45305 | 91 | } FGStatusDevice; |
ohneta | 0:cbf811b45305 | 92 | |
ohneta | 0:cbf811b45305 | 93 | typedef struct { |
ohneta | 0:cbf811b45305 | 94 | uint8_t xxx; |
ohneta | 0:cbf811b45305 | 95 | } FGStatusOutput; |
ohneta | 0:cbf811b45305 | 96 | |
ohneta | 0:cbf811b45305 | 97 | typedef struct { |
ohneta | 0:cbf811b45305 | 98 | uint8_t xxx; |
ohneta | 0:cbf811b45305 | 99 | } FGStatusFrequency; |
ohneta | 0:cbf811b45305 | 100 | |
ohneta | 0:cbf811b45305 | 101 | |
ohneta | 0:cbf811b45305 | 102 | |
ohneta | 0:cbf811b45305 | 103 | // command Packet format |
ohneta | 0:cbf811b45305 | 104 | typedef struct { |
ohneta | 0:cbf811b45305 | 105 | FGHeader header; |
ohneta | 0:cbf811b45305 | 106 | union { |
ohneta | 0:cbf811b45305 | 107 | FGCommandDevice commandDevice; |
ohneta | 0:cbf811b45305 | 108 | FGCommandOutput commandOutput; |
ohneta | 0:cbf811b45305 | 109 | FGCommandFrequency commandFrequency; |
ohneta | 0:cbf811b45305 | 110 | FGCommandWaveformInfo commandWaveformInfo; |
ohneta | 0:cbf811b45305 | 111 | FGCommandWaveformBlock commandWaveformBlock; |
ohneta | 0:cbf811b45305 | 112 | FGCommandWaveformToBuffer commandWaveformToBuffer; |
ohneta | 0:cbf811b45305 | 113 | |
ohneta | 0:cbf811b45305 | 114 | FGCommandReset commandReset; |
ohneta | 0:cbf811b45305 | 115 | |
ohneta | 0:cbf811b45305 | 116 | FGStatusDevice statusDevice; |
ohneta | 0:cbf811b45305 | 117 | FGStatusOutput statusOutput; |
ohneta | 0:cbf811b45305 | 118 | FGStatusFrequency statusFrequency; |
ohneta | 0:cbf811b45305 | 119 | } body; |
ohneta | 0:cbf811b45305 | 120 | } FGPacket; |
ohneta | 0:cbf811b45305 | 121 | |
ohneta | 0:cbf811b45305 | 122 | #pragma pack() |