Output the audio signal with filtering by graphic equalizer in the *.wav file on the SD card using onboard CODEC. SD カードの *.wav ファイルのオーディオ信号をグラフィック・イコライザを通して,ボードに搭載されているCODEC で出力する.

Dependencies:   F746_GUI F746_SAI_IO SD_PlayerSkeleton FrequencyResponseDrawer

Committer:
MikamiUitOpen
Date:
Mon Apr 10 04:07:35 2017 +0000
Revision:
24:f78f9d0ac262
Parent:
16:cbb726ac20d8
25

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MikamiUitOpen 16:cbb726ac20d8 1 /* mbed Microcontroller Library
MikamiUitOpen 16:cbb726ac20d8 2 * Copyright (c) 2006-2013 ARM Limited
MikamiUitOpen 16:cbb726ac20d8 3 *
MikamiUitOpen 16:cbb726ac20d8 4 * Licensed under the Apache License, Version 2.0 (the "License");
MikamiUitOpen 16:cbb726ac20d8 5 * you may not use this file except in compliance with the License.
MikamiUitOpen 16:cbb726ac20d8 6 * You may obtain a copy of the License at
MikamiUitOpen 16:cbb726ac20d8 7 *
MikamiUitOpen 16:cbb726ac20d8 8 * http://www.apache.org/licenses/LICENSE-2.0
MikamiUitOpen 16:cbb726ac20d8 9 *
MikamiUitOpen 16:cbb726ac20d8 10 * Unless required by applicable law or agreed to in writing, software
MikamiUitOpen 16:cbb726ac20d8 11 * distributed under the License is distributed on an "AS IS" BASIS,
MikamiUitOpen 16:cbb726ac20d8 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
MikamiUitOpen 16:cbb726ac20d8 13 * See the License for the specific language governing permissions and
MikamiUitOpen 16:cbb726ac20d8 14 * limitations under the License.
MikamiUitOpen 16:cbb726ac20d8 15 */
MikamiUitOpen 16:cbb726ac20d8 16 #ifndef MBED_CAN_H
MikamiUitOpen 16:cbb726ac20d8 17 #define MBED_CAN_H
MikamiUitOpen 16:cbb726ac20d8 18
MikamiUitOpen 16:cbb726ac20d8 19 #include "platform.h"
MikamiUitOpen 16:cbb726ac20d8 20
MikamiUitOpen 16:cbb726ac20d8 21 #if DEVICE_CAN
MikamiUitOpen 16:cbb726ac20d8 22
MikamiUitOpen 16:cbb726ac20d8 23 #include "can_api.h"
MikamiUitOpen 16:cbb726ac20d8 24 #include "can_helper.h"
MikamiUitOpen 16:cbb726ac20d8 25 #include "FunctionPointer.h"
MikamiUitOpen 16:cbb726ac20d8 26
MikamiUitOpen 16:cbb726ac20d8 27 namespace mbed {
MikamiUitOpen 16:cbb726ac20d8 28
MikamiUitOpen 16:cbb726ac20d8 29 /** CANMessage class
MikamiUitOpen 16:cbb726ac20d8 30 */
MikamiUitOpen 16:cbb726ac20d8 31 class CANMessage : public CAN_Message {
MikamiUitOpen 16:cbb726ac20d8 32
MikamiUitOpen 16:cbb726ac20d8 33 public:
MikamiUitOpen 16:cbb726ac20d8 34 /** Creates empty CAN message.
MikamiUitOpen 16:cbb726ac20d8 35 */
MikamiUitOpen 16:cbb726ac20d8 36 CANMessage() : CAN_Message() {
MikamiUitOpen 16:cbb726ac20d8 37 len = 8;
MikamiUitOpen 16:cbb726ac20d8 38 type = CANData;
MikamiUitOpen 16:cbb726ac20d8 39 format = CANStandard;
MikamiUitOpen 16:cbb726ac20d8 40 id = 0;
MikamiUitOpen 16:cbb726ac20d8 41 memset(data, 0, 8);
MikamiUitOpen 16:cbb726ac20d8 42 }
MikamiUitOpen 16:cbb726ac20d8 43
MikamiUitOpen 16:cbb726ac20d8 44 /** Creates CAN message with specific content.
MikamiUitOpen 16:cbb726ac20d8 45 */
MikamiUitOpen 16:cbb726ac20d8 46 CANMessage(int _id, const char *_data, char _len = 8, CANType _type = CANData, CANFormat _format = CANStandard) {
MikamiUitOpen 16:cbb726ac20d8 47 len = _len & 0xF;
MikamiUitOpen 16:cbb726ac20d8 48 type = _type;
MikamiUitOpen 16:cbb726ac20d8 49 format = _format;
MikamiUitOpen 16:cbb726ac20d8 50 id = _id;
MikamiUitOpen 16:cbb726ac20d8 51 memcpy(data, _data, _len);
MikamiUitOpen 16:cbb726ac20d8 52 }
MikamiUitOpen 16:cbb726ac20d8 53
MikamiUitOpen 16:cbb726ac20d8 54 /** Creates CAN remote message.
MikamiUitOpen 16:cbb726ac20d8 55 */
MikamiUitOpen 16:cbb726ac20d8 56 CANMessage(int _id, CANFormat _format = CANStandard) {
MikamiUitOpen 16:cbb726ac20d8 57 len = 0;
MikamiUitOpen 16:cbb726ac20d8 58 type = CANRemote;
MikamiUitOpen 16:cbb726ac20d8 59 format = _format;
MikamiUitOpen 16:cbb726ac20d8 60 id = _id;
MikamiUitOpen 16:cbb726ac20d8 61 memset(data, 0, 8);
MikamiUitOpen 16:cbb726ac20d8 62 }
MikamiUitOpen 16:cbb726ac20d8 63 };
MikamiUitOpen 16:cbb726ac20d8 64
MikamiUitOpen 16:cbb726ac20d8 65 /** A can bus client, used for communicating with can devices
MikamiUitOpen 16:cbb726ac20d8 66 */
MikamiUitOpen 16:cbb726ac20d8 67 class CAN {
MikamiUitOpen 16:cbb726ac20d8 68
MikamiUitOpen 16:cbb726ac20d8 69 public:
MikamiUitOpen 16:cbb726ac20d8 70 /** Creates an CAN interface connected to specific pins.
MikamiUitOpen 16:cbb726ac20d8 71 *
MikamiUitOpen 16:cbb726ac20d8 72 * @param rd read from transmitter
MikamiUitOpen 16:cbb726ac20d8 73 * @param td transmit to transmitter
MikamiUitOpen 16:cbb726ac20d8 74 *
MikamiUitOpen 16:cbb726ac20d8 75 * Example:
MikamiUitOpen 16:cbb726ac20d8 76 * @code
MikamiUitOpen 16:cbb726ac20d8 77 * #include "mbed.h"
MikamiUitOpen 16:cbb726ac20d8 78 *
MikamiUitOpen 16:cbb726ac20d8 79 * Ticker ticker;
MikamiUitOpen 16:cbb726ac20d8 80 * DigitalOut led1(LED1);
MikamiUitOpen 16:cbb726ac20d8 81 * DigitalOut led2(LED2);
MikamiUitOpen 16:cbb726ac20d8 82 * CAN can1(p9, p10);
MikamiUitOpen 16:cbb726ac20d8 83 * CAN can2(p30, p29);
MikamiUitOpen 16:cbb726ac20d8 84 *
MikamiUitOpen 16:cbb726ac20d8 85 * char counter = 0;
MikamiUitOpen 16:cbb726ac20d8 86 *
MikamiUitOpen 16:cbb726ac20d8 87 * void send() {
MikamiUitOpen 16:cbb726ac20d8 88 * if(can1.write(CANMessage(1337, &counter, 1))) {
MikamiUitOpen 16:cbb726ac20d8 89 * printf("Message sent: %d\n", counter);
MikamiUitOpen 16:cbb726ac20d8 90 * counter++;
MikamiUitOpen 16:cbb726ac20d8 91 * }
MikamiUitOpen 16:cbb726ac20d8 92 * led1 = !led1;
MikamiUitOpen 16:cbb726ac20d8 93 * }
MikamiUitOpen 16:cbb726ac20d8 94 *
MikamiUitOpen 16:cbb726ac20d8 95 * int main() {
MikamiUitOpen 16:cbb726ac20d8 96 * ticker.attach(&send, 1);
MikamiUitOpen 16:cbb726ac20d8 97 * CANMessage msg;
MikamiUitOpen 16:cbb726ac20d8 98 * while(1) {
MikamiUitOpen 16:cbb726ac20d8 99 * if(can2.read(msg)) {
MikamiUitOpen 16:cbb726ac20d8 100 * printf("Message received: %d\n\n", msg.data[0]);
MikamiUitOpen 16:cbb726ac20d8 101 * led2 = !led2;
MikamiUitOpen 16:cbb726ac20d8 102 * }
MikamiUitOpen 16:cbb726ac20d8 103 * wait(0.2);
MikamiUitOpen 16:cbb726ac20d8 104 * }
MikamiUitOpen 16:cbb726ac20d8 105 * }
MikamiUitOpen 16:cbb726ac20d8 106 * @endcode
MikamiUitOpen 16:cbb726ac20d8 107 */
MikamiUitOpen 16:cbb726ac20d8 108 CAN(PinName rd, PinName td);
MikamiUitOpen 16:cbb726ac20d8 109 virtual ~CAN();
MikamiUitOpen 16:cbb726ac20d8 110
MikamiUitOpen 16:cbb726ac20d8 111 /** Set the frequency of the CAN interface
MikamiUitOpen 16:cbb726ac20d8 112 *
MikamiUitOpen 16:cbb726ac20d8 113 * @param hz The bus frequency in hertz
MikamiUitOpen 16:cbb726ac20d8 114 *
MikamiUitOpen 16:cbb726ac20d8 115 * @returns
MikamiUitOpen 16:cbb726ac20d8 116 * 1 if successful,
MikamiUitOpen 16:cbb726ac20d8 117 * 0 otherwise
MikamiUitOpen 16:cbb726ac20d8 118 */
MikamiUitOpen 16:cbb726ac20d8 119 int frequency(int hz);
MikamiUitOpen 16:cbb726ac20d8 120
MikamiUitOpen 16:cbb726ac20d8 121 /** Write a CANMessage to the bus.
MikamiUitOpen 16:cbb726ac20d8 122 *
MikamiUitOpen 16:cbb726ac20d8 123 * @param msg The CANMessage to write.
MikamiUitOpen 16:cbb726ac20d8 124 *
MikamiUitOpen 16:cbb726ac20d8 125 * @returns
MikamiUitOpen 16:cbb726ac20d8 126 * 0 if write failed,
MikamiUitOpen 16:cbb726ac20d8 127 * 1 if write was successful
MikamiUitOpen 16:cbb726ac20d8 128 */
MikamiUitOpen 16:cbb726ac20d8 129 int write(CANMessage msg);
MikamiUitOpen 16:cbb726ac20d8 130
MikamiUitOpen 16:cbb726ac20d8 131 /** Read a CANMessage from the bus.
MikamiUitOpen 16:cbb726ac20d8 132 *
MikamiUitOpen 16:cbb726ac20d8 133 * @param msg A CANMessage to read to.
MikamiUitOpen 16:cbb726ac20d8 134 * @param handle message filter handle (0 for any message)
MikamiUitOpen 16:cbb726ac20d8 135 *
MikamiUitOpen 16:cbb726ac20d8 136 * @returns
MikamiUitOpen 16:cbb726ac20d8 137 * 0 if no message arrived,
MikamiUitOpen 16:cbb726ac20d8 138 * 1 if message arrived
MikamiUitOpen 16:cbb726ac20d8 139 */
MikamiUitOpen 16:cbb726ac20d8 140 int read(CANMessage &msg, int handle = 0);
MikamiUitOpen 16:cbb726ac20d8 141
MikamiUitOpen 16:cbb726ac20d8 142 /** Reset CAN interface.
MikamiUitOpen 16:cbb726ac20d8 143 *
MikamiUitOpen 16:cbb726ac20d8 144 * To use after error overflow.
MikamiUitOpen 16:cbb726ac20d8 145 */
MikamiUitOpen 16:cbb726ac20d8 146 void reset();
MikamiUitOpen 16:cbb726ac20d8 147
MikamiUitOpen 16:cbb726ac20d8 148 /** Puts or removes the CAN interface into silent monitoring mode
MikamiUitOpen 16:cbb726ac20d8 149 *
MikamiUitOpen 16:cbb726ac20d8 150 * @param silent boolean indicating whether to go into silent mode or not
MikamiUitOpen 16:cbb726ac20d8 151 */
MikamiUitOpen 16:cbb726ac20d8 152 void monitor(bool silent);
MikamiUitOpen 16:cbb726ac20d8 153
MikamiUitOpen 16:cbb726ac20d8 154 enum Mode {
MikamiUitOpen 16:cbb726ac20d8 155 Reset = 0,
MikamiUitOpen 16:cbb726ac20d8 156 Normal,
MikamiUitOpen 16:cbb726ac20d8 157 Silent,
MikamiUitOpen 16:cbb726ac20d8 158 LocalTest,
MikamiUitOpen 16:cbb726ac20d8 159 GlobalTest,
MikamiUitOpen 16:cbb726ac20d8 160 SilentTest
MikamiUitOpen 16:cbb726ac20d8 161 };
MikamiUitOpen 16:cbb726ac20d8 162
MikamiUitOpen 16:cbb726ac20d8 163 /** Change CAN operation to the specified mode
MikamiUitOpen 16:cbb726ac20d8 164 *
MikamiUitOpen 16:cbb726ac20d8 165 * @param mode The new operation mode (CAN::Normal, CAN::Silent, CAN::LocalTest, CAN::GlobalTest, CAN::SilentTest)
MikamiUitOpen 16:cbb726ac20d8 166 *
MikamiUitOpen 16:cbb726ac20d8 167 * @returns
MikamiUitOpen 16:cbb726ac20d8 168 * 0 if mode change failed or unsupported,
MikamiUitOpen 16:cbb726ac20d8 169 * 1 if mode change was successful
MikamiUitOpen 16:cbb726ac20d8 170 */
MikamiUitOpen 16:cbb726ac20d8 171 int mode(Mode mode);
MikamiUitOpen 16:cbb726ac20d8 172
MikamiUitOpen 16:cbb726ac20d8 173 /** Filter out incomming messages
MikamiUitOpen 16:cbb726ac20d8 174 *
MikamiUitOpen 16:cbb726ac20d8 175 * @param id the id to filter on
MikamiUitOpen 16:cbb726ac20d8 176 * @param mask the mask applied to the id
MikamiUitOpen 16:cbb726ac20d8 177 * @param format format to filter on (Default CANAny)
MikamiUitOpen 16:cbb726ac20d8 178 * @param handle message filter handle (Optional)
MikamiUitOpen 16:cbb726ac20d8 179 *
MikamiUitOpen 16:cbb726ac20d8 180 * @returns
MikamiUitOpen 16:cbb726ac20d8 181 * 0 if filter change failed or unsupported,
MikamiUitOpen 16:cbb726ac20d8 182 * new filter handle if successful
MikamiUitOpen 16:cbb726ac20d8 183 */
MikamiUitOpen 16:cbb726ac20d8 184 int filter(unsigned int id, unsigned int mask, CANFormat format = CANAny, int handle = 0);
MikamiUitOpen 16:cbb726ac20d8 185
MikamiUitOpen 16:cbb726ac20d8 186 /** Returns number of read errors to detect read overflow errors.
MikamiUitOpen 16:cbb726ac20d8 187 */
MikamiUitOpen 16:cbb726ac20d8 188 unsigned char rderror();
MikamiUitOpen 16:cbb726ac20d8 189
MikamiUitOpen 16:cbb726ac20d8 190 /** Returns number of write errors to detect write overflow errors.
MikamiUitOpen 16:cbb726ac20d8 191 */
MikamiUitOpen 16:cbb726ac20d8 192 unsigned char tderror();
MikamiUitOpen 16:cbb726ac20d8 193
MikamiUitOpen 16:cbb726ac20d8 194 enum IrqType {
MikamiUitOpen 16:cbb726ac20d8 195 RxIrq = 0,
MikamiUitOpen 16:cbb726ac20d8 196 TxIrq,
MikamiUitOpen 16:cbb726ac20d8 197 EwIrq,
MikamiUitOpen 16:cbb726ac20d8 198 DoIrq,
MikamiUitOpen 16:cbb726ac20d8 199 WuIrq,
MikamiUitOpen 16:cbb726ac20d8 200 EpIrq,
MikamiUitOpen 16:cbb726ac20d8 201 AlIrq,
MikamiUitOpen 16:cbb726ac20d8 202 BeIrq,
MikamiUitOpen 16:cbb726ac20d8 203 IdIrq
MikamiUitOpen 16:cbb726ac20d8 204 };
MikamiUitOpen 16:cbb726ac20d8 205
MikamiUitOpen 16:cbb726ac20d8 206 /** Attach a function to call whenever a CAN frame received interrupt is
MikamiUitOpen 16:cbb726ac20d8 207 * generated.
MikamiUitOpen 16:cbb726ac20d8 208 *
MikamiUitOpen 16:cbb726ac20d8 209 * @param fptr A pointer to a void function, or 0 to set as none
MikamiUitOpen 16:cbb726ac20d8 210 * @param event Which CAN interrupt to attach the member function to (CAN::RxIrq for message received, CAN::TxIrq for transmitted or aborted, CAN::EwIrq for error warning, CAN::DoIrq for data overrun, CAN::WuIrq for wake-up, CAN::EpIrq for error passive, CAN::AlIrq for arbitration lost, CAN::BeIrq for bus error)
MikamiUitOpen 16:cbb726ac20d8 211 */
MikamiUitOpen 16:cbb726ac20d8 212 void attach(void (*fptr)(void), IrqType type=RxIrq);
MikamiUitOpen 16:cbb726ac20d8 213
MikamiUitOpen 16:cbb726ac20d8 214 /** Attach a member function to call whenever a CAN frame received interrupt
MikamiUitOpen 16:cbb726ac20d8 215 * is generated.
MikamiUitOpen 16:cbb726ac20d8 216 *
MikamiUitOpen 16:cbb726ac20d8 217 * @param tptr pointer to the object to call the member function on
MikamiUitOpen 16:cbb726ac20d8 218 * @param mptr pointer to the member function to be called
MikamiUitOpen 16:cbb726ac20d8 219 * @param event Which CAN interrupt to attach the member function to (CAN::RxIrq for message received, TxIrq for transmitted or aborted, EwIrq for error warning, DoIrq for data overrun, WuIrq for wake-up, EpIrq for error passive, AlIrq for arbitration lost, BeIrq for bus error)
MikamiUitOpen 16:cbb726ac20d8 220 */
MikamiUitOpen 16:cbb726ac20d8 221 template<typename T>
MikamiUitOpen 16:cbb726ac20d8 222 void attach(T* tptr, void (T::*mptr)(void), IrqType type=RxIrq) {
MikamiUitOpen 16:cbb726ac20d8 223 if((mptr != NULL) && (tptr != NULL)) {
MikamiUitOpen 16:cbb726ac20d8 224 _irq[type].attach(tptr, mptr);
MikamiUitOpen 16:cbb726ac20d8 225 can_irq_set(&_can, (CanIrqType)type, 1);
MikamiUitOpen 16:cbb726ac20d8 226 }
MikamiUitOpen 16:cbb726ac20d8 227 else {
MikamiUitOpen 16:cbb726ac20d8 228 can_irq_set(&_can, (CanIrqType)type, 0);
MikamiUitOpen 16:cbb726ac20d8 229 }
MikamiUitOpen 16:cbb726ac20d8 230 }
MikamiUitOpen 16:cbb726ac20d8 231
MikamiUitOpen 16:cbb726ac20d8 232 static void _irq_handler(uint32_t id, CanIrqType type);
MikamiUitOpen 16:cbb726ac20d8 233
MikamiUitOpen 16:cbb726ac20d8 234 protected:
MikamiUitOpen 16:cbb726ac20d8 235 can_t _can;
MikamiUitOpen 16:cbb726ac20d8 236 FunctionPointer _irq[9];
MikamiUitOpen 16:cbb726ac20d8 237 };
MikamiUitOpen 16:cbb726ac20d8 238
MikamiUitOpen 16:cbb726ac20d8 239 } // namespace mbed
MikamiUitOpen 16:cbb726ac20d8 240
MikamiUitOpen 16:cbb726ac20d8 241 #endif
MikamiUitOpen 16:cbb726ac20d8 242
MikamiUitOpen 16:cbb726ac20d8 243 #endif // MBED_CAN_H