Transistor Gijutsu, October 2014, Special Features Chapter 9, Software of the Function Generator トランジスタ技術2014年10月号 特集第9章のソフトウェア わがまま波形発生器のソフトウェア

Dependencies:   USBDevice mbed

Information

tg_201410s8_AD7714 トランジスタ技術 2014年 10月号 第9章のソフトウェア

Program for Section 9 in October. 2014 issue of the Transistor Gijutsu
(Japanese electronics magazine)

概要

このプログラムは、ソフトウエアDDSにより、任意の波形を出力(2ch)します。 特徴は次のとおりです。

  • PWM出力をDAコンバータとして利用します。
  • 周波数や波形、バースト条件などを個別に設定できる独立した出力を2チャネル持っています。
  • 周波数分解能0.023mHz
  • 周波数範囲0.023mHz~10kHz
  • 各チャネルにそれぞれ、波形の先頭で出力されるトリガ出力があります。
  • 出力波形を関数で定義できます。
  • 休止波数、出力波数、を設定することでバースト波形が出力できます。

ファイル

このソフトウエアは、次のファイルから構成されています。

  • DDS.cpp - DDSによる波形発生
  • main.cpp - main()関数

詳細については、10月号の記事および上記ファイル中のコメントを参照してください。

Committer:
Dance
Date:
Fri Aug 29 08:33:17 2014 +0000
Revision:
0:f1ecca559ec3
Transistor Gijutsu, October 2014, Special Features Chapter 9; ????????2014?10??????9????????

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Dance 0:f1ecca559ec3 1 /* Copyright (c) 2010-2011 mbed.org, MIT License
Dance 0:f1ecca559ec3 2 *
Dance 0:f1ecca559ec3 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
Dance 0:f1ecca559ec3 4 * and associated documentation files (the "Software"), to deal in the Software without
Dance 0:f1ecca559ec3 5 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
Dance 0:f1ecca559ec3 6 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
Dance 0:f1ecca559ec3 7 * Software is furnished to do so, subject to the following conditions:
Dance 0:f1ecca559ec3 8 *
Dance 0:f1ecca559ec3 9 * The above copyright notice and this permission notice shall be included in all copies or
Dance 0:f1ecca559ec3 10 * substantial portions of the Software.
Dance 0:f1ecca559ec3 11 *
Dance 0:f1ecca559ec3 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
Dance 0:f1ecca559ec3 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
Dance 0:f1ecca559ec3 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
Dance 0:f1ecca559ec3 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
Dance 0:f1ecca559ec3 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Dance 0:f1ecca559ec3 17 */
Dance 0:f1ecca559ec3 18
Dance 0:f1ecca559ec3 19 #ifndef USBBUSINTERFACE_H
Dance 0:f1ecca559ec3 20 #define USBBUSINTERFACE_H
Dance 0:f1ecca559ec3 21
Dance 0:f1ecca559ec3 22 #include "mbed.h"
Dance 0:f1ecca559ec3 23 #include "USBEndpoints.h"
Dance 0:f1ecca559ec3 24 #include "toolchain.h"
Dance 0:f1ecca559ec3 25
Dance 0:f1ecca559ec3 26 //#ifdef __GNUC__
Dance 0:f1ecca559ec3 27 //#define __packed __attribute__ ((__packed__))
Dance 0:f1ecca559ec3 28 //#endif
Dance 0:f1ecca559ec3 29
Dance 0:f1ecca559ec3 30 class USBHAL {
Dance 0:f1ecca559ec3 31 public:
Dance 0:f1ecca559ec3 32 /* Configuration */
Dance 0:f1ecca559ec3 33 USBHAL();
Dance 0:f1ecca559ec3 34 ~USBHAL();
Dance 0:f1ecca559ec3 35 void connect(void);
Dance 0:f1ecca559ec3 36 void disconnect(void);
Dance 0:f1ecca559ec3 37 void configureDevice(void);
Dance 0:f1ecca559ec3 38 void unconfigureDevice(void);
Dance 0:f1ecca559ec3 39 void setAddress(uint8_t address);
Dance 0:f1ecca559ec3 40 void remoteWakeup(void);
Dance 0:f1ecca559ec3 41
Dance 0:f1ecca559ec3 42 /* Endpoint 0 */
Dance 0:f1ecca559ec3 43 void EP0setup(uint8_t *buffer);
Dance 0:f1ecca559ec3 44 void EP0read(void);
Dance 0:f1ecca559ec3 45 void EP0readStage(void);
Dance 0:f1ecca559ec3 46 uint32_t EP0getReadResult(uint8_t *buffer);
Dance 0:f1ecca559ec3 47 void EP0write(uint8_t *buffer, uint32_t size);
Dance 0:f1ecca559ec3 48 void EP0getWriteResult(void);
Dance 0:f1ecca559ec3 49 void EP0stall(void);
Dance 0:f1ecca559ec3 50
Dance 0:f1ecca559ec3 51 /* Other endpoints */
Dance 0:f1ecca559ec3 52 EP_STATUS endpointRead(uint8_t endpoint, uint32_t maximumSize);
Dance 0:f1ecca559ec3 53 EP_STATUS endpointReadResult(uint8_t endpoint, uint8_t *data, uint32_t *bytesRead);
Dance 0:f1ecca559ec3 54 EP_STATUS endpointWrite(uint8_t endpoint, uint8_t *data, uint32_t size);
Dance 0:f1ecca559ec3 55 EP_STATUS endpointWriteResult(uint8_t endpoint);
Dance 0:f1ecca559ec3 56 void stallEndpoint(uint8_t endpoint);
Dance 0:f1ecca559ec3 57 void unstallEndpoint(uint8_t endpoint);
Dance 0:f1ecca559ec3 58 bool realiseEndpoint(uint8_t endpoint, uint32_t maxPacket, uint32_t options);
Dance 0:f1ecca559ec3 59 bool getEndpointStallState(unsigned char endpoint);
Dance 0:f1ecca559ec3 60 uint32_t endpointReadcore(uint8_t endpoint, uint8_t *buffer);
Dance 0:f1ecca559ec3 61
Dance 0:f1ecca559ec3 62 protected:
Dance 0:f1ecca559ec3 63 virtual void busReset(void){};
Dance 0:f1ecca559ec3 64 virtual void EP0setupCallback(void){};
Dance 0:f1ecca559ec3 65 virtual void EP0out(void){};
Dance 0:f1ecca559ec3 66 virtual void EP0in(void){};
Dance 0:f1ecca559ec3 67 virtual void connectStateChanged(unsigned int connected){};
Dance 0:f1ecca559ec3 68 virtual void suspendStateChanged(unsigned int suspended){};
Dance 0:f1ecca559ec3 69 virtual void SOF(int frameNumber){};
Dance 0:f1ecca559ec3 70
Dance 0:f1ecca559ec3 71 virtual bool EP1_OUT_callback(){return false;};
Dance 0:f1ecca559ec3 72 virtual bool EP1_IN_callback(){return false;};
Dance 0:f1ecca559ec3 73 virtual bool EP2_OUT_callback(){return false;};
Dance 0:f1ecca559ec3 74 virtual bool EP2_IN_callback(){return false;};
Dance 0:f1ecca559ec3 75 virtual bool EP3_OUT_callback(){return false;};
Dance 0:f1ecca559ec3 76 virtual bool EP3_IN_callback(){return false;};
Dance 0:f1ecca559ec3 77 #if !defined(TARGET_STM32F4)
Dance 0:f1ecca559ec3 78 virtual bool EP4_OUT_callback(){return false;};
Dance 0:f1ecca559ec3 79 virtual bool EP4_IN_callback(){return false;};
Dance 0:f1ecca559ec3 80 #if !defined(TARGET_LPC11U24)
Dance 0:f1ecca559ec3 81 virtual bool EP5_OUT_callback(){return false;};
Dance 0:f1ecca559ec3 82 virtual bool EP5_IN_callback(){return false;};
Dance 0:f1ecca559ec3 83 virtual bool EP6_OUT_callback(){return false;};
Dance 0:f1ecca559ec3 84 virtual bool EP6_IN_callback(){return false;};
Dance 0:f1ecca559ec3 85 virtual bool EP7_OUT_callback(){return false;};
Dance 0:f1ecca559ec3 86 virtual bool EP7_IN_callback(){return false;};
Dance 0:f1ecca559ec3 87 virtual bool EP8_OUT_callback(){return false;};
Dance 0:f1ecca559ec3 88 virtual bool EP8_IN_callback(){return false;};
Dance 0:f1ecca559ec3 89 virtual bool EP9_OUT_callback(){return false;};
Dance 0:f1ecca559ec3 90 virtual bool EP9_IN_callback(){return false;};
Dance 0:f1ecca559ec3 91 virtual bool EP10_OUT_callback(){return false;};
Dance 0:f1ecca559ec3 92 virtual bool EP10_IN_callback(){return false;};
Dance 0:f1ecca559ec3 93 virtual bool EP11_OUT_callback(){return false;};
Dance 0:f1ecca559ec3 94 virtual bool EP11_IN_callback(){return false;};
Dance 0:f1ecca559ec3 95 virtual bool EP12_OUT_callback(){return false;};
Dance 0:f1ecca559ec3 96 virtual bool EP12_IN_callback(){return false;};
Dance 0:f1ecca559ec3 97 virtual bool EP13_OUT_callback(){return false;};
Dance 0:f1ecca559ec3 98 virtual bool EP13_IN_callback(){return false;};
Dance 0:f1ecca559ec3 99 virtual bool EP14_OUT_callback(){return false;};
Dance 0:f1ecca559ec3 100 virtual bool EP14_IN_callback(){return false;};
Dance 0:f1ecca559ec3 101 virtual bool EP15_OUT_callback(){return false;};
Dance 0:f1ecca559ec3 102 virtual bool EP15_IN_callback(){return false;};
Dance 0:f1ecca559ec3 103 #endif
Dance 0:f1ecca559ec3 104 #endif
Dance 0:f1ecca559ec3 105
Dance 0:f1ecca559ec3 106 private:
Dance 0:f1ecca559ec3 107 void usbisr(void);
Dance 0:f1ecca559ec3 108 static void _usbisr(void);
Dance 0:f1ecca559ec3 109 static USBHAL * instance;
Dance 0:f1ecca559ec3 110
Dance 0:f1ecca559ec3 111 #if defined(TARGET_LPC11U24)
Dance 0:f1ecca559ec3 112 bool (USBHAL::*epCallback[10 - 2])(void);
Dance 0:f1ecca559ec3 113 #elif defined(TARGET_STM32F4XX)
Dance 0:f1ecca559ec3 114 bool (USBHAL::*epCallback[8 - 2])(void);
Dance 0:f1ecca559ec3 115 #else
Dance 0:f1ecca559ec3 116 bool (USBHAL::*epCallback[32 - 2])(void);
Dance 0:f1ecca559ec3 117 #endif
Dance 0:f1ecca559ec3 118
Dance 0:f1ecca559ec3 119
Dance 0:f1ecca559ec3 120 };
Dance 0:f1ecca559ec3 121 #endif