#include "net\ip.h"
//******************************************************* //----------------- Appcfg Configuration ----------------- //******************************************************** //Define if this application has an 8 bit ADC converter, 10 bit ADC converter or none at all. //#define APP_USE_ADC8 //#define APP_USE_ADC10 //Define buffer space that is reserved for ADC conversion values. For a 8 bit ADC converted, 1 byte //is reserved per channel. For an 10 bit ADC, 2 bytes are reserved per channel. //#define ADC_CHANNELS 12
#define APPCFG_CMDFLAGS_AUTH_UDP 0x02 |
#define APPCFG_CMDFLAGS_ENABLE 0x01 |
Mask for bits in APPCFG_CMD_FLAGS config byte.
#define APPCFG_NETFLAGS_DHCP 0x01 |
Mask for bits in APPCFG_NETFLAGS config byte.
#define APPCFG_SMALLER_256 |
Define this if APP_CONFIG is smaller then 256 bytes. When this is defined the code knows that it only need 1 byte to address all configuration bytes. This produces smaller and faster code.
#define APPCFG_USART_ENABLE 0x01 |
#define APPCFG_USERNAME_LEN 9 |
#define APPCFG_WEBFLAGS_AUTH_ALL 0x02 |
#define APPCFG_WEBFLAGS_AUTH_CGI 0x10 |
#define APPCFG_WEBFLAGS_AUTH_DYN 0x08 |
#define APPCFG_WEBFLAGS_AUTH_GET 0x04 |
#define APPCFG_WEBFLAGS_AUTH_SECTAG 0x20 |
#define APPCFG_WEBFLAGS_AUTH_X 0x01 |
Mask for bits in APPCFG_WEB_FLAGS config byte.
#define APPCFG_WEBFLAGS_PARSE_HTM 0x01 |
Mask for bits in APPCFG_WEB_FLAGS2 config byte.
#define APPCFG_WEBFLAGS_PARSE_JS 0x02 |
#define appcfgGetcAtField | ( | field | ) | appcfgGetc(offsetof(APP_CONFIG, field)) |
Gets a specified byte from the APP_CONFIG configuration structure
field | The byte to get from the APP_CONFIG structure. For example "MyMask.v[0]" |
#define appcfgPutc | ( | offset, | |||
value | ) | EEDATA = (value); _appcfgPutc(offset) |
Set a specified byte in the APP_CONFIG configuration structure to a given value. This function will only update the EEPROM if the given new value is different from the current old value. This saves the EEPROM, and increases it's live!
offset | The byte to set in the APP_CONFIG structure. Use the APPCFG_X defines | |
value | Contains the value to set the given byte to |
#define appcfgPutcAtField | ( | field, | |||
value | ) | EEDATA = (value); _appcfgPutc(offsetof(APP_CONFIG, field)) |
Set a specified byte from the APP_CONFIG configuration structure to a given value.
field | The byte to set in the APP_CONFIG structure. For example "MyMask.v[0]" | |
value | Contains the value to set the given byte to |
#define BAUD_115200 8 |
#define BAUD_1200 1 |
#define BAUD_19200 5 |
#define BAUD_230400 9 |
#define BAUD_2400 2 |
#define BAUD_300 0 |
#define BAUD_38400 6 |
#define BAUD_460800 10 |
#define BAUD_4800 3 |
#define BAUD_57600 7 |
#define BAUD_921600 11 |
#define BAUD_9600 4 |
#define BUSCFG_BUS1_TXBUFSIZE BUSCFG_SER1_TXBUFSIZE |
#define pwmIs10BitMode | ( | ) | (PR2 == 255) |
Return TRUE if the PWM is currently in 10-bit mode
#define pwmIs8BitMode | ( | ) | (PR2 == 63) |
Return TRUE if the PWM is currently in 10-bit mode
#define XBRD_TYPE_IOR5E 2 |
#define XBRD_TYPE_MAX 2 |
#define XBRD_TYPE_MXD2R 1 |
#define XBRD_TYPE_NONE 0 |
typedef struct _APP_CONFIG APP_CONFIG |
Structure for storing application configuration data that needs fast access. This structure is created in the processors internal RAM, and is initialized with the contents of the corresponding bytes in EEPROM at startup. Whenever the application needs to access any of these variables, it will read them straight from this RAM structure in stead of reading them from the EEPROM.
enum APP_CONFIG_ENUM |
Main application config structure. This structure lives in the internal EEPROM, starting at address 0.
!!! IMPORTANT - Only add to end the of this structure!!!
This structure can NOT get larger then 256 bytes. If it does, some code will have to be changed!
enum BUS_CONFIG_ENUM |
Second application config structure. Contains configuration for SPI, I2C, USART, CAN, USB serial buses. This structure lives in the internal EEPROM, starting at address 256.
!!! IMPORTANT - Only add to end the of this structure!!!
This structure can NOT get larger then 256 bytes. If it does, some code will have to be changed!
BUSCFG_SER1_TXBUFSIZE |
Serial Bus 1 Tx Buffer size Offset = 0 = 0x00
Serial Bus 1 Rx Buffer size |
BUSCFG_SER1_RXBUFSIZE |
Offset = 1 = 0x01.
Serial Bus 2 Tx Buffer size |
BUSCFG_SER2_TXBUFSIZE |
Offset = 2 = 0x02.
Serial Bus 2 Rx Buffer size |
BUSCFG_SER2_RXBUFSIZE |
Offset = 3 = 0x03.
I2C Bus 1 Tx Buffer size |
BUSCFG_I2C1_TXBUFSIZE |
Offset = 4 = 0x04.
I2C Bus 1 Rx Buffer size |
BUSCFG_I2C1_RXBUFSIZE |
Offset = 5 = 0x05.
SPI Bus 1 Tx Buffer size |
BUSCFG_SPI1_TXBUFSIZE |
Offset = 6 = 0x06.
SPI Bus 1 Rx Buffer size |
BUSCFG_SPI1_RXBUFSIZE |
Offset = 7 = 0x07.
Reserved for Serial Bus 5 to 8 |
BUSCFG_BUS5_TXBUFSIZE | Offset = 8 = 0x08. |
BUSCFG_BUS5_RXBUFSIZE | Offset = 9 = 0x09. |
BUSCFG_BUS6_TXBUFSIZE | Offset = 10 = 0x0A. |
BUSCFG_BUS6_RXBUFSIZE | Offset = 11 = 0x0B. |
BUSCFG_BUS7_TXBUFSIZE | Offset = 12 = 0x0C. |
BUSCFG_BUS7_RXBUFSIZE | Offset = 13 = 0x0D. |
BUSCFG_BUS8_TXBUFSIZE | Offset = 14 = 0x0E. |
BUSCFG_BUS8_RXBUFSIZE |
Offset = 15 = 0x0F.
UDP 1 Port |
BUSCFG_UDP1_PORT0 | Offset = 16 = 0x10. |
BUSCFG_UDP1_PORT1 |
Offset = 17 = 0x11.
UDP Port 1 Flags
|
BUSCFG_UDP1_CFG |
Offset = 18 = 0x12.
UDP 2 Port |
BUSCFG_UDP2_PORT0 | Offset = 19 = 0x13. |
BUSCFG_UDP2_PORT1 |
Offset = 20 = 0x14.
UDP Port 2 Flags
|
BUSCFG_UDP2_CFG |
Offset = 21 = 0x15.
BUS that UDP Port 1 is linked to, 0xff is non |
BUSCFG_UDP1_LINK |
Offset = 22 = 0x16.
BUS that UDP Port 2 is linked to, 0xff is non |
BUSCFG_UDP2_LINK |
Offset = 23 = 0x17.
Software SPI buses enabled. Bits 0 to 7 indicate which software SPI buses have been enabled. |
BUSCFG_SWSPI_ENABLED |
Offset = 24 = 0x18.
Software SPI 1 CLK pin. Bits 4-7 point to port (0=a, 1=b..), and bits 0-3 the bit |
BUSCFG_SWSPI1_CLKPIN |
Offset = 25 = 0x19.
Software SPI 1 SDI pin. Bits 4-7 point to port (0=a, 1=b..), and bits 0-3 the bit |
BUSCFG_SWSPI1_SDIPIN |
Offset = 26 = 0x1A.
Software SPI 1 SDO pin. Bits 4-7 point to port (0=a, 1=b..), and bits 0-3 the bit |
BUSCFG_SWSPI1_SDOPIN |
Offset = 27 = 0x1B.
Software SPI 1 CS pin. Bits 4-7 point to port (0=a, 1=b..), and bits 0-3 the bit |
BUSCFG_SWSPI1_CSPIN |
Offset = 28 = 0x1C.
Software SPI 1 config.
|
BUSCFG_SWSPI1_CONF | Offset = 29 = 0x1D. |
void _appcfgPutc | ( | WORD | offset | ) |
Set a specified byte from the APP_CONFIG configuration structure with the data contained in the EEDATA byte.
offset | Contains the offset in the APP_CONFIG structure of the byte to get |
void appcfgADC | ( | void | ) |
Configure the ADC unit
void appcfgCpuIO | ( | void | ) |
Configure the CPU I/O ports
void appcfgCpuIOValues | ( | void | ) |
Configure the CPU I/O ports to have the configured default values
Get a specified byte from the APP_CONFIG configuration structure
offset | Contains the offset in the APP_CONFIG structure of the byte to get. Use the APPCFG_X defines |
void appcfgInit | ( | void | ) |
void appcfgPWM | ( | void | ) |
void appcfgSave | ( | void | ) |
Save Application Configuartion data to EEPROM
void appcfgUSART | ( | void | ) |
Configure USART with AppConfig data
void appcfgUSART2 | ( | void | ) |
Configure USART2 with AppConfig data
void appcfgXboard | ( | void | ) |
Configure the Expansion Board
Enables/Disables given PWM channels
chan | Bits 0-4 indicate if PWM channels 1-5 must be enabled or disabled | |
remember | If 1, store in EEPROM and remember |
BYTE pwmGetFreq | ( | void | ) |
Gets a constant value representing the current PWM frequency
Get the value of the given PWM channel
ch | PWM channnel, is a value from 1 to 5 |
Sets the PWM frequency to the given value
freq | New frequency, a value from 0-3. For 8 bit mode: 0 and 1=9.766kHz, 2=39.062kHz, 3=156.25kHz For 10 bit mode: 0=2.441kHz, 1=9.766kHz, 2 and 3=39.062kHz | |
remember | If 1, store in EEPROM and remember |
Set the given PWM channel to the given value
ch | PWM channnel, is a value from 1 to 5 | |
val | The value to set the channel.
| |
remember | If 1, store in EEPROM and remember |