You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
	
	
		
			79 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			C
		
	
		
		
			
		
	
	
			79 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			C
		
	
| 
											7 months ago
										 | /*
 | ||
|  |  * SCIBase.h | ||
|  |  * | ||
|  |  *      Author: Aleksey Gerasimenko | ||
|  |  *      gerasimenko.aleksey.n@gmail.com | ||
|  |  */ | ||
|  | 
 | ||
|  | #include "F28335/DSP28x_Project.h"
 | ||
|  | 
 | ||
|  | #include "DSP28335/GPIO.h"
 | ||
|  | #include "RUDRIVEFRAMEWORK/DataType.h"
 | ||
|  | #include "RUDRIVEFRAMEWORK/SystemDefinitions.h"
 | ||
|  | 
 | ||
|  | 
 | ||
|  | #ifndef DSP28335_SCIBASE_H_
 | ||
|  | #define DSP28335_SCIBASE_H_
 | ||
|  | 
 | ||
|  | 
 | ||
|  | namespace DSP28335 | ||
|  | { | ||
|  | 
 | ||
|  | 
 | ||
|  | enum SCIBaudRate { BR2400, BR4800, BR9600, BR19200, BR38400}; | ||
|  | enum SCIParity {NO, ODD, EVEN}; | ||
|  | enum SCIStopBits {ONE, TWO}; | ||
|  | enum SCICharLenght { LEN1, LEN2, LEN3, LEN4, LEN5, LEN6, LEN7, LEN8}; | ||
|  | 
 | ||
|  | 
 | ||
|  | 
 | ||
|  | struct SCIConfiguration | ||
|  | { | ||
|  |     DSP28335::SCIBaudRate baudrate; | ||
|  |     DSP28335::SCIParity parity; | ||
|  |     DSP28335::SCIStopBits stopbits; | ||
|  |     DSP28335::SCICharLenght lenght; | ||
|  |     SCIConfiguration(): | ||
|  |         baudrate(DSP28335::BR9600), | ||
|  |         parity(DSP28335::ODD), | ||
|  |         stopbits(DSP28335::ONE), | ||
|  |         lenght(DSP28335::LEN8) | ||
|  |     {} | ||
|  | };//
 | ||
|  | 
 | ||
|  | 
 | ||
|  | struct SCISetup | ||
|  | { | ||
|  |     SCIConfiguration config; | ||
|  |     pGPIO_FUNCTION gpio_setup; | ||
|  |     SCISetup(): | ||
|  |         config(), | ||
|  |         gpio_setup(0) | ||
|  |     {} | ||
|  | };//
 | ||
|  | 
 | ||
|  | 
 | ||
|  | 
 | ||
|  | class SCIBase | ||
|  | { | ||
|  | public: | ||
|  |     volatile struct SCI_REGS& SciRegs; | ||
|  | protected: | ||
|  |     SCISetup    settings; | ||
|  | public: | ||
|  |     SCIBase(volatile struct SCI_REGS& SciRegs); | ||
|  |     virtual void setup() = 0; | ||
|  |     //virtual void setup(DSP28335::SCISetup& setup) = 0;
 | ||
|  |     virtual void get_default_configuration(DSP28335::SCIConfiguration& config) = 0; | ||
|  |     virtual void get_configuration(DSP28335::SCIConfiguration& config) = 0; | ||
|  |     virtual void set_configuration(DSP28335::SCIConfiguration& config) = 0; | ||
|  |     virtual bool compare_configuration(DSP28335::SCIConfiguration& config) = 0; | ||
|  | protected: | ||
|  |     virtual void _configure(DSP28335::SCIConfiguration& config) = 0; | ||
|  |     void (*_gpio_setup)(); | ||
|  | }; | ||
|  | 
 | ||
|  | } /* namespace DSP28335 */ | ||
|  | 
 | ||
|  | #endif /* DSP28335_SCIBASE_H_ */
 |