⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 global.h

📁 AVR source code for performing speech, the speech voice will be like a robot voice. sources are in c
💻 H
字号:
#ifndef _GLOBAL_H_
#define _GLOBAL_H_

// For windows then must always use logging
#ifndef _AVR_
	#define _LOG_
	#define F_CPU 8000000
#endif


// Overall timing delay factor
#ifndef F_CPU
	#error "F_CPU not specified. Defaulting to 8MHz"
	#define F_CPU 8000000
#endif
#define TIME_FACTOR ((F_CPU+250000)/500000)





#ifdef _AVR_

	// Uncomment the following line to LOG output
	//#define _LOG_

	// PWM on Port B2 - comment out this line to stop it
	#define _AVR_PWM_

	// Binary output on SOUND_PORT, SOUND_BIT - comment out this line to stop it
	#define _AVR_BINARY_

	// 4 port output on QUAD_PORT using pins QUAD_PIN, QUAD_PIN + 1, QUAD_PIN + 2 and QUAD_PIN + 3
	#define _AVR_QUAD_

	#include <avr/io.h>
	#include <avr/pgmspace.h>
	#include "avrlibdefs.h"
	#include "avrlibtypes.h"
	#include "uart.h"
	#include "rprintf.h"
	#include <avr/sleep.h>

	// Specify the output port pin to use for binary sound control
	#ifdef _AVR_BINARY_
		#define SOUND_PORT PORTB
		#define SOUND_DDR DDRB
		#define SOUND_BIT BV(PB4)
	#endif

	// Specify the output port pin to use for quad sound control
	#ifdef _AVR_QUAD_
		#define QUAD_PORT PORTC
		#define QUAD_DDR  DDRC
		#define QUAD_BIT  PC0
		#define QUAD_MASK (BV(QUAD_BIT) | BV(QUAD_BIT+1) | BV(QUAD_BIT+2) | BV(QUAD_BIT+3)) 
	#endif


#else
	// Compiling for windows
	#ifdef _LOG_
		#include <stdio.h>
		#define loggerP(s) logger(s)
	#endif
	#define PROGMEM
	#include <memory.h>
	#define pgm_read_byte(addr) *addr
	#define pgm_read_word(addr) *addr
	#define memcpy_P(a,b,c) memcpy(a,b,c);
	typedef unsigned char uint8_t;
	typedef signed char int8_t;
	typedef int int16_t;
	#define PSTR(s) s
	void setLogFile(FILE * file);
#endif


#ifndef TRUE
#define FALSE 0
#define TRUE -1
#endif 
typedef int8_t boolean;



typedef struct Vocab {
	const char* txt;
	const char* phoneme;
} VOCAB;

typedef struct Phoneme {
	const char* txt;
	const char* phoneme;
	uint8_t attenuate;
} PHONEME;

typedef struct strSoundIndex{
	uint8_t SoundNumber;
	int8_t byte1;
	uint8_t byte2;
} SOUND_INDEX;

#include "core.h"
#include "speech.h"

#ifdef _AVR_
	// Phase and frequency correct - no prescale
	#define PWM_FLAGS ((1 << WGM13) | (1 << CS10))

	// 20kHz PWM
	#if F_CPU == 8000000
	#define PWM_TOP (600/2)

	#elif F_CPU== 16000000
	#define PWM_TOP (1200/2)

	#elif F_CPU== 20000000
	#define PWM_TOP (1500/2)

	#elif F_CPU== 1000000
	#define PWM_TOP (600/(2*8))
	#endif

#endif

void init(void);

#define min(a,b) (a < b) ? a : b
#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -