Initial commit
This commit is contained in:
33
Clean_TMC2209/CMakeLists.txt
Normal file
33
Clean_TMC2209/CMakeLists.txt
Normal file
@@ -0,0 +1,33 @@
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
|
||||
set(PROJECT_NAME "Uart_TMC2209_test")
|
||||
set(PICO_SDK_PATH "E:/Beyon_Motion/pico-sdk")
|
||||
set(PICO_TOOLCHAIN_PATH "C:/Users/spide/scoop/apps/gcc-arm-none-eabi/current/bin")
|
||||
set(CMAKE_C_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
|
||||
include(${PICO_SDK_PATH}/external/pico_sdk_import.cmake)
|
||||
|
||||
project(${PROJECT_NAME} C CXX ASM) # Ajout de CXX ici
|
||||
|
||||
pico_sdk_init()
|
||||
|
||||
add_executable(${PROJECT_NAME}
|
||||
main.c
|
||||
Tmc2209.c
|
||||
Tmc_uart.c
|
||||
)
|
||||
|
||||
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
pico_stdlib
|
||||
hardware_i2c
|
||||
hardware_uart
|
||||
hardware_dma
|
||||
# TMC2209
|
||||
)
|
||||
|
||||
pico_enable_stdio_usb(${PROJECT_NAME} 1)
|
||||
pico_enable_stdio_uart(${PROJECT_NAME} 0)
|
||||
|
||||
pico_add_extra_outputs(${PROJECT_NAME})
|
||||
830
Clean_TMC2209/Tmc2209.c
Normal file
830
Clean_TMC2209/Tmc2209.c
Normal file
@@ -0,0 +1,830 @@
|
||||
// Tmc2209.c
|
||||
#include "Tmc2209.h"
|
||||
|
||||
|
||||
#define portMAX_DELAY 10
|
||||
#define UART_BUFFER_SIZE 64 // Taille du tampon UART, à ajuster selon vos besoins
|
||||
|
||||
// Adresses des registres
|
||||
#define GCONF 0x00
|
||||
#define GSTAT 0x01
|
||||
#define IFCNT 0x02
|
||||
#define IOIN 0x06
|
||||
#define IHOLD_IRUN 0x10
|
||||
#define TSTEP 0x12
|
||||
#define TCOOLTHRS 0x14
|
||||
#define SGTHRS 0x40
|
||||
#define SG_RESULT 0x41
|
||||
#define MSCNT 0x6A
|
||||
#define CHOPCONF 0x6C
|
||||
#define DRVSTATUS 0x6F
|
||||
#define VACTUAL 0x22
|
||||
|
||||
// Bits associés à GCONF
|
||||
#define I_SCALE_ANALOG (1 << 0)
|
||||
#define INTERNAL_RSENSE (1 << 1)
|
||||
#define EN_SPREADCYCLE (1 << 2)
|
||||
#define SHAFT (1 << 3)
|
||||
#define INDEX_OTPW (1 << 4)
|
||||
#define INDEX_STEP (1 << 5)
|
||||
#define MSTEP_REG_SELECT (1 << 7)
|
||||
|
||||
// Bits associés à GSTAT
|
||||
#define RESET (1 << 0)
|
||||
#define DRV_ERR (1 << 1)
|
||||
#define UV_CP (1 << 2)
|
||||
|
||||
// Bits associés à CHOPCONF
|
||||
#define VSENSE (1 << 17)
|
||||
#define MSRES0 (1 << 24)
|
||||
#define MSRES1 (1 << 25)
|
||||
#define MSRES2 (1 << 26)
|
||||
#define MSRES3 (1 << 27)
|
||||
#define INTPOL (1 << 28)
|
||||
|
||||
// Bits associés à IOIN
|
||||
#define IO_ENN (1 << 0)
|
||||
#define IO_STEP (1 << 7)
|
||||
#define IO_SPREAD (1 << 8)
|
||||
#define IO_DIR (1 << 9)
|
||||
|
||||
// Bits associés à DRVSTATUS
|
||||
#define STST (1U << 31)
|
||||
#define STEALTH (1U << 30)
|
||||
#define CS_ACTUAL (31U << 16)
|
||||
#define T157 (1 << 11)
|
||||
#define T150 (1 << 10)
|
||||
#define T143 (1 << 9)
|
||||
#define T120 (1 << 8)
|
||||
#define OLB (1 << 7)
|
||||
#define OLA (1 << 6)
|
||||
#define S2VSB (1 << 5)
|
||||
#define S2VSA (1 << 4)
|
||||
#define S2GB (1 << 3)
|
||||
#define S2GA (1 << 2)
|
||||
#define OT (1 << 1)
|
||||
#define OTPW (1 << 0)
|
||||
|
||||
// Bits associés à IHOLD_IRUN
|
||||
#define IHOLD (31 << 0)
|
||||
#define IRUN (31 << 8)
|
||||
#define IHOLDDELAY (15 << 16)
|
||||
|
||||
// Bits associés à SGTHRS
|
||||
#define SGTHRS_VAL (255 << 0)
|
||||
|
||||
// Autres constantes
|
||||
#define MRES_256 0
|
||||
#define MRES_128 1
|
||||
#define MRES_64 2
|
||||
#define MRES_32 3
|
||||
#define MRES_16 4
|
||||
#define MRES_8 5
|
||||
#define MRES_4 6
|
||||
#define MRES_2 7
|
||||
#define MRES_1 8
|
||||
|
||||
|
||||
|
||||
|
||||
void TMC2209_Init(TMC2209* tmc2209,TMC_UART* serial_instance) {
|
||||
|
||||
tmc2209->serial_instance = serial_instance;
|
||||
tmc2209->mtr_id = 0x00;
|
||||
tmc2209->rFrame[0] = 0x55;
|
||||
tmc2209->rFrame[1] = 0x00;
|
||||
tmc2209->rFrame[2] = 0x00;
|
||||
tmc2209->rFrame[3] = 0x00;
|
||||
tmc2209->wFrame[0] = 0x55;
|
||||
tmc2209->wFrame[1] = 0x00;
|
||||
tmc2209->wFrame[2] = 0x00;
|
||||
tmc2209->wFrame[3] = 0x00;
|
||||
tmc2209->wFrame[4] = 0x00;
|
||||
tmc2209->wFrame[5] = 0x00;
|
||||
tmc2209->wFrame[6] = 0x00;
|
||||
tmc2209->wFrame[7] = 0x00;
|
||||
tmc2209->result[0] = 0x00;
|
||||
tmc2209->result[1] = 0x00;
|
||||
tmc2209->result[2] = 0x00;
|
||||
tmc2209->result[3] = 0x00;
|
||||
|
||||
// return true;
|
||||
}
|
||||
|
||||
uint8_t compute_crc8_atm(const uint8_t *datagram, size_t length, uint8_t initial_value) {
|
||||
uint8_t crc = initial_value;
|
||||
|
||||
size_t i;
|
||||
int j;
|
||||
for (i = 0; i < length; i++) {
|
||||
uint8_t byte = datagram[i];
|
||||
for (j = 0; j < 8; j++) {
|
||||
if ((crc >> 7) ^ (byte & 0x01)) {
|
||||
crc = ((crc << 1) ^ 0x07) & 0xFF;
|
||||
} else {
|
||||
crc = (crc << 1) & 0xFF;
|
||||
}
|
||||
byte >>= 1;
|
||||
}
|
||||
}
|
||||
return crc;
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint64_t *read_reg(TMC2209* tmc2209, int reg) {
|
||||
|
||||
tmc2209->rFrame[0] = 0x55;
|
||||
tmc2209->rFrame[1] = tmc2209->mtr_id;
|
||||
tmc2209->rFrame[2] = reg;
|
||||
tmc2209->rFrame[3] = compute_crc8_atm(tmc2209->rFrame, 3, 0);
|
||||
|
||||
uart_putc(tmc2209->serial_instance->UART_ID, tmc2209->rFrame[0]);
|
||||
uart_putc(tmc2209->serial_instance->UART_ID, tmc2209->rFrame[1]);
|
||||
uart_putc(tmc2209->serial_instance->UART_ID, tmc2209->rFrame[2]);
|
||||
uart_putc(tmc2209->serial_instance->UART_ID, tmc2209->rFrame[3]);
|
||||
|
||||
uint64_t temp_result[12] = {0x00};
|
||||
|
||||
int i = 0;
|
||||
uint32_t start_time = time_us_32(); // Temps de départ en microsecondes
|
||||
while (time_us_32() - start_time < 2000 && i < 12) { // Lire pendant 2 ms
|
||||
if (uart_is_readable(tmc2209->serial_instance->UART_ID)) {
|
||||
uint64_t tempchar = uart_getc(tmc2209->serial_instance->UART_ID);
|
||||
temp_result[i] = tempchar;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
if (temp_result[11] == 0 ){
|
||||
tmc2209->result[0] = temp_result[6];
|
||||
tmc2209->result[1] = temp_result[7];
|
||||
tmc2209->result[2] = temp_result[8];
|
||||
tmc2209->result[3] = temp_result[9];
|
||||
}else{
|
||||
tmc2209->result[0] = temp_result[7];
|
||||
tmc2209->result[1] = temp_result[8];
|
||||
tmc2209->result[2] = temp_result[9];
|
||||
tmc2209->result[3] = temp_result[10];
|
||||
}
|
||||
|
||||
sleep_ms(3);
|
||||
return tmc2209->result;
|
||||
}
|
||||
|
||||
|
||||
uint32_t read_int(TMC2209* tmc2209, int reg) {
|
||||
uint8_t data[4]; // Array to store the 4-byte response
|
||||
|
||||
for (int tries = 0; tries < 10; tries++) {
|
||||
uint64_t* rtn = read_reg(tmc2209, reg);
|
||||
|
||||
if (rtn == NULL) {
|
||||
printf("TMC2209: read_reg failed to return data\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (sizeof(*rtn) >= sizeof(data)) {
|
||||
for (int i = 0; i < sizeof(data); i++) {
|
||||
data[i] = (uint8_t)(*rtn >> (8 * (sizeof(*rtn) - i - 1)));
|
||||
}
|
||||
} else {
|
||||
printf("TMC2209: expected at least 4 bytes, got %zu Bytes\n", sizeof(*rtn));
|
||||
continue;
|
||||
}
|
||||
|
||||
uint32_t result_int = (data[0] << 24) | (data[1] << 16) | (data[2] << 8) | data[3];
|
||||
|
||||
if (!(result_int & 0x80000000)) {
|
||||
return result_int;
|
||||
} else {
|
||||
printf("TMC2209: error in register response: 0x%08X\n", result_int);
|
||||
}
|
||||
}
|
||||
|
||||
printf("TMC2209: failed to read register after 10 tries\n");
|
||||
printf("TMC2209: is Stepper Powersupply switched on?\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
bool write_reg(TMC2209* tmc2209, int reg, int val) {
|
||||
tmc2209->wFrame[0] = 0x55;
|
||||
tmc2209->wFrame[1] = tmc2209->mtr_id;
|
||||
tmc2209->wFrame[2] = reg | 0x80;
|
||||
tmc2209->wFrame[3] = (val >> 24) & 0xFF;
|
||||
tmc2209->wFrame[4] = (val >> 16) & 0xFF;
|
||||
tmc2209->wFrame[5] = (val >> 8) & 0xFF;
|
||||
tmc2209->wFrame[6] = val & 0xFF;
|
||||
tmc2209->wFrame[7] = compute_crc8_atm(tmc2209->wFrame, sizeof(tmc2209->wFrame) - 1, 0);
|
||||
|
||||
// printf("val : %d\n",val);
|
||||
|
||||
// printf("Frames :");
|
||||
// for (int i = 0; i < 8; i++) {
|
||||
// printf("%X ", tmc2209->wFrame[i]);
|
||||
// }
|
||||
// printf("\n");
|
||||
|
||||
uart_putc(tmc2209->serial_instance->UART_ID, tmc2209->wFrame[0]);
|
||||
uart_putc(tmc2209->serial_instance->UART_ID, tmc2209->wFrame[1]);
|
||||
uart_putc(tmc2209->serial_instance->UART_ID, tmc2209->wFrame[2]);
|
||||
uart_putc(tmc2209->serial_instance->UART_ID, tmc2209->wFrame[3]);
|
||||
uart_putc(tmc2209->serial_instance->UART_ID, tmc2209->wFrame[4]);
|
||||
uart_putc(tmc2209->serial_instance->UART_ID, tmc2209->wFrame[5]);
|
||||
uart_putc(tmc2209->serial_instance->UART_ID, tmc2209->wFrame[6]);
|
||||
uart_putc(tmc2209->serial_instance->UART_ID, tmc2209->wFrame[7]);
|
||||
|
||||
sleep_ms(3);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool write_reg_check(TMC2209* tmc2209, int reg, int val) {
|
||||
|
||||
int ifcnt12 = read_int(tmc2209, IFCNT);
|
||||
unsigned int ifcnt1 = (unsigned int)tmc2209->result[0] << 24 |
|
||||
(unsigned int)tmc2209->result[1] << 16 |
|
||||
(unsigned int)tmc2209->result[2] << 8 |
|
||||
(unsigned int)tmc2209->result[3];
|
||||
|
||||
write_reg(tmc2209, reg, val);
|
||||
|
||||
int ifcnt22 = read_int(tmc2209, IFCNT);
|
||||
unsigned int ifcnt2 = (unsigned int)tmc2209->result[0] << 24 |
|
||||
(unsigned int)tmc2209->result[1] << 16 |
|
||||
(unsigned int)tmc2209->result[2] << 8 |
|
||||
(unsigned int)tmc2209->result[3];
|
||||
|
||||
if (ifcnt1 >= ifcnt2) {
|
||||
printf("TMC2209: writing not successful!\n");
|
||||
printf("reg: %X val: %d\n", reg, val);
|
||||
printf("ifcnt: %d %d\n", ifcnt1, ifcnt2);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void TMC2209_destroy(TMC2209* tmc2209) {
|
||||
// free(tmc2209);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void driver_status(TMC2209* tmc2209) {
|
||||
printf("TMC2209: ---\n");
|
||||
printf("TMC2209: DRIVER STATUS:\n");
|
||||
read_int(tmc2209, DRVSTATUS);
|
||||
unsigned int drvstatus = (unsigned int)tmc2209->result[0] << 24 |
|
||||
(unsigned int)tmc2209->result[1] << 16 |
|
||||
(unsigned int)tmc2209->result[2] << 8 |
|
||||
(unsigned int)tmc2209->result[3];
|
||||
|
||||
printf("Drvstatus : %d \n",drvstatus);
|
||||
|
||||
if (drvstatus & STST) {
|
||||
printf("TMC2209: Info: motor is standing still\n");
|
||||
} else {
|
||||
printf("TMC2209: Info: motor is running\n");
|
||||
}
|
||||
|
||||
if (drvstatus & STEALTH) {
|
||||
printf("TMC2209: Info: motor is running on StealthChop\n");
|
||||
} else {
|
||||
printf("TMC2209: Info: motor is running on SpreadCycle\n");
|
||||
}
|
||||
|
||||
int cs_act = drvstatus & CS_ACTUAL;
|
||||
cs_act >>= 16;
|
||||
printf("TMC2209: CS actual: %d\n", cs_act);
|
||||
|
||||
if (drvstatus & OLB) {
|
||||
printf("TMC2209: Warning: Open load detected on phase B\n");
|
||||
}
|
||||
if (drvstatus & OLA) {
|
||||
printf("TMC2209: Warning: Open load detected on phase A\n");
|
||||
}
|
||||
if (drvstatus & S2VSB) {
|
||||
printf("TMC2209: Error: Short on low-side MOSFET detected on phase B. The driver becomes disabled\n");
|
||||
}
|
||||
if (drvstatus & S2GA) {
|
||||
printf("TMC2209: Error: Short on low-side MOSFET detected on phase A. The driver becomes disabled\n");
|
||||
}
|
||||
if (drvstatus & S2GB) {
|
||||
printf("TMC2209: Error: Short to GND detected on phase B. The driver becomes disabled.\n");
|
||||
}
|
||||
if (drvstatus & S2GA) {
|
||||
printf("TMC2209: Error: Short to GND detected on phase A. The driver becomes disabled.\n");
|
||||
}
|
||||
if (drvstatus & OT) {
|
||||
printf("TMC2209: Error: Driver Overheating!\n");
|
||||
}
|
||||
if (drvstatus & OTPW) {
|
||||
printf("TMC2209: Warning: Driver Overheating Prewarning!\n");
|
||||
}
|
||||
}
|
||||
|
||||
// Fonction general_config
|
||||
void general_config(TMC2209* tmc2209) {
|
||||
printf("TMC2209: ---\n");
|
||||
printf("TMC2209: GENERAL CONFIG\n");
|
||||
read_int(tmc2209, GCONF);
|
||||
unsigned int gconf = (unsigned int)tmc2209->result[0] << 24 |
|
||||
(unsigned int)tmc2209->result[1] << 16 |
|
||||
(unsigned int)tmc2209->result[2] << 8 |
|
||||
(unsigned int)tmc2209->result[3];
|
||||
|
||||
printf("Gconf : %d \n",gconf);
|
||||
|
||||
if (gconf & I_SCALE_ANALOG) {
|
||||
printf("TMC2209: Driver is using voltage supplied to VREF as current reference\n");
|
||||
} else {
|
||||
printf("TMC2209: Driver is using internal reference derived from 5VOUT\n");
|
||||
}
|
||||
|
||||
if (gconf & INTERNAL_RSENSE) {
|
||||
printf("TMC2209: Internal sense resistors. Use current supplied into VREF as reference.\n");
|
||||
printf("TMC2209: VREF pin internally is driven to GND in this mode.\n");
|
||||
printf("TMC2209: This will most likely destroy your driver!!!\n");
|
||||
exit(EXIT_FAILURE);
|
||||
} else {
|
||||
printf("TMC2209: Operation with external sense resistors\n");
|
||||
}
|
||||
|
||||
if (gconf & EN_SPREADCYCLE) {
|
||||
printf("TMC2209: SpreadCycle mode enabled\n");
|
||||
} else {
|
||||
printf("TMC2209: StealthChop PWM mode enabled\n");
|
||||
}
|
||||
|
||||
if (gconf & SHAFT) {
|
||||
printf("TMC2209: Inverse motor direction\n");
|
||||
} else {
|
||||
printf("TMC2209: normal motor direction\n");
|
||||
}
|
||||
|
||||
if (gconf & INDEX_OTPW) {
|
||||
printf("TMC2209: INDEX pin outputs overtemperature prewarning flag\n");
|
||||
} else {
|
||||
printf("TMC2209: INDEX shows the first microstep position of sequencer\n");
|
||||
}
|
||||
|
||||
if (gconf & INDEX_STEP) {
|
||||
printf("TMC2209: INDEX output shows step pulses from internal pulse generator\n");
|
||||
} else {
|
||||
printf("TMC2209: INDEX output as selected by index_otpw\n");
|
||||
}
|
||||
}
|
||||
|
||||
// Fonction general_stat
|
||||
void general_stat(TMC2209* tmc2209) {
|
||||
printf("TMC2209: ---\n");
|
||||
printf("TMC2209: GENERAL STAT\n");
|
||||
read_int(tmc2209, GSTAT);
|
||||
unsigned int gstat = (unsigned int)tmc2209->result[0] << 24 |
|
||||
(unsigned int)tmc2209->result[1] << 16 |
|
||||
(unsigned int)tmc2209->result[2] << 8 |
|
||||
(unsigned int)tmc2209->result[3];
|
||||
|
||||
printf("Gstat : %d \n",gstat);
|
||||
if (gstat & RESET) {
|
||||
printf("TMC2209: The driver has been reset since the last read access to GSTAT\n");
|
||||
} else {
|
||||
printf("TMC2209: The driver has not been reset since the last read access to GSTAT\n");
|
||||
}
|
||||
|
||||
if (gstat & DRV_ERR) {
|
||||
printf("TMC2209: The driver has been shut down due to overtemperature or short circuit detection since the last read access\n");
|
||||
} else {
|
||||
printf("TMC2209: The driver has not been shut down due to overtemperature or short circuit detection since the last read access\n");
|
||||
}
|
||||
|
||||
if (gstat & UV_CP) {
|
||||
printf("TMC2209: Undervoltage detected on the charge pump. The driver is disabled in this case\n");
|
||||
} else {
|
||||
printf("TMC2209: No undervoltage detected on the charge pump. The driver is not disabled in this case\n");
|
||||
}
|
||||
|
||||
|
||||
printf("end Gstat\n");
|
||||
}
|
||||
|
||||
|
||||
bool set_vactual(TMC2209* tmc2209, int value) {
|
||||
return write_reg_check(tmc2209, VACTUAL, value);
|
||||
}
|
||||
|
||||
|
||||
|
||||
unsigned int set_bit(unsigned int value, unsigned int bit) {
|
||||
unsigned int temp = value | bit;
|
||||
// printf("value %d ,set_bit temp : %d\n" ,value,temp);
|
||||
return temp;
|
||||
}
|
||||
|
||||
|
||||
// Fonction pour définir un bit spécifique à 0
|
||||
unsigned int clear_bit(unsigned int value, unsigned int bit) {
|
||||
unsigned int temp = value & ~(bit);
|
||||
// printf("value %d ,clear_bit temp : %d\n" ,value,temp);
|
||||
return temp;
|
||||
}
|
||||
|
||||
|
||||
void clear_general_stat(TMC2209* tmc2209) {
|
||||
read_int(tmc2209, GSTAT);
|
||||
unsigned int gstat= (unsigned int)tmc2209->result[0] << 24 |
|
||||
(unsigned int)tmc2209->result[1] << 16 |
|
||||
(unsigned int)tmc2209->result[2] << 8 |
|
||||
(unsigned int)tmc2209->result[3];
|
||||
gstat = set_bit(gstat, RESET);
|
||||
gstat = set_bit(gstat, DRV_ERR);
|
||||
write_reg_check(tmc2209, GSTAT, gstat);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void set_voltage_sense(TMC2209* tmc2209, bool enabled) {
|
||||
read_int(tmc2209, CHOPCONF); // Lire la valeur actuelle du registre CHOPCONF
|
||||
unsigned int chopconf= (unsigned int)tmc2209->result[0] << 24 |
|
||||
(unsigned int)tmc2209->result[1] << 16 |
|
||||
(unsigned int)tmc2209->result[2] << 8 |
|
||||
(unsigned int)tmc2209->result[3];
|
||||
if (enabled) {
|
||||
chopconf |= VSENSE;
|
||||
} else {
|
||||
chopconf &= ~VSENSE;
|
||||
}
|
||||
|
||||
if (!write_reg_check(tmc2209, CHOPCONF, chopconf)) {
|
||||
printf("Erreur lors de l'écriture de la valeur dans le registre CHOPCONF\n");
|
||||
}
|
||||
}
|
||||
|
||||
bool get_voltage_sense(TMC2209* tmc2209) {
|
||||
read_int(tmc2209, CHOPCONF);
|
||||
unsigned int chopconf = (unsigned int)tmc2209->result[0] << 24 |
|
||||
(unsigned int)tmc2209->result[1] << 16 |
|
||||
(unsigned int)tmc2209->result[2] << 8 |
|
||||
(unsigned int)tmc2209->result[3];
|
||||
return (chopconf & VSENSE) != 0;
|
||||
}
|
||||
|
||||
|
||||
void set_current_flow(TMC2209* tmc2209,double run_current, double hold_current_multiplier, int hold_current_delay, double Vref) {
|
||||
double CS_IRun = 0.0;
|
||||
double Rsense = 0.11;
|
||||
double Vfs = 0.0;
|
||||
Vref = 5.4;
|
||||
hold_current_multiplier = 0.5;
|
||||
hold_current_delay = 10;
|
||||
run_current = 1800;
|
||||
|
||||
int voltage_sense = get_voltage_sense(tmc2209);
|
||||
|
||||
if (voltage_sense) {
|
||||
Vfs = 0.180 * Vref / 2.5;
|
||||
} else {
|
||||
Vfs = 0.325 * Vref / 2.5;
|
||||
}
|
||||
|
||||
CS_IRun = 32.0 * 1.41421 * run_current / 1000.0 * (Rsense + 0.02) / Vfs - 1;
|
||||
CS_IRun = fmin(CS_IRun, 31);
|
||||
CS_IRun = fmax(CS_IRun, 0);
|
||||
double CS_IHold = hold_current_multiplier * CS_IRun;
|
||||
CS_IRun = round(CS_IRun);
|
||||
CS_IHold = round(CS_IHold);
|
||||
|
||||
// printf("CS_IHold_rounded %.3f, CS_IRun_rounded %.3f, hold_current_delay %d\n" , CS_IHold, CS_IRun, hold_current_delay);
|
||||
|
||||
set_irun_ihold(tmc2209,CS_IHold, CS_IRun, hold_current_delay);
|
||||
}
|
||||
|
||||
int get_iscale_analog(TMC2209* tmc2209) {
|
||||
read_int(tmc2209, GCONF);
|
||||
unsigned int gconf = (unsigned int)tmc2209->result[0] << 24 |
|
||||
(unsigned int)tmc2209->result[1] << 16 |
|
||||
(unsigned int)tmc2209->result[2] << 8 |
|
||||
(unsigned int)tmc2209->result[3];
|
||||
|
||||
return (gconf & I_SCALE_ANALOG) ;
|
||||
}
|
||||
|
||||
void set_iscale_analog(TMC2209* tmc2209, bool enabled) {
|
||||
read_int(tmc2209, GCONF);
|
||||
unsigned int gconf = (unsigned int)tmc2209->result[0] << 24 |
|
||||
(unsigned int)tmc2209->result[1] << 16 |
|
||||
(unsigned int)tmc2209->result[2] << 8 |
|
||||
(unsigned int)tmc2209->result[3];
|
||||
|
||||
if (enabled) {
|
||||
gconf = set_bit(gconf, I_SCALE_ANALOG);
|
||||
} else {
|
||||
|
||||
gconf = clear_bit(gconf, I_SCALE_ANALOG);
|
||||
}
|
||||
|
||||
write_reg_check(tmc2209, GCONF, gconf);
|
||||
}
|
||||
|
||||
int get_interpolation(TMC2209* tmc2209) {
|
||||
read_int(tmc2209, CHOPCONF);
|
||||
unsigned int chopconf = (unsigned int)tmc2209->result[0] << 24 |
|
||||
(unsigned int)tmc2209->result[1] << 16 |
|
||||
(unsigned int)tmc2209->result[2] << 8 |
|
||||
(unsigned int)tmc2209->result[3];
|
||||
|
||||
return (chopconf & INTPOL) ;
|
||||
}
|
||||
|
||||
void set_interpolation(TMC2209* tmc2209, bool enabled) {
|
||||
read_int(tmc2209, CHOPCONF);
|
||||
unsigned int chopconf = (unsigned int)tmc2209->result[0] << 24 |
|
||||
(unsigned int)tmc2209->result[1] << 16 |
|
||||
(unsigned int)tmc2209->result[2] << 8 |
|
||||
(unsigned int)tmc2209->result[3];
|
||||
if (enabled) {
|
||||
chopconf = set_bit(chopconf, INTPOL);
|
||||
} else {
|
||||
chopconf = clear_bit(chopconf, INTPOL);
|
||||
}
|
||||
|
||||
write_reg_check(tmc2209, CHOPCONF, chopconf);
|
||||
}
|
||||
|
||||
int get_internal_resistor_sense(TMC2209* tmc2209) {
|
||||
read_int(tmc2209, GCONF);
|
||||
unsigned int gconf = (unsigned int)tmc2209->result[0] << 24 |
|
||||
(unsigned int)tmc2209->result[1] << 16 |
|
||||
(unsigned int)tmc2209->result[2] << 8 |
|
||||
(unsigned int)tmc2209->result[3];
|
||||
|
||||
return (gconf & INTERNAL_RSENSE) ;
|
||||
}
|
||||
|
||||
|
||||
void set_internal_resistor_sense(TMC2209* tmc2209, bool enabled) {
|
||||
read_int(tmc2209, GCONF);
|
||||
unsigned int gconf = (unsigned int)tmc2209->result[0] << 24 |
|
||||
(unsigned int)tmc2209->result[1] << 16 |
|
||||
(unsigned int)tmc2209->result[2] << 8 |
|
||||
(unsigned int)tmc2209->result[3];
|
||||
if (enabled) {
|
||||
|
||||
gconf = set_bit(gconf, INTERNAL_RSENSE);
|
||||
} else {
|
||||
|
||||
gconf = clear_bit(gconf, INTERNAL_RSENSE);
|
||||
}
|
||||
|
||||
write_reg_check(tmc2209, GCONF, gconf);
|
||||
}
|
||||
|
||||
int get_spread_cycle(TMC2209* tmc2209) {
|
||||
read_int(tmc2209, GCONF);
|
||||
unsigned int gconf = (unsigned int)tmc2209->result[0] << 24 |
|
||||
(unsigned int)tmc2209->result[1] << 16 |
|
||||
(unsigned int)tmc2209->result[2] << 8 |
|
||||
(unsigned int)tmc2209->result[3];
|
||||
|
||||
return (gconf & EN_SPREADCYCLE) ;
|
||||
}
|
||||
|
||||
|
||||
void set_spread_cycle(TMC2209* tmc2209, bool enabled) {
|
||||
read_int(tmc2209, GCONF);
|
||||
unsigned int gconf = (unsigned int)tmc2209->result[0] << 24 |
|
||||
(unsigned int)tmc2209->result[1] << 16 |
|
||||
(unsigned int)tmc2209->result[2] << 8 |
|
||||
(unsigned int)tmc2209->result[3];
|
||||
if (enabled) {
|
||||
|
||||
gconf = set_bit(gconf, EN_SPREADCYCLE);
|
||||
} else {
|
||||
|
||||
gconf = clear_bit(gconf, EN_SPREADCYCLE);
|
||||
}
|
||||
|
||||
write_reg_check(tmc2209, GCONF, gconf);
|
||||
}
|
||||
|
||||
void set_microstepping_resolution(TMC2209* tmc2209, int msres) {
|
||||
|
||||
read_int(tmc2209, CHOPCONF);
|
||||
unsigned int chopconf = (unsigned int)tmc2209->result[0] << 24 |
|
||||
(unsigned int)tmc2209->result[1] << 16 |
|
||||
(unsigned int)tmc2209->result[2] << 8 |
|
||||
(unsigned int)tmc2209->result[3];
|
||||
// printf("chopconf %d \n",chopconf);
|
||||
|
||||
int msresdezimal = 8 - (int)log2(msres);
|
||||
chopconf &= 4043309055;
|
||||
chopconf |= msresdezimal << 24;
|
||||
write_reg_check(tmc2209, CHOPCONF, chopconf);
|
||||
set_microstep_resolution_regselect(tmc2209, true);
|
||||
}
|
||||
|
||||
int get_microstepping_resolution(TMC2209* tmc2209) {
|
||||
read_int(tmc2209, CHOPCONF);
|
||||
unsigned int chopconf = (unsigned int)tmc2209->result[0] << 24 |
|
||||
(unsigned int)tmc2209->result[1] << 16 |
|
||||
(unsigned int)tmc2209->result[2] << 8 |
|
||||
(unsigned int)tmc2209->result[3];
|
||||
|
||||
|
||||
// printf("chopconf : %d\n", chopconf);
|
||||
int msresdezimal = chopconf & (MSRES0 | MSRES1 | MSRES2 | MSRES3);
|
||||
msresdezimal = msresdezimal >> 24;
|
||||
msresdezimal = 8 - msresdezimal;
|
||||
int micro_stepping_resolution = (int)pow(2, msresdezimal);
|
||||
|
||||
return micro_stepping_resolution;
|
||||
}
|
||||
|
||||
void set_microstep_resolution_regselect(TMC2209* tmc2209, bool enabled) {
|
||||
read_int(tmc2209, GCONF);
|
||||
unsigned int gconf = (unsigned int)tmc2209->result[0] << 24 |
|
||||
(unsigned int)tmc2209->result[1] << 16 |
|
||||
(unsigned int)tmc2209->result[2] << 8 |
|
||||
(unsigned int)tmc2209->result[3];
|
||||
if (enabled) {
|
||||
gconf = set_bit(gconf, MSTEP_REG_SELECT);
|
||||
} else {
|
||||
gconf = clear_bit(gconf, MSTEP_REG_SELECT);
|
||||
}
|
||||
// printf("gconf : %d \n",gconf);
|
||||
|
||||
write_reg_check(tmc2209, GCONF, gconf);
|
||||
}
|
||||
|
||||
|
||||
void set_irun_ihold(TMC2209* tmc2209, double IHold, double IRun, int IHoldDelay) {
|
||||
// Convertir les valeurs doubles en entiers
|
||||
int ihold_irun = 0;
|
||||
int ih = (int)IHold;
|
||||
int ir = (int)IRun;
|
||||
|
||||
ihold_irun |= ih << 0;
|
||||
// printf("ihold_irun1 : %d\n",ihold_irun);
|
||||
|
||||
ihold_irun |= ir << 8;
|
||||
// printf("ihold_irun2 : %d\n",ihold_irun);
|
||||
|
||||
ihold_irun |= IHoldDelay << 16;
|
||||
|
||||
// printf("ihold_irun3 : %d\n",ihold_irun);
|
||||
|
||||
write_reg_check(tmc2209, IHOLD_IRUN, ihold_irun);
|
||||
}
|
||||
|
||||
int get_direction_shart(TMC2209* tmc2209) {
|
||||
read_int(tmc2209, GCONF);
|
||||
unsigned int gconf = (unsigned int)tmc2209->result[0] << 24 |
|
||||
(unsigned int)tmc2209->result[1] << 16 |
|
||||
(unsigned int)tmc2209->result[2] << 8 |
|
||||
(unsigned int)tmc2209->result[3];
|
||||
|
||||
return (gconf & SHAFT) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void ioin(TMC2209* tmc2209) {
|
||||
printf("TMC2209: ---\n");
|
||||
printf("TMC2209: INPUTS\n");
|
||||
read_int(tmc2209, IOIN);
|
||||
unsigned int ioin = (unsigned int)tmc2209->result[0] << 24 |
|
||||
(unsigned int)tmc2209->result[1] << 16 |
|
||||
(unsigned int)tmc2209->result[2] << 8 |
|
||||
(unsigned int)tmc2209->result[3];
|
||||
|
||||
|
||||
if (ioin & IO_SPREAD) {
|
||||
printf("TMC2209: spread is high\n");
|
||||
} else {
|
||||
printf("TMC2209: spread is low\n");
|
||||
}
|
||||
|
||||
if (ioin & IO_DIR) {
|
||||
printf("TMC2209: dir is high\n");
|
||||
} else {
|
||||
printf("TMC2209: dir is low\n");
|
||||
}
|
||||
|
||||
if (ioin & IO_STEP) {
|
||||
printf("TMC2209: step is high\n");
|
||||
} else {
|
||||
printf("TMC2209: step is low\n");
|
||||
}
|
||||
|
||||
if (ioin & IO_ENN) {
|
||||
printf("TMC2209: en is high\n");
|
||||
} else {
|
||||
printf("TMC2209: en is low\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void chopper_control(TMC2209* tmc2209, int direction) {
|
||||
printf("TMC2209: ---\n");
|
||||
printf("TMC2209: CHOPPER CONTROL\n");
|
||||
read_int(tmc2209, CHOPCONF);
|
||||
unsigned int chopconf = (unsigned int)tmc2209->result[0] << 24 |
|
||||
(unsigned int)tmc2209->result[1] << 16 |
|
||||
(unsigned int)tmc2209->result[2] << 8 |
|
||||
(unsigned int)tmc2209->result[3];
|
||||
|
||||
if (chopconf & INTPOL) {
|
||||
printf("TMC2209: interpolation to 256 microsteps\n");
|
||||
}
|
||||
|
||||
if (chopconf & VSENSE) {
|
||||
printf("TMC2209: 1: High sensitivity, low sense resistor voltage\n");
|
||||
} else {
|
||||
printf("TMC2209: 0: Low sensitivity, high sense resistor voltage\n");
|
||||
}
|
||||
}
|
||||
|
||||
void set_direction_shart(TMC2209* tmc2209, int direction) {
|
||||
read_int(tmc2209, GCONF);
|
||||
unsigned int gconf = (unsigned int)tmc2209->result[0] << 24 |
|
||||
(unsigned int)tmc2209->result[1] << 16 |
|
||||
(unsigned int)tmc2209->result[2] << 8 |
|
||||
(unsigned int)tmc2209->result[3];
|
||||
int dir = get_direction_shart(tmc2209);
|
||||
// printf("dir : %d , dir 8 : %d\n",dir,dir / 8);
|
||||
if ((dir / 8) != direction) {
|
||||
if (direction) {
|
||||
gconf = set_bit(gconf, SHAFT);
|
||||
} else {
|
||||
gconf = clear_bit(gconf, SHAFT);
|
||||
}
|
||||
// printf("gconf : %d \n",gconf);
|
||||
|
||||
write_reg_check(tmc2209, GCONF, gconf);
|
||||
sleep_us(100);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int get_stallguard(TMC2209* tmc2209) {
|
||||
read_int(tmc2209, SG_RESULT);
|
||||
unsigned int stg = (unsigned int)tmc2209->result[0] << 24 |
|
||||
(unsigned int)tmc2209->result[1] << 16 |
|
||||
(unsigned int)tmc2209->result[2] << 8 |
|
||||
(unsigned int)tmc2209->result[3];
|
||||
|
||||
return stg ;
|
||||
}
|
||||
|
||||
|
||||
void set_stallguard_threshold(TMC2209* tmc2209, int threshold){
|
||||
write_reg_check(tmc2209,SGTHRS, threshold);
|
||||
}
|
||||
|
||||
void set_coolstep_threshold(TMC2209* tmc2209, int threshold){
|
||||
write_reg_check(tmc2209,TCOOLTHRS, threshold);
|
||||
}
|
||||
|
||||
|
||||
void set_stallguard_callback(TMC2209* tmc2209, int stallguard_pin, int threshold, int callback, int min_speed){
|
||||
set_stallguard_threshold(tmc2209,threshold);
|
||||
set_coolstep_threshold(tmc2209,min_speed);
|
||||
|
||||
gpio_set_function(stallguard_pin, GPIO_FUNC_SIO);
|
||||
gpio_pull_up(stallguard_pin);
|
||||
|
||||
gpio_set_irq_enabled_with_callback(stallguard_pin, GPIO_IRQ_EDGE_RISE, true, callback);
|
||||
|
||||
}
|
||||
|
||||
int get_tstep(TMC2209* tmc2209) {
|
||||
read_int(tmc2209, TSTEP);
|
||||
unsigned int gconf = (unsigned int)tmc2209->result[0] << 24 |
|
||||
(unsigned int)tmc2209->result[1] << 16 |
|
||||
(unsigned int)tmc2209->result[2] << 8 |
|
||||
(unsigned int)tmc2209->result[3];
|
||||
|
||||
return gconf ;
|
||||
}
|
||||
|
||||
|
||||
int get_microstep_counter(TMC2209* tmc2209, bool in_steps, int offset) {
|
||||
read_int(tmc2209, MSCNT);
|
||||
unsigned int mscnt = (unsigned int)tmc2209->result[0] << 24 |
|
||||
(unsigned int)tmc2209->result[1] << 16 |
|
||||
(unsigned int)tmc2209->result[2] << 8 |
|
||||
(unsigned int)tmc2209->result[3];
|
||||
|
||||
if (!in_steps) {
|
||||
return mscnt;
|
||||
}
|
||||
|
||||
int micro_stepping_resolution = get_microstepping_resolution(tmc2209); // Remplacez par la résolution réelle du micro-pas
|
||||
return round((4 * micro_stepping_resolution) - ((mscnt - 64) * (micro_stepping_resolution * 4) / 1024) - 1) + offset;
|
||||
}
|
||||
66
Clean_TMC2209/Tmc2209.h
Normal file
66
Clean_TMC2209/Tmc2209.h
Normal file
@@ -0,0 +1,66 @@
|
||||
// Tmc2209.h
|
||||
#ifndef TMC2209_H
|
||||
#define TMC2209_H
|
||||
|
||||
#include "pico/stdlib.h"
|
||||
#include "Tmc_uart.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
typedef struct {
|
||||
TMC_UART* serial_instance;
|
||||
int mtr_id;
|
||||
uint8_t rFrame[4];
|
||||
uint8_t wFrame[8];
|
||||
uint64_t result[4];
|
||||
} TMC2209;
|
||||
|
||||
void TMC2209_Init(TMC2209* tmc2209, TMC_UART* serial_instance); //ok
|
||||
void TMC2209_destroy(TMC2209* tmc2209); //TODO
|
||||
uint8_t compute_crc8_atm(const uint8_t *datagram, size_t length, uint8_t initial_value); //ok
|
||||
uint64_t* read_reg(TMC2209* tmc2209, int reg) ; //ok
|
||||
uint32_t read_int(TMC2209* tmc2209, int reg); //ok
|
||||
bool write_reg(TMC2209* tmc2209, int reg, int val); //ok
|
||||
bool write_reg_check(TMC2209* tmc2209, int reg, int val) ; //ok
|
||||
|
||||
void driver_status(TMC2209* tmc2209); //NotWork
|
||||
void general_config(TMC2209* tmc2209); //NotWork
|
||||
void general_stat(TMC2209* tmc2209); //NotWork
|
||||
|
||||
bool set_vactual(TMC2209* tmc2209, int value); //ok
|
||||
void set_voltage_sense(TMC2209* tmc2209, bool enabled); //ok
|
||||
bool get_voltage_sense(TMC2209* tmc2209); //ok
|
||||
void set_current_flow(TMC2209* tmc2209, double run_current, double hold_current_multiplier, int hold_current_delay, double Vref);//averif NotWork
|
||||
|
||||
int get_iscale_analog(TMC2209* tmc2209); //ok
|
||||
void set_iscale_analog(TMC2209* tmc2209, bool enabled); //ok
|
||||
int get_interpolation(TMC2209* tmc2209); //ok
|
||||
void set_interpolation(TMC2209* tmc2209, bool enabled); //ok
|
||||
int get_internal_resistor_sense(TMC2209* tmc2209); //ok
|
||||
void set_internal_resistor_sense(TMC2209* tmc2209, bool enabled); //ok
|
||||
int get_spread_cycle(TMC2209* tmc2209); //NotWork
|
||||
void set_spread_cycle(TMC2209* tmc2209, bool enabled); //NotWork
|
||||
|
||||
void set_microstepping_resolution(TMC2209* tmc2209, int msres); //ok
|
||||
int get_microstepping_resolution(TMC2209* tmc2209); //ok
|
||||
void set_microstep_resolution_regselect(TMC2209* tmc2209, bool enabled); //ok
|
||||
void set_irun_ihold(TMC2209* tmc2209, double IHold, double IRun, int IHoldDelay); //ok
|
||||
|
||||
int get_direction_shart(TMC2209* tmc2209); //ok
|
||||
void ioin(TMC2209* tmc2209);
|
||||
void clear_general_stat(TMC2209* tmc2209); //ok
|
||||
void set_direction_shart(TMC2209* tmc2209, int direction); //ok
|
||||
|
||||
int get_stallguard(TMC2209* tmc2209);
|
||||
void set_stallguard_threshold(TMC2209* tmc2209, int threshold);
|
||||
void set_coolstep_threshold(TMC2209* tmc2209, int threshold);
|
||||
void set_stallguard_callback(TMC2209* tmc2209, int stallguard_pin, int threshold, int callback, int min_speed);
|
||||
int get_tstep(TMC2209* tmc2209);
|
||||
int get_microstep_counter(TMC2209* tmc2209, bool in_steps, int offset);
|
||||
|
||||
#endif
|
||||
36
Clean_TMC2209/Tmc_uart.c
Normal file
36
Clean_TMC2209/Tmc_uart.c
Normal file
@@ -0,0 +1,36 @@
|
||||
// TMC_UART.c
|
||||
#include "TMC_uart.h"
|
||||
|
||||
|
||||
#define DEFAULT_UART_ID uart1
|
||||
#define DEFAULT_BAUD_RATE 115200
|
||||
#define DEFAULT_MOTOR_TX_PIN 4
|
||||
#define DEFAULT_MOTOR_RX_PIN 5
|
||||
|
||||
TMC_UART* tmc_Uart_Init(TMC_UART* tmc_uart, uart_inst_t *UART_ID, int BAUD_RATE, int MOTOR_TX_PIN, int MOTOR_RX_PIN) {
|
||||
|
||||
if (BAUD_RATE == -1) BAUD_RATE = DEFAULT_BAUD_RATE;
|
||||
if (MOTOR_TX_PIN == -1) MOTOR_TX_PIN = DEFAULT_MOTOR_TX_PIN;
|
||||
if (MOTOR_RX_PIN == -1) MOTOR_RX_PIN = DEFAULT_MOTOR_RX_PIN;
|
||||
|
||||
uart_init(UART_ID, BAUD_RATE);
|
||||
gpio_set_function(MOTOR_TX_PIN, GPIO_FUNC_UART);
|
||||
gpio_set_function(MOTOR_RX_PIN, GPIO_FUNC_UART);
|
||||
uart_set_hw_flow(UART_ID, false, false);
|
||||
uart_set_format(UART_ID, 8, 1, UART_PARITY_NONE);
|
||||
uart_set_fifo_enabled(UART_ID, false);
|
||||
|
||||
tmc_uart->UART_ID = UART_ID;
|
||||
tmc_uart->BAUD_RATE = BAUD_RATE;
|
||||
tmc_uart->MOTOR_TX_PIN = MOTOR_TX_PIN;
|
||||
tmc_uart->MOTOR_RX_PIN = MOTOR_RX_PIN;
|
||||
return tmc_uart;
|
||||
}
|
||||
|
||||
void TMC_UART_Write(TMC_UART* tmc_uart, int data) {
|
||||
uart_putc(tmc_uart->UART_ID, data);
|
||||
}
|
||||
|
||||
void TMC_UART_Destroy(TMC_UART* tmc_uart) {
|
||||
// Aucune opération nécessaire
|
||||
}
|
||||
18
Clean_TMC2209/Tmc_uart.h
Normal file
18
Clean_TMC2209/Tmc_uart.h
Normal file
@@ -0,0 +1,18 @@
|
||||
// TMC_UART.h
|
||||
#ifndef TMC_UART_H
|
||||
#define TMC_UART_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include "pico/stdlib.h"
|
||||
|
||||
typedef struct {
|
||||
uart_inst_t *UART_ID;
|
||||
int BAUD_RATE;
|
||||
int MOTOR_TX_PIN;
|
||||
int MOTOR_RX_PIN;
|
||||
} TMC_UART;
|
||||
|
||||
TMC_UART* tmc_Uart_Init(TMC_UART* tmc_uart, uart_inst_t *UART_ID, int BAUD_RATE, int MOTOR_TX_PIN, int MOTOR_RX_PIN);
|
||||
void tmc_Uart_Destroy(TMC_UART* TMC_UART);
|
||||
|
||||
#endif
|
||||
172
Clean_TMC2209/lib/tmc/boards/Board.c
Normal file
172
Clean_TMC2209/lib/tmc/boards/Board.c
Normal file
@@ -0,0 +1,172 @@
|
||||
/*******************************************************************************
|
||||
* Copyright © 2019 TRINAMIC Motion Control GmbH & Co. KG
|
||||
* (now owned by Analog Devices Inc.),
|
||||
*
|
||||
* Copyright © 2023 Analog Devices Inc. All Rights Reserved. This software is
|
||||
* proprietary & confidential to Analog Devices, Inc. and its licensors.
|
||||
*******************************************************************************/
|
||||
|
||||
|
||||
#include "Board.h"
|
||||
|
||||
MotionControllerBoards motionControllerBoards;
|
||||
DriverBoards driverBoards;
|
||||
|
||||
static void deInit(void) {}
|
||||
|
||||
// Evalboard channel function dummies
|
||||
static uint32_t dummy_Motor(uint8_t motor)
|
||||
{
|
||||
UNUSED(motor);
|
||||
return TMC_ERROR_FUNCTION;
|
||||
}
|
||||
|
||||
static uint32_t dummy_MotorValue(uint8_t motor, int32_t value)
|
||||
{
|
||||
UNUSED(motor);
|
||||
UNUSED(value);
|
||||
return TMC_ERROR_FUNCTION;
|
||||
}
|
||||
|
||||
static void dummy_AddressRef(uint8_t motor, uint16_t address, int32_t *value)
|
||||
{
|
||||
UNUSED(motor);
|
||||
UNUSED(address);
|
||||
UNUSED(value);
|
||||
}
|
||||
|
||||
static void dummy_AddressValue(uint8_t motor, uint16_t address, int32_t value)
|
||||
{
|
||||
UNUSED(motor);
|
||||
UNUSED(address);
|
||||
UNUSED(value);
|
||||
}
|
||||
|
||||
static uint32_t dummy_MotorRef(uint8_t motor, int32_t *value)
|
||||
{
|
||||
UNUSED(motor);
|
||||
UNUSED(value);
|
||||
return TMC_ERROR_FUNCTION;
|
||||
}
|
||||
|
||||
static uint32_t dummy_TypeMotorValue(uint8_t type, uint8_t motor, int32_t value)
|
||||
{
|
||||
UNUSED(type);
|
||||
UNUSED(motor);
|
||||
UNUSED(value);
|
||||
return TMC_ERROR_FUNCTION;
|
||||
}
|
||||
|
||||
static uint32_t dummy_TypeMotorRef(uint8_t type, uint8_t motor, int32_t *value)
|
||||
{
|
||||
UNUSED(type);
|
||||
UNUSED(motor);
|
||||
UNUSED(value);
|
||||
return TMC_ERROR_FUNCTION;
|
||||
}
|
||||
|
||||
static uint32_t dummy_getLimit(uint8_t type, uint8_t motor, int32_t *value)
|
||||
{
|
||||
UNUSED(type);
|
||||
UNUSED(motor);
|
||||
UNUSED(value);
|
||||
return TMC_ERROR_FUNCTION;
|
||||
}
|
||||
|
||||
static uint8_t dummy_onPinChange(IOPinTypeDef *pin, IO_States state)
|
||||
{
|
||||
UNUSED(pin);
|
||||
UNUSED(state);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void dummy_OTP_init(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static void dummy_OTP_address(uint32_t address)
|
||||
{
|
||||
UNUSED(address);
|
||||
return;
|
||||
}
|
||||
|
||||
static void dummy_OTP_value(uint32_t value)
|
||||
{
|
||||
UNUSED(value);
|
||||
return;
|
||||
}
|
||||
|
||||
static void dummy_OTP_program(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static void dummy_OTP_lock(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static OTP_Status dummy_OTP_status(void)
|
||||
{
|
||||
return OTP_STATUS_IDLE;
|
||||
}
|
||||
|
||||
static uint8_t delegationReturn(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void enableDriver(DriverState state)
|
||||
{
|
||||
UNUSED(state);
|
||||
}
|
||||
|
||||
static void periodicJob(uint32_t tick)
|
||||
{
|
||||
UNUSED(tick);
|
||||
}
|
||||
|
||||
void board_setDummyFunctions(EvalboardFunctionsTypeDef *channel)
|
||||
{
|
||||
channel->config->reset = delegationReturn;
|
||||
channel->config->restore = delegationReturn;
|
||||
|
||||
channel->deInit = deInit;
|
||||
channel->periodicJob = periodicJob;
|
||||
channel->left = dummy_MotorValue;
|
||||
channel->stop = dummy_Motor;
|
||||
channel->moveTo = dummy_MotorValue;
|
||||
channel->moveBy = dummy_MotorRef;
|
||||
channel->moveProfile = dummy_MotorValue;
|
||||
channel->right = dummy_MotorValue;
|
||||
channel->GAP = dummy_TypeMotorRef;
|
||||
channel->readRegister = dummy_AddressRef;
|
||||
channel->writeRegister = dummy_AddressValue;
|
||||
channel->SAP = dummy_TypeMotorValue;
|
||||
channel->SIO = dummy_TypeMotorValue;
|
||||
channel->GIO = dummy_TypeMotorRef;
|
||||
channel->STAP = dummy_TypeMotorValue;
|
||||
channel->RSAP = dummy_TypeMotorValue;
|
||||
channel->userFunction = dummy_TypeMotorRef;
|
||||
channel->getMeasuredSpeed = dummy_MotorRef;
|
||||
channel->checkErrors = periodicJob;
|
||||
channel->enableDriver = enableDriver;
|
||||
|
||||
channel->fullCover = NULL;
|
||||
channel->getMin = dummy_getLimit;
|
||||
channel->getMax = dummy_getLimit;
|
||||
channel->onPinChange = dummy_onPinChange;
|
||||
|
||||
channel->OTP_init = dummy_OTP_init;
|
||||
channel->OTP_address = dummy_OTP_address;
|
||||
channel->OTP_value = dummy_OTP_value;
|
||||
channel->OTP_program = dummy_OTP_program;
|
||||
channel->OTP_status = dummy_OTP_status;
|
||||
channel->OTP_lock = dummy_OTP_lock;
|
||||
}
|
||||
|
||||
void periodicJobDummy(uint32_t tick)
|
||||
{
|
||||
UNUSED(tick);
|
||||
}
|
||||
197
Clean_TMC2209/lib/tmc/boards/Board.h
Normal file
197
Clean_TMC2209/lib/tmc/boards/Board.h
Normal file
@@ -0,0 +1,197 @@
|
||||
/*******************************************************************************
|
||||
* Copyright © 2019 TRINAMIC Motion Control GmbH & Co. KG
|
||||
* (now owned by Analog Devices Inc.),
|
||||
*
|
||||
* Copyright © 2023 Analog Devices Inc. All Rights Reserved. This software is
|
||||
* proprietary & confidential to Analog Devices, Inc. and its licensors.
|
||||
*******************************************************************************/
|
||||
|
||||
|
||||
#ifndef BOARD_H
|
||||
#define BOARD_H
|
||||
|
||||
#include "tmc/helpers/API_Header.h"
|
||||
|
||||
#include "hal/derivative.h"
|
||||
#include "hal/HAL.h"
|
||||
#include "tmc/VitalSignsMonitor.h"
|
||||
|
||||
#include "tmc/ic/TMC2130/TMC2130.h"
|
||||
#include "tmc/ic/TMC2160/TMC2160.h"
|
||||
#include "tmc/ic/TMC2208/TMC2208.h"
|
||||
#include "tmc/ic/TMC2224/TMC2224.h"
|
||||
#include "tmc/ic/TMC2590/TMC2590.h"
|
||||
#include "tmc/ic/TMC2660/TMC2660.h"
|
||||
#include "tmc/ic/TMC6100/TMC6100.h"
|
||||
#include "tmc/ic/TMC6200/TMC6200.h"
|
||||
#include "tmc/ic/TMC7300/TMC7300.h"
|
||||
|
||||
|
||||
#include "tmc/ic/TMC2209/TMC2209.h"
|
||||
#include "tmc/ic/TMC2225/TMC2225.h"
|
||||
#include "tmc/ic/TMC2226/TMC2226.h"
|
||||
#include "tmc/ic/TMC2300/TMC2300.h"
|
||||
#include "tmc/ic/MAX22216/MAX22216.h"
|
||||
#include "tmc/ic/TMC4361A/TMC4361A.h"
|
||||
#include "tmc/ic/TMC5031/TMC5031.h"
|
||||
#include "tmc/ic/TMC5041/TMC5041.h"
|
||||
#include "tmc/ic/TMC5062/TMC5062.h"
|
||||
#include "tmc/ic/TMC5072/TMC5072.h"
|
||||
#include "tmc/ic/TMC5130/TMC5130.h"
|
||||
#include "tmc/ic/TMC5160/TMC5160.h"
|
||||
#include "tmc/ic/TMC8461/TMC8461.h"
|
||||
#include "tmc/ic/TMC8462/TMC8462.h"
|
||||
|
||||
// parameter access (for axis parameters)
|
||||
#define READ 0
|
||||
#define WRITE 1
|
||||
|
||||
typedef enum {
|
||||
LIMIT_MIN,
|
||||
LIMIT_MAX
|
||||
} AxisParameterLimit;
|
||||
|
||||
typedef enum {
|
||||
DRIVER_DISABLE,
|
||||
DRIVER_ENABLE,
|
||||
DRIVER_USE_GLOBAL_ENABLE
|
||||
} DriverState;
|
||||
|
||||
typedef enum {
|
||||
OTP_STATUS_IDLE = 0,
|
||||
OTP_STATUS_PROGRAMMING = 1,
|
||||
OTP_STATUS_DONE = 2,
|
||||
OTP_STATUS_FAILED = 3
|
||||
} OTP_Status;
|
||||
|
||||
// Evalboard channel struct
|
||||
typedef struct
|
||||
{
|
||||
void *type;
|
||||
uint8_t id;
|
||||
uint32_t errors;
|
||||
int32_t VMMax;
|
||||
int32_t VMMin;
|
||||
unsigned char numberOfMotors;
|
||||
ConfigurationTypeDef *config;
|
||||
uint32_t (*left) (uint8_t motor, int32_t velocity); // move left with velocity <velocity>
|
||||
uint32_t (*right) (uint8_t motor, int32_t velocity); // move right with velocity <velocity>
|
||||
uint32_t (*rotate) (uint8_t motor, int32_t velocity); // move right with velocity <velocity>
|
||||
uint32_t (*stop) (uint8_t motor); // stop motor
|
||||
uint32_t (*moveTo) (uint8_t motor, int32_t position); // move to position <position>
|
||||
uint32_t (*moveBy) (uint8_t motor, int32_t *ticks); // move by <ticks>, changes ticks to absolute target
|
||||
uint32_t (*moveProfile) (uint8_t motor, int32_t position); // move profile <position>
|
||||
uint32_t (*SAP) (uint8_t type, uint8_t motor, int32_t value); // set axis parameter -> TMCL conformance
|
||||
uint32_t (*GAP) (uint8_t type, uint8_t motor, int32_t *value); // get axis parameter -> TMCL conformance
|
||||
uint32_t (*STAP) (uint8_t type, uint8_t motor, int32_t value); // store axis parameter -> TMCL conformance
|
||||
uint32_t (*RSAP) (uint8_t type, uint8_t motor, int32_t value); // restore axis parameter -> TMCL conformance
|
||||
uint32_t (*SIO) (uint8_t type, uint8_t motor, int32_t value);
|
||||
uint32_t (*GIO) (uint8_t type, uint8_t motor, int32_t *value);
|
||||
void (*readRegister) (uint8_t motor, uint16_t address, int32_t *value); // Motor needed since some chips utilize it as a switch between low and high values
|
||||
void (*writeRegister) (uint8_t motor, uint16_t address, int32_t value); // Motor needed since some chips utilize it as a switch between low and high values
|
||||
uint32_t (*getMeasuredSpeed) (uint8_t motor, int32_t *value);
|
||||
uint32_t (*userFunction) (uint8_t type, uint8_t motor, int32_t *value);
|
||||
|
||||
void (*periodicJob) (uint32_t tick);
|
||||
void (*deInit) (void);
|
||||
|
||||
void (*checkErrors) (uint32_t tick);
|
||||
void (*enableDriver) (DriverState state);
|
||||
|
||||
uint8_t (*cover) (uint8_t data, uint8_t lastTransfer);
|
||||
void (*fullCover) (uint8_t *data, size_t length);
|
||||
|
||||
uint32_t (*getMin) (uint8_t type, uint8_t motor, int32_t *value);
|
||||
uint32_t (*getMax) (uint8_t type, uint8_t motor, int32_t *value);
|
||||
|
||||
uint8_t (*onPinChange)(IOPinTypeDef *pin, IO_States state);
|
||||
|
||||
void (*OTP_init)(void);
|
||||
void (*OTP_address)(uint32_t address);
|
||||
void (*OTP_value)(uint32_t value);
|
||||
void (*OTP_program)(void);
|
||||
void (*OTP_lock)(void);
|
||||
OTP_Status (*OTP_status)(void);
|
||||
} EvalboardFunctionsTypeDef;
|
||||
|
||||
|
||||
// "hash" function to resolve API error <=> Map index
|
||||
inline uint8_t error_index(uint8_t error)
|
||||
{
|
||||
uint8_t i = 0;
|
||||
for(; error != 1; i++)
|
||||
error >>= 1;
|
||||
return i;
|
||||
}
|
||||
|
||||
// Evalboard errors
|
||||
// TODO: Extends API Error bits. For more information, see comment in TMCError typedef.
|
||||
typedef enum {
|
||||
TMC_ERROR_TYPE = 0x04,
|
||||
TMC_ERROR_ADDRESS = 0x04,
|
||||
TMC_ERROR_NOT_DONE = 0x20
|
||||
} EvalboardErrorBit;
|
||||
|
||||
// Channel identifiers required to switch between channels in readWrite
|
||||
typedef enum {
|
||||
CHANNEL_1,
|
||||
CHANNEL_2
|
||||
} EvalboardChannels;
|
||||
|
||||
// struct for our Evalsystem, with two available Evalboard channels
|
||||
typedef struct
|
||||
{
|
||||
EvalboardFunctionsTypeDef ch1;
|
||||
EvalboardFunctionsTypeDef ch2;
|
||||
DriverState driverEnable; // global driver status
|
||||
} EvalboardsTypeDef;
|
||||
|
||||
extern EvalboardsTypeDef Evalboards;
|
||||
|
||||
typedef enum {
|
||||
TMC_BOARD_COMM_DEFAULT,
|
||||
TMC_BOARD_COMM_SPI,
|
||||
TMC_BOARD_COMM_UART,
|
||||
TMC_BOARD_COMM_WLAN
|
||||
} TMC_Board_Comm_Mode;
|
||||
|
||||
// Group all the motion controller chip objects into a single union to save memory,
|
||||
// since we will only ever use one driver at a time
|
||||
typedef union {
|
||||
TMC4361ATypeDef tmc4361A;
|
||||
TMC5031TypeDef tmc5031;
|
||||
TMC5041TypeDef tmc5041;
|
||||
TMC5062TypeDef tmc5062;
|
||||
TMC5072TypeDef tmc5072;
|
||||
TMC5130TypeDef tmc5130;
|
||||
TMC5160TypeDef tmc5160;
|
||||
TMC8461TypeDef tmc8461;
|
||||
TMC8462TypeDef tmc8462;
|
||||
} MotionControllerBoards;
|
||||
extern MotionControllerBoards motionControllerBoards;
|
||||
|
||||
// Group all the driver chip objects into a single union to save memory,
|
||||
// since we will only ever use one motion controller at a time
|
||||
typedef union {
|
||||
TMC2130TypeDef tmc2130;
|
||||
TMC2160TypeDef tmc2160;
|
||||
TMC2208TypeDef tmc2208;
|
||||
TMC2224TypeDef tmc2224;
|
||||
TMC2590TypeDef tmc2590;
|
||||
TMC2660TypeDef tmc2660;
|
||||
TMC7300TypeDef tmc7300;
|
||||
TMC2209TypeDef tmc2209;
|
||||
TMC2225TypeDef tmc2225;
|
||||
TMC2226TypeDef tmc2226;
|
||||
TMC2300TypeDef tmc2300;
|
||||
MAX22216TypeDef max22216;
|
||||
} DriverBoards;
|
||||
extern DriverBoards driverBoards;
|
||||
|
||||
void periodicJobDummy(uint32_t tick);
|
||||
void board_setDummyFunctions(EvalboardFunctionsTypeDef *channel);
|
||||
|
||||
#include "TMCDriver.h"
|
||||
#include "TMCMotionController.h"
|
||||
|
||||
#endif /* BOARD_H */
|
||||
23
Clean_TMC2209/lib/tmc/boards/SelfTest.h
Normal file
23
Clean_TMC2209/lib/tmc/boards/SelfTest.h
Normal file
@@ -0,0 +1,23 @@
|
||||
/*******************************************************************************
|
||||
* Copyright © 2019 TRINAMIC Motion Control GmbH & Co. KG
|
||||
* (now owned by Analog Devices Inc.),
|
||||
*
|
||||
* Copyright © 2023 Analog Devices Inc. All Rights Reserved. This software is
|
||||
* proprietary & confidential to Analog Devices, Inc. and its licensors.
|
||||
*******************************************************************************/
|
||||
|
||||
|
||||
#ifndef SELF_TEST_H
|
||||
#define SELF_TEST_H
|
||||
|
||||
#define SELF_TEST_PINS_PER_GROUP 17
|
||||
#define SELF_TEST_LEAVE 1
|
||||
#define SELF_TEST_A_OUT_B_IN 2
|
||||
#define SELF_TEST_A_IN_B_OUT 3
|
||||
#define SELF_TEST_READ_AN 4
|
||||
#define SELF_TEST_SET_AN 5
|
||||
#define SELF_TEST_SET_AN_2 6
|
||||
#define SELF_TEST_SET_MIXED 7
|
||||
#define SELF_TEST_SET_EXTIO 8
|
||||
|
||||
#endif /* SELF_TEST_H */
|
||||
790
Clean_TMC2209/lib/tmc/boards/TMC2209_eval.c
Normal file
790
Clean_TMC2209/lib/tmc/boards/TMC2209_eval.c
Normal file
@@ -0,0 +1,790 @@
|
||||
/*******************************************************************************
|
||||
* Copyright © 2019 TRINAMIC Motion Control GmbH & Co. KG
|
||||
* (now owned by Analog Devices Inc.),
|
||||
*
|
||||
* Copyright © 2023 Analog Devices Inc. All Rights Reserved. This software is
|
||||
* proprietary & confidential to Analog Devices, Inc. and its licensors.
|
||||
*******************************************************************************/
|
||||
|
||||
|
||||
#include "Board.h"
|
||||
#include "tmc/ic/TMC2209/TMC2209.h"
|
||||
#include "tmc/StepDir.h"
|
||||
|
||||
#undef TMC2209_MAX_VELOCITY
|
||||
#define TMC2209_MAX_VELOCITY STEPDIR_MAX_VELOCITY
|
||||
|
||||
// Stepdir precision: 2^17 -> 17 digits of precision
|
||||
#define STEPDIR_PRECISION 131072
|
||||
|
||||
#define ERRORS_VM (1<<0)
|
||||
#define ERRORS_VM_UNDER (1<<1)
|
||||
#define ERRORS_VM_OVER (1<<2)
|
||||
|
||||
#define VM_MIN 50 // VM[V/10] min
|
||||
#define VM_MAX 390 // VM[V/10] max
|
||||
|
||||
#define MOTORS 1
|
||||
|
||||
#define VREF_FULLSCALE 2100 // mV // with R308 achievable Vref_max is ~2100mV
|
||||
//#define VREF_FULLSCALE 3300 // mV // without R308 achievable Vref_max is ~2500mV
|
||||
|
||||
|
||||
static uint32_t right(uint8_t motor, int32_t velocity);
|
||||
static uint32_t left(uint8_t motor, int32_t velocity);
|
||||
static uint32_t rotate(uint8_t motor, int32_t velocity);
|
||||
static uint32_t stop(uint8_t motor);
|
||||
static uint32_t moveTo(uint8_t motor, int32_t position);
|
||||
static uint32_t moveBy(uint8_t motor, int32_t *ticks);
|
||||
static uint32_t GAP(uint8_t type, uint8_t motor, int32_t *value);
|
||||
static uint32_t SAP(uint8_t type, uint8_t motor, int32_t value);
|
||||
|
||||
static void checkErrors (uint32_t tick);
|
||||
static void deInit(void);
|
||||
static uint32_t userFunction(uint8_t type, uint8_t motor, int32_t *value);
|
||||
|
||||
static void periodicJob(uint32_t tick);
|
||||
static uint8_t reset(void);
|
||||
static uint8_t restore(void);
|
||||
static void enableDriver(DriverState state);
|
||||
|
||||
static UART_Config *TMC2209_UARTChannel;
|
||||
static ConfigurationTypeDef *TMC2209_config;
|
||||
|
||||
static uint16_t vref; // mV
|
||||
static int32_t thigh;
|
||||
|
||||
static timer_channel timerChannel;
|
||||
// Helper macro - Access the chip object in the driver boards union
|
||||
#define TMC2209 (driverBoards.tmc2209)
|
||||
|
||||
// Helper macro - index is always 1 here (channel 1 <-> index 0, channel 2 <-> index 1)
|
||||
#define TMC2209_CRC(data, length) tmc_CRC8(data, length, 1)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
IOPinTypeDef *ENN;
|
||||
IOPinTypeDef *SPREAD;
|
||||
IOPinTypeDef *STEP;
|
||||
IOPinTypeDef *DIR;
|
||||
IOPinTypeDef *MS1_AD0;
|
||||
IOPinTypeDef *MS2_AD1;
|
||||
IOPinTypeDef *DIAG;
|
||||
IOPinTypeDef *INDEX;
|
||||
IOPinTypeDef *UC_PWM;
|
||||
IOPinTypeDef *STDBY;
|
||||
} PinsTypeDef;
|
||||
|
||||
static PinsTypeDef Pins;
|
||||
|
||||
static inline TMC2209TypeDef *motorToIC(uint8_t motor)
|
||||
{
|
||||
UNUSED(motor);
|
||||
|
||||
return &TMC2209;
|
||||
}
|
||||
|
||||
static inline UART_Config *channelToUART(uint8_t channel)
|
||||
{
|
||||
UNUSED(channel);
|
||||
|
||||
return TMC2209_UARTChannel;
|
||||
}
|
||||
|
||||
// => UART wrapper
|
||||
// Write [writeLength] bytes from the [data] array.
|
||||
// If [readLength] is greater than zero, read [readLength] bytes from the
|
||||
// [data] array.
|
||||
void tmc2209_readWriteArray(uint8_t channel, uint8_t *data, size_t writeLength, size_t readLength)
|
||||
{
|
||||
UART_readWrite(channelToUART(channel), data, writeLength, readLength);
|
||||
}
|
||||
// <= UART wrapper
|
||||
|
||||
// => CRC wrapper
|
||||
// Return the CRC8 of [length] bytes of data stored in the [data] array.
|
||||
uint8_t tmc2209_CRC8(uint8_t *data, size_t length)
|
||||
{
|
||||
return TMC2209_CRC(data, length);
|
||||
}
|
||||
// <= CRC wrapper
|
||||
|
||||
void tmc2209_writeRegister(uint8_t motor, uint16_t address, int32_t value)
|
||||
{
|
||||
tmc2209_writeInt(motorToIC(motor), (uint8_t) address, value);
|
||||
|
||||
}
|
||||
|
||||
void tmc2209_readRegister(uint8_t motor, uint16_t address, int32_t *value)
|
||||
{
|
||||
*value = tmc2209_readInt(motorToIC(motor), (uint8_t) address);
|
||||
}
|
||||
|
||||
static uint32_t rotate(uint8_t motor, int32_t velocity)
|
||||
{
|
||||
if(motor >= MOTORS)
|
||||
return TMC_ERROR_MOTOR;
|
||||
|
||||
StepDir_rotate(motor, velocity);
|
||||
|
||||
return TMC_ERROR_NONE;
|
||||
}
|
||||
|
||||
static uint32_t right(uint8_t motor, int32_t velocity)
|
||||
{
|
||||
return rotate(motor, velocity);
|
||||
}
|
||||
|
||||
static uint32_t left(uint8_t motor, int32_t velocity)
|
||||
{
|
||||
return rotate(motor, -velocity);
|
||||
}
|
||||
|
||||
static uint32_t stop(uint8_t motor)
|
||||
{
|
||||
return rotate(motor, 0);
|
||||
}
|
||||
|
||||
static uint32_t moveTo(uint8_t motor, int32_t position)
|
||||
{
|
||||
if(motor >= MOTORS)
|
||||
return TMC_ERROR_MOTOR;
|
||||
|
||||
StepDir_moveTo(motor, position);
|
||||
|
||||
return TMC_ERROR_NONE;
|
||||
}
|
||||
|
||||
static uint32_t moveBy(uint8_t motor, int32_t *ticks)
|
||||
{
|
||||
if(motor >= MOTORS)
|
||||
return TMC_ERROR_MOTOR;
|
||||
|
||||
// determine actual position and add numbers of ticks to move
|
||||
*ticks += StepDir_getActualPosition(motor);
|
||||
|
||||
return moveTo(motor, *ticks);
|
||||
}
|
||||
|
||||
static uint32_t handleParameter(uint8_t readWrite, uint8_t motor, uint8_t type, int32_t *value)
|
||||
{
|
||||
uint32_t errors = TMC_ERROR_NONE;
|
||||
int32_t buffer = 0;
|
||||
|
||||
if(motor >= MOTORS)
|
||||
return TMC_ERROR_MOTOR;
|
||||
|
||||
switch(type)
|
||||
{
|
||||
case 0:
|
||||
// Target position
|
||||
if(readWrite == READ) {
|
||||
*value = StepDir_getTargetPosition(motor);
|
||||
} else if(readWrite == WRITE) {
|
||||
StepDir_moveTo(motor, *value);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
// Actual position
|
||||
if(readWrite == READ) {
|
||||
*value = StepDir_getActualPosition(motor);
|
||||
} else if(readWrite == WRITE) {
|
||||
StepDir_setActualPosition(motor, *value);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
// Target speed
|
||||
if(readWrite == READ) {
|
||||
*value = StepDir_getTargetVelocity(motor);
|
||||
} else if(readWrite == WRITE) {
|
||||
StepDir_rotate(motor, *value);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
// Actual speed
|
||||
if(readWrite == READ) {
|
||||
*value = StepDir_getActualVelocity(motor);
|
||||
} else if(readWrite == WRITE) {
|
||||
errors |= TMC_ERROR_TYPE;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
// Maximum speed
|
||||
if(readWrite == READ) {
|
||||
*value = StepDir_getVelocityMax(motor);
|
||||
} else if(readWrite == WRITE) {
|
||||
StepDir_setVelocityMax(motor, abs(*value));
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
// Maximum acceleration
|
||||
if(readWrite == READ) {
|
||||
*value = StepDir_getAcceleration(motor);
|
||||
} else if(readWrite == WRITE) {
|
||||
StepDir_setAcceleration(motor, *value);
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
// Maximum current
|
||||
if(readWrite == READ) {
|
||||
*value = TMC2209_FIELD_READ(motorToIC(motor), TMC2209_IHOLD_IRUN, TMC2209_IRUN_MASK, TMC2209_IRUN_SHIFT);
|
||||
} else if(readWrite == WRITE) {
|
||||
TMC2209_FIELD_UPDATE(motorToIC(motor), TMC2209_IHOLD_IRUN, TMC2209_IRUN_MASK, TMC2209_IRUN_SHIFT, *value);
|
||||
}
|
||||
break;
|
||||
case 7:
|
||||
// Standby current
|
||||
if(readWrite == READ) {
|
||||
*value = TMC2209_FIELD_READ(motorToIC(motor), TMC2209_IHOLD_IRUN, TMC2209_IHOLD_MASK, TMC2209_IHOLD_SHIFT);
|
||||
} else if(readWrite == WRITE) {
|
||||
TMC2209_FIELD_UPDATE(motorToIC(motor), TMC2209_IHOLD_IRUN, TMC2209_IHOLD_MASK, TMC2209_IHOLD_SHIFT, *value);
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
// Position reached flag
|
||||
if(readWrite == READ) {
|
||||
*value = (StepDir_getStatus(motor) & STATUS_TARGET_REACHED)? 1:0;
|
||||
} else if(readWrite == WRITE) {
|
||||
errors |= TMC_ERROR_TYPE;
|
||||
}
|
||||
break;
|
||||
case 9:
|
||||
// VREF
|
||||
if (readWrite == READ) {
|
||||
*value = vref;
|
||||
} else {
|
||||
if ((uint32_t) *value < VREF_FULLSCALE) {
|
||||
vref = *value;
|
||||
Timer.setDuty(timerChannel, ((float)vref) / VREF_FULLSCALE);
|
||||
} else {
|
||||
errors |= TMC_ERROR_VALUE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 23:
|
||||
// Speed threshold for high speed mode
|
||||
if(readWrite == READ) {
|
||||
buffer = thigh;
|
||||
*value = MIN(0xFFFFF, (1<<24) / ((buffer) ? buffer : 1));
|
||||
} else if(readWrite == WRITE) {
|
||||
*value = MIN(0xFFFFF, (1<<24) / ((*value) ? *value : 1));
|
||||
thigh = *value;
|
||||
}
|
||||
break;
|
||||
case 28:
|
||||
// Internal RSense
|
||||
if(readWrite == READ) {
|
||||
*value = TMC2209_FIELD_READ(motorToIC(motor), TMC2209_GCONF, TMC2209_INTERNAL_RSENSE_MASK, TMC2209_INTERNAL_RSENSE_SHIFT);
|
||||
} else if(readWrite == WRITE) {
|
||||
TMC2209_FIELD_UPDATE(motorToIC(motor), TMC2209_GCONF, TMC2209_INTERNAL_RSENSE_MASK, TMC2209_INTERNAL_RSENSE_SHIFT, *value);
|
||||
}
|
||||
break;
|
||||
case 29:
|
||||
// Measured Speed
|
||||
if(readWrite == READ) {
|
||||
buffer = (int32_t)(((int64_t)StepDir_getFrequency(motor) * (int64_t)122) / (int64_t)TMC2209_FIELD_READ(motorToIC(motor), TMC2209_TSTEP, TMC2209_TSTEP_MASK, TMC2209_TSTEP_SHIFT));
|
||||
*value = (abs(buffer) < 20) ? 0 : buffer;
|
||||
} else if(readWrite == WRITE) {
|
||||
errors |= TMC_ERROR_TYPE;
|
||||
}
|
||||
break;
|
||||
case 50: // StepDir internal(0)/external(1)
|
||||
if(readWrite == READ) {
|
||||
*value = StepDir_getMode(motor);
|
||||
} else if(readWrite == WRITE) {
|
||||
StepDir_setMode(motor, *value);
|
||||
}
|
||||
break;
|
||||
case 51: // StepDir interrupt frequency
|
||||
if(readWrite == READ) {
|
||||
*value = StepDir_getFrequency(motor);
|
||||
} else if(readWrite == WRITE) {
|
||||
StepDir_setFrequency(motor, *value);
|
||||
}
|
||||
break;
|
||||
case 140:
|
||||
// Microstep Resolution
|
||||
if(readWrite == READ) {
|
||||
*value = 256 >> TMC2209_FIELD_READ(motorToIC(motor), TMC2209_CHOPCONF, TMC2209_MRES_MASK, TMC2209_MRES_SHIFT);
|
||||
} else if(readWrite == WRITE) {
|
||||
switch(*value)
|
||||
{
|
||||
case 1: *value = 8; break;
|
||||
case 2: *value = 7; break;
|
||||
case 4: *value = 6; break;
|
||||
case 8: *value = 5; break;
|
||||
case 16: *value = 4; break;
|
||||
case 32: *value = 3; break;
|
||||
case 64: *value = 2; break;
|
||||
case 128: *value = 1; break;
|
||||
case 256: *value = 0; break;
|
||||
default: *value = -1; break;
|
||||
}
|
||||
|
||||
if(*value != -1)
|
||||
{
|
||||
TMC2209_FIELD_UPDATE(motorToIC(motor), TMC2209_CHOPCONF, TMC2209_MRES_MASK, TMC2209_MRES_SHIFT, *value);
|
||||
}
|
||||
else
|
||||
{
|
||||
errors |= TMC_ERROR_VALUE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 162:
|
||||
// Chopper blank time
|
||||
if(readWrite == READ) {
|
||||
*value = TMC2209_FIELD_READ(motorToIC(motor), TMC2209_CHOPCONF, TMC2209_TBL_MASK, TMC2209_TBL_SHIFT);
|
||||
} else if(readWrite == WRITE) {
|
||||
TMC2209_FIELD_UPDATE(motorToIC(motor), TMC2209_CHOPCONF, TMC2209_TBL_MASK, TMC2209_TBL_SHIFT, *value);
|
||||
}
|
||||
break;
|
||||
case 165:
|
||||
// Chopper hysteresis end / fast decay time
|
||||
if(readWrite == READ) {
|
||||
if(tmc2209_readInt(motorToIC(motor), TMC2209_CHOPCONF) & (1<<14))
|
||||
{
|
||||
*value = TMC2209_FIELD_READ(motorToIC(motor), TMC2209_CHOPCONF, TMC2209_HEND_MASK, TMC2209_HEND_SHIFT);
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer = tmc2209_readInt(motorToIC(motor), TMC2209_CHOPCONF);
|
||||
*value = (tmc2209_readInt(motorToIC(motor), TMC2209_CHOPCONF) >> 4) & 0x07;
|
||||
if(buffer & (1<<11))
|
||||
*value |= 1<<3;
|
||||
}
|
||||
} else if(readWrite == WRITE) {
|
||||
errors |= TMC_ERROR_TYPE;
|
||||
}
|
||||
break;
|
||||
case 166:
|
||||
// Chopper hysteresis start / sine wave offset
|
||||
if(readWrite == READ) {
|
||||
if(tmc2209_readInt(motorToIC(motor), TMC2209_CHOPCONF) & (1<<14))
|
||||
{
|
||||
*value = TMC2209_FIELD_READ(motorToIC(motor), TMC2209_CHOPCONF, TMC2209_HSTRT_MASK, TMC2209_HSTRT_SHIFT);
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer = tmc2209_readInt(motorToIC(motor), TMC2209_CHOPCONF);
|
||||
*value = (tmc2209_readInt(motorToIC(motor), TMC2209_CHOPCONF) >> 7) & 0x0F;
|
||||
if(buffer & (1<<11))
|
||||
*value |= 1<<3;
|
||||
}
|
||||
} else if(readWrite == WRITE) {
|
||||
if(tmc2209_readInt(motorToIC(motor), TMC2209_CHOPCONF) & (1<<14))
|
||||
{
|
||||
TMC2209_FIELD_UPDATE(motorToIC(motor), TMC2209_CHOPCONF, TMC2209_HSTRT_MASK, TMC2209_HSTRT_SHIFT, *value);
|
||||
}
|
||||
else
|
||||
{
|
||||
TMC2209_FIELD_UPDATE(motorToIC(motor), TMC2209_CHOPCONF, TMC2209_HEND_MASK, TMC2209_HEND_SHIFT, *value);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 167:
|
||||
// Chopper off time
|
||||
if(readWrite == READ) {
|
||||
*value = TMC2209_FIELD_READ(motorToIC(motor), TMC2209_CHOPCONF, TMC2209_TOFF_MASK, TMC2209_TOFF_SHIFT);
|
||||
} else if(readWrite == WRITE) {
|
||||
TMC2209_FIELD_UPDATE(motorToIC(motor), TMC2209_CHOPCONF, TMC2209_TOFF_MASK, TMC2209_TOFF_SHIFT, *value);
|
||||
}
|
||||
break;
|
||||
case 168:
|
||||
// smartEnergy current minimum (SEIMIN)
|
||||
if(readWrite == READ) {
|
||||
*value = TMC2209_FIELD_READ(motorToIC(motor), TMC2209_COOLCONF, TMC2209_SEIMIN_MASK, TMC2209_SEIMIN_SHIFT);
|
||||
} else if(readWrite == WRITE) {
|
||||
TMC2209_FIELD_UPDATE(motorToIC(motor), TMC2209_COOLCONF, TMC2209_SEIMIN_MASK, TMC2209_SEIMIN_SHIFT, *value);
|
||||
}
|
||||
break;
|
||||
case 169:
|
||||
// smartEnergy current down step
|
||||
if(readWrite == READ) {
|
||||
*value = TMC2209_FIELD_READ(motorToIC(motor), TMC2209_COOLCONF, TMC2209_SEDN_MASK, TMC2209_SEDN_SHIFT);
|
||||
} else if(readWrite == WRITE) {
|
||||
TMC2209_FIELD_UPDATE(motorToIC(motor), TMC2209_COOLCONF, TMC2209_SEDN_MASK, TMC2209_SEDN_SHIFT, *value);
|
||||
}
|
||||
break;
|
||||
case 170:
|
||||
// smartEnergy hysteresis
|
||||
if(readWrite == READ) {
|
||||
*value = TMC2209_FIELD_READ(motorToIC(motor), TMC2209_COOLCONF, TMC2209_SEMAX_MASK, TMC2209_SEMAX_SHIFT);
|
||||
} else if(readWrite == WRITE) {
|
||||
TMC2209_FIELD_UPDATE(motorToIC(motor), TMC2209_COOLCONF, TMC2209_SEMAX_MASK, TMC2209_SEMAX_SHIFT, *value);
|
||||
}
|
||||
break;
|
||||
case 171:
|
||||
// smartEnergy current up step
|
||||
if(readWrite == READ) {
|
||||
*value = TMC2209_FIELD_READ(motorToIC(motor), TMC2209_COOLCONF, TMC2209_SEUP_MASK, TMC2209_SEUP_SHIFT);
|
||||
} else if(readWrite == WRITE) {
|
||||
TMC2209_FIELD_UPDATE(motorToIC(motor), TMC2209_COOLCONF, TMC2209_SEUP_MASK, TMC2209_SEUP_SHIFT, *value);
|
||||
}
|
||||
break;
|
||||
case 172:
|
||||
// smartEnergy hysteresis start
|
||||
if(readWrite == READ) {
|
||||
*value = TMC2209_FIELD_READ(motorToIC(motor), TMC2209_COOLCONF, TMC2209_SEMIN_MASK, TMC2209_SEMIN_SHIFT);
|
||||
} else if(readWrite == WRITE) {
|
||||
TMC2209_FIELD_UPDATE(motorToIC(motor), TMC2209_COOLCONF, TMC2209_SEMIN_MASK, TMC2209_SEMIN_SHIFT, *value);
|
||||
}
|
||||
break;
|
||||
case 174:
|
||||
// stallGuard2 threshold
|
||||
if(readWrite == READ) {
|
||||
*value = tmc2209_readInt(motorToIC(motor), TMC2209_SGTHRS);
|
||||
} else if(readWrite == WRITE) {
|
||||
tmc2209_writeInt(motorToIC(motor), TMC2209_SGTHRS, *value);
|
||||
}
|
||||
break;
|
||||
case 179:
|
||||
// VSense
|
||||
if(readWrite == READ) {
|
||||
*value = TMC2209_FIELD_READ(motorToIC(motor), TMC2209_CHOPCONF, TMC2209_VSENSE_MASK, TMC2209_VSENSE_SHIFT);
|
||||
} else if(readWrite == WRITE) {
|
||||
TMC2209_FIELD_UPDATE(motorToIC(motor), TMC2209_CHOPCONF, TMC2209_VSENSE_MASK, TMC2209_VSENSE_SHIFT, *value);
|
||||
}
|
||||
break;
|
||||
case 180:
|
||||
// smartEnergy actual current
|
||||
if(readWrite == READ) {
|
||||
*value = TMC2209_FIELD_READ(motorToIC(motor), TMC2209_DRVSTATUS, TMC2209_CS_ACTUAL_MASK, TMC2209_CS_ACTUAL_SHIFT);
|
||||
} else if(readWrite == WRITE) {
|
||||
errors |= TMC_ERROR_TYPE;
|
||||
}
|
||||
break;
|
||||
case 181:
|
||||
// smartEnergy stall velocity
|
||||
if(readWrite == READ) {
|
||||
*value = StepDir_getStallGuardThreshold(motor);
|
||||
} else if(readWrite == WRITE) {
|
||||
// Store the threshold value in the internal StepDir generator
|
||||
StepDir_setStallGuardThreshold(motor, *value);
|
||||
|
||||
// Convert the value for the TCOOLTHRS register
|
||||
// The IC only sends out Stallguard errors while TCOOLTHRS >= TSTEP >= TPWMTHRS
|
||||
// The TSTEP value is measured. To prevent measurement inaccuracies hiding
|
||||
// a stall signal, we decrease the needed velocity by roughly 12% before converting it.
|
||||
*value -= (*value) >> 3;
|
||||
if (*value)
|
||||
{
|
||||
*value = MIN(0x000FFFFF, (1<<24) / (*value));
|
||||
}
|
||||
else
|
||||
{
|
||||
*value = 0x000FFFFF;
|
||||
}
|
||||
tmc2209_writeInt(motorToIC(motor), TMC2209_TCOOLTHRS, *value);
|
||||
}
|
||||
break;
|
||||
case 182:
|
||||
// smartEnergy threshold speed
|
||||
if(readWrite == READ) {
|
||||
buffer = tmc2209_readInt(motorToIC(motor), TMC2209_TCOOLTHRS);
|
||||
*value = MIN(0xFFFFF, (1<<24) / ((buffer) ? buffer : 1));
|
||||
} else if(readWrite == WRITE) {
|
||||
*value = MIN(0xFFFFF, (1<<24) / ((*value) ? *value : 1));
|
||||
tmc2209_writeInt(motorToIC(motor), TMC2209_TCOOLTHRS, *value);
|
||||
}
|
||||
break;
|
||||
case 186:
|
||||
// PWM threshold speed
|
||||
if(readWrite == READ) {
|
||||
buffer = tmc2209_readInt(motorToIC(motor), TMC2209_TPWMTHRS);
|
||||
*value = MIN(0xFFFFF, (1<<24) / ((buffer) ? buffer : 1));
|
||||
} else if(readWrite == WRITE) {
|
||||
*value = MIN(0xFFFFF, (1<<24) / ((*value) ? *value : 1));
|
||||
tmc2209_writeInt(motorToIC(motor), TMC2209_TPWMTHRS, *value);
|
||||
}
|
||||
break;
|
||||
case 187:
|
||||
// PWM gradient
|
||||
if(readWrite == READ) {
|
||||
*value = TMC2209_FIELD_READ(motorToIC(motor), TMC2209_PWMCONF, TMC2209_PWM_GRAD_MASK, TMC2209_PWM_GRAD_SHIFT);
|
||||
} else if(readWrite == WRITE) {
|
||||
// Set gradient
|
||||
TMC2209_FIELD_UPDATE(motorToIC(motor), TMC2209_PWMCONF, TMC2209_PWM_GRAD_MASK, TMC2209_PWM_GRAD_SHIFT, *value);
|
||||
|
||||
// Enable/disable stealthChop accordingly
|
||||
TMC2209_FIELD_UPDATE(motorToIC(motor), TMC2209_GCONF, TMC2209_EN_SPREADCYCLE_MASK, TMC2209_EN_SPREADCYCLE_SHIFT, (*value > 0) ? 0 : 1);
|
||||
}
|
||||
break;
|
||||
case 191:
|
||||
// PWM frequency
|
||||
if(readWrite == READ) {
|
||||
*value = TMC2209_FIELD_READ(motorToIC(motor), TMC2209_PWMCONF, TMC2209_PWM_FREQ_MASK, TMC2209_PWM_FREQ_SHIFT);
|
||||
} else if(readWrite == WRITE) {
|
||||
if(*value >= 0 && *value < 4)
|
||||
{
|
||||
TMC2209_FIELD_UPDATE(motorToIC(motor), TMC2209_PWMCONF, TMC2209_PWM_FREQ_MASK, TMC2209_PWM_FREQ_SHIFT, *value);
|
||||
}
|
||||
else
|
||||
{
|
||||
errors |= TMC_ERROR_VALUE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 192:
|
||||
// PWM autoscale
|
||||
if(readWrite == READ) {
|
||||
*value = TMC2209_FIELD_READ(motorToIC(motor), TMC2209_PWMCONF, TMC2209_PWM_AUTOSCALE_MASK, TMC2209_PWM_AUTOSCALE_SHIFT);
|
||||
} else if(readWrite == WRITE) {
|
||||
TMC2209_FIELD_UPDATE(motorToIC(motor), TMC2209_PWMCONF, TMC2209_PWM_AUTOSCALE_MASK, TMC2209_PWM_AUTOSCALE_SHIFT, (*value)? 1:0);
|
||||
}
|
||||
break;
|
||||
case 204:
|
||||
// Freewheeling mode
|
||||
if(readWrite == READ) {
|
||||
*value = TMC2209_FIELD_READ(motorToIC(motor), TMC2209_PWMCONF, TMC2209_FREEWHEEL_MASK, TMC2209_FREEWHEEL_SHIFT);
|
||||
} else if(readWrite == WRITE) {
|
||||
TMC2209_FIELD_UPDATE(motorToIC(motor), TMC2209_PWMCONF, TMC2209_FREEWHEEL_MASK, TMC2209_FREEWHEEL_SHIFT, *value);
|
||||
}
|
||||
break;
|
||||
case 206:
|
||||
// Load value
|
||||
if(readWrite == READ) {
|
||||
*value = tmc2209_readInt(motorToIC(motor), TMC2209_SG_RESULT);
|
||||
} else if(readWrite == WRITE) {
|
||||
errors |= TMC_ERROR_TYPE;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
errors |= TMC_ERROR_TYPE;
|
||||
break;
|
||||
}
|
||||
|
||||
return errors;
|
||||
}
|
||||
|
||||
static uint32_t SAP(uint8_t type, uint8_t motor, int32_t value)
|
||||
{
|
||||
return handleParameter(WRITE, motor, type, &value);
|
||||
}
|
||||
|
||||
static uint32_t GAP(uint8_t type, uint8_t motor, int32_t *value)
|
||||
{
|
||||
return handleParameter(READ, motor, type, value);
|
||||
}
|
||||
|
||||
static void checkErrors(uint32_t tick)
|
||||
{
|
||||
UNUSED(tick);
|
||||
Evalboards.ch2.errors = 0;
|
||||
}
|
||||
|
||||
static uint32_t userFunction(uint8_t type, uint8_t motor, int32_t *value)
|
||||
{
|
||||
uint32_t errors = 0;
|
||||
uint8_t state;
|
||||
IOPinTypeDef *pin;
|
||||
|
||||
switch(type)
|
||||
{
|
||||
case 0: // Read StepDir status bits
|
||||
*value = StepDir_getStatus(motor);
|
||||
break;
|
||||
case 1:
|
||||
tmc2209_set_slave(motorToIC(motor), (*value) & 0xFF);
|
||||
break;
|
||||
case 2:
|
||||
*value = tmc2209_get_slave(motorToIC(motor));
|
||||
break;
|
||||
case 3:
|
||||
*value = Timer.getDuty(timerChannel) * 100 / TIMER_MAX;
|
||||
break;
|
||||
case 4:
|
||||
Timer.setDuty(timerChannel, ((float)*value) / 100);
|
||||
break;
|
||||
case 5: // Set pin state
|
||||
state = (*value) & 0x03;
|
||||
pin = Pins.ENN;
|
||||
switch(motor) {
|
||||
case 0:
|
||||
pin = Pins.ENN;
|
||||
break;
|
||||
case 1:
|
||||
pin = Pins.SPREAD;
|
||||
break;
|
||||
case 2:
|
||||
pin = Pins.MS1_AD0;
|
||||
break;
|
||||
case 3:
|
||||
pin = Pins.MS2_AD1;
|
||||
break;
|
||||
case 4:
|
||||
pin = Pins.UC_PWM;
|
||||
break;
|
||||
case 5:
|
||||
pin = Pins.STDBY;
|
||||
break;
|
||||
}
|
||||
HAL.IOs->config->setToState(pin, state);
|
||||
break;
|
||||
case 6: // Get pin state
|
||||
pin = Pins.ENN;
|
||||
switch(motor) {
|
||||
case 0:
|
||||
pin = Pins.ENN;
|
||||
break;
|
||||
case 1:
|
||||
pin = Pins.SPREAD;
|
||||
break;
|
||||
case 2:
|
||||
pin = Pins.MS1_AD0;
|
||||
break;
|
||||
case 3:
|
||||
pin = Pins.MS2_AD1;
|
||||
break;
|
||||
case 4:
|
||||
pin = Pins.UC_PWM;
|
||||
break;
|
||||
case 5:
|
||||
pin = Pins.STDBY;
|
||||
break;
|
||||
}
|
||||
*value = (uint32_t) HAL.IOs->config->getState(pin);
|
||||
break;
|
||||
default:
|
||||
errors |= TMC_ERROR_TYPE;
|
||||
break;
|
||||
}
|
||||
|
||||
return errors;
|
||||
}
|
||||
|
||||
static void deInit(void)
|
||||
{
|
||||
enableDriver(DRIVER_DISABLE);
|
||||
HAL.IOs->config->reset(Pins.ENN);
|
||||
HAL.IOs->config->reset(Pins.SPREAD);
|
||||
HAL.IOs->config->reset(Pins.STEP);
|
||||
HAL.IOs->config->reset(Pins.DIR);
|
||||
HAL.IOs->config->reset(Pins.MS1_AD0);
|
||||
HAL.IOs->config->reset(Pins.MS2_AD1);
|
||||
HAL.IOs->config->reset(Pins.DIAG);
|
||||
HAL.IOs->config->reset(Pins.INDEX);
|
||||
HAL.IOs->config->reset(Pins.STDBY);
|
||||
HAL.IOs->config->reset(Pins.UC_PWM);
|
||||
|
||||
StepDir_deInit();
|
||||
Timer.deInit();
|
||||
}
|
||||
|
||||
static uint8_t reset()
|
||||
{
|
||||
StepDir_init(STEPDIR_PRECISION);
|
||||
StepDir_setPins(0, Pins.STEP, Pins.DIR, Pins.DIAG);
|
||||
|
||||
return tmc2209_reset(&TMC2209);
|
||||
}
|
||||
|
||||
static uint8_t restore()
|
||||
{
|
||||
return tmc2209_restore(&TMC2209);
|
||||
}
|
||||
|
||||
static void enableDriver(DriverState state)
|
||||
{
|
||||
if(state == DRIVER_USE_GLOBAL_ENABLE)
|
||||
state = Evalboards.driverEnable;
|
||||
|
||||
if(state == DRIVER_DISABLE)
|
||||
HAL.IOs->config->setHigh(Pins.ENN);
|
||||
else if((state == DRIVER_ENABLE) && (Evalboards.driverEnable == DRIVER_ENABLE))
|
||||
HAL.IOs->config->setLow(Pins.ENN);
|
||||
}
|
||||
|
||||
static void periodicJob(uint32_t tick)
|
||||
{
|
||||
tmc2209_periodicJob(&TMC2209, tick);
|
||||
StepDir_periodicJob(0);
|
||||
}
|
||||
|
||||
void TMC2209_init(void)
|
||||
{
|
||||
|
||||
#if defined(Landungsbruecke) || defined(LandungsbrueckeSmall)
|
||||
timerChannel = TIMER_CHANNEL_3;
|
||||
|
||||
#elif defined(LandungsbrueckeV3)
|
||||
timerChannel = TIMER_CHANNEL_4;
|
||||
#endif
|
||||
tmc_fillCRC8Table(0x07, true, 1);
|
||||
thigh = 0;
|
||||
|
||||
Pins.ENN = &HAL.IOs->pins->DIO0;
|
||||
Pins.SPREAD = &HAL.IOs->pins->DIO8;
|
||||
Pins.STEP = &HAL.IOs->pins->DIO6;
|
||||
Pins.DIR = &HAL.IOs->pins->DIO7;
|
||||
Pins.MS1_AD0 = &HAL.IOs->pins->DIO3;
|
||||
Pins.MS2_AD1 = &HAL.IOs->pins->DIO4;
|
||||
Pins.DIAG = &HAL.IOs->pins->DIO1;
|
||||
Pins.INDEX = &HAL.IOs->pins->DIO2;
|
||||
Pins.UC_PWM = &HAL.IOs->pins->DIO9;
|
||||
Pins.STDBY = &HAL.IOs->pins->DIO0;
|
||||
|
||||
HAL.IOs->config->toOutput(Pins.ENN);
|
||||
HAL.IOs->config->toOutput(Pins.SPREAD);
|
||||
HAL.IOs->config->toOutput(Pins.STEP);
|
||||
HAL.IOs->config->toOutput(Pins.DIR);
|
||||
HAL.IOs->config->toOutput(Pins.MS1_AD0);
|
||||
HAL.IOs->config->toOutput(Pins.MS2_AD1);
|
||||
HAL.IOs->config->toInput(Pins.DIAG);
|
||||
HAL.IOs->config->toInput(Pins.INDEX);
|
||||
|
||||
HAL.IOs->config->setLow(Pins.MS1_AD0);
|
||||
HAL.IOs->config->setLow(Pins.MS2_AD1);
|
||||
|
||||
TMC2209_UARTChannel = HAL.UART;
|
||||
TMC2209_UARTChannel->pinout = UART_PINS_2;
|
||||
TMC2209_UARTChannel->rxtx.init();
|
||||
|
||||
TMC2209_config = Evalboards.ch2.config;
|
||||
|
||||
Evalboards.ch2.config->reset = reset;
|
||||
Evalboards.ch2.config->restore = restore;
|
||||
|
||||
Evalboards.ch2.rotate = rotate;
|
||||
Evalboards.ch2.right = right;
|
||||
Evalboards.ch2.left = left;
|
||||
Evalboards.ch2.stop = stop;
|
||||
Evalboards.ch2.GAP = GAP;
|
||||
Evalboards.ch2.SAP = SAP;
|
||||
Evalboards.ch2.moveTo = moveTo;
|
||||
Evalboards.ch2.moveBy = moveBy;
|
||||
Evalboards.ch2.writeRegister = tmc2209_writeRegister;
|
||||
Evalboards.ch2.readRegister = tmc2209_readRegister;
|
||||
Evalboards.ch2.userFunction = userFunction;
|
||||
Evalboards.ch2.enableDriver = enableDriver;
|
||||
Evalboards.ch2.checkErrors = checkErrors;
|
||||
Evalboards.ch2.numberOfMotors = MOTORS;
|
||||
Evalboards.ch2.VMMin = VM_MIN;
|
||||
Evalboards.ch2.VMMax = VM_MAX;
|
||||
Evalboards.ch2.deInit = deInit;
|
||||
Evalboards.ch2.periodicJob = periodicJob;
|
||||
|
||||
tmc2209_init(&TMC2209, 0, 0, TMC2209_config, &tmc2209_defaultRegisterResetState[0]);
|
||||
|
||||
StepDir_init(STEPDIR_PRECISION);
|
||||
StepDir_setPins(0, Pins.STEP, Pins.DIR, Pins.DIAG);
|
||||
StepDir_setVelocityMax(0, 51200);
|
||||
StepDir_setAcceleration(0, 51200);
|
||||
|
||||
HAL.IOs->config->toOutput(Pins.UC_PWM);
|
||||
|
||||
#if defined(Landungsbruecke) || defined(LandungsbrueckeSmall)
|
||||
Pins.UC_PWM->configuration.GPIO_Mode = GPIO_Mode_AF4;
|
||||
#elif defined(LandungsbrueckeV3)
|
||||
Pins.UC_PWM->configuration.GPIO_Mode = GPIO_MODE_AF;
|
||||
gpio_af_set(Pins.UC_PWM->port, GPIO_AF_1, Pins.UC_PWM->bitWeight);
|
||||
|
||||
#endif
|
||||
|
||||
vref = 2000;
|
||||
HAL.IOs->config->set(Pins.UC_PWM);
|
||||
Timer.init();
|
||||
Timer.setDuty(timerChannel, ((float)vref) / VREF_FULLSCALE);
|
||||
|
||||
enableDriver(DRIVER_ENABLE);
|
||||
};
|
||||
41
Clean_TMC2209/lib/tmc/boards/TMCDriver.c
Normal file
41
Clean_TMC2209/lib/tmc/boards/TMCDriver.c
Normal file
@@ -0,0 +1,41 @@
|
||||
/*******************************************************************************
|
||||
* Copyright © 2019 TRINAMIC Motion Control GmbH & Co. KG
|
||||
* (now owned by Analog Devices Inc.),
|
||||
*
|
||||
* Copyright © 2023 Analog Devices Inc. All Rights Reserved. This software is
|
||||
* proprietary & confidential to Analog Devices, Inc. and its licensors.
|
||||
*******************************************************************************/
|
||||
|
||||
|
||||
#include "TMCDriver.h"
|
||||
|
||||
EvalBoardDriverTypeDef TMCDriver =
|
||||
{
|
||||
.config =
|
||||
{
|
||||
.state = CONFIG_READY,
|
||||
.configIndex = 0,
|
||||
.shadowRegister = { 0 }
|
||||
}
|
||||
};
|
||||
|
||||
void tmcdriver_init()
|
||||
{
|
||||
Evalboards.ch2.config = &TMCDriver.config;
|
||||
Evalboards.ch2.config->state = CONFIG_READY;
|
||||
Evalboards.ch2.config->configIndex = 0;
|
||||
|
||||
// A value of 0 indicates the Evalboard not connecting the VM line,
|
||||
// resulting in skipped global minimum voltage checks.
|
||||
// A negative value indicates no board being connected, which skips the
|
||||
// minimum voltage check for that channel
|
||||
Evalboards.ch2.VMMin = -1;
|
||||
Evalboards.ch2.VMMax = s32_MAX;
|
||||
|
||||
Evalboards.ch2.numberOfMotors = 0;
|
||||
Evalboards.ch2.errors = 0;
|
||||
|
||||
Evalboards.ch2.config->channel = CHANNEL_2;
|
||||
|
||||
board_setDummyFunctions(&Evalboards.ch2);
|
||||
}
|
||||
24
Clean_TMC2209/lib/tmc/boards/TMCDriver.h
Normal file
24
Clean_TMC2209/lib/tmc/boards/TMCDriver.h
Normal file
@@ -0,0 +1,24 @@
|
||||
/*******************************************************************************
|
||||
* Copyright © 2019 TRINAMIC Motion Control GmbH & Co. KG
|
||||
* (now owned by Analog Devices Inc.),
|
||||
*
|
||||
* Copyright © 2023 Analog Devices Inc. All Rights Reserved. This software is
|
||||
* proprietary & confidential to Analog Devices, Inc. and its licensors.
|
||||
*******************************************************************************/
|
||||
|
||||
|
||||
#ifndef TMCDRIVER_H_
|
||||
#define TMCDRIVER_H_
|
||||
|
||||
#include "Board.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ConfigurationTypeDef config;
|
||||
} EvalBoardDriverTypeDef;
|
||||
|
||||
extern EvalBoardDriverTypeDef TMCDriver;
|
||||
|
||||
void tmcdriver_init();
|
||||
|
||||
#endif /* TMCDRIVER_H_ */
|
||||
41
Clean_TMC2209/lib/tmc/boards/TMCMotionController.c
Normal file
41
Clean_TMC2209/lib/tmc/boards/TMCMotionController.c
Normal file
@@ -0,0 +1,41 @@
|
||||
/*******************************************************************************
|
||||
* Copyright © 2019 TRINAMIC Motion Control GmbH & Co. KG
|
||||
* (now owned by Analog Devices Inc.),
|
||||
*
|
||||
* Copyright © 2023 Analog Devices Inc. All Rights Reserved. This software is
|
||||
* proprietary & confidential to Analog Devices, Inc. and its licensors.
|
||||
*******************************************************************************/
|
||||
|
||||
|
||||
#include "TMCMotionController.h"
|
||||
|
||||
EvalBoardMotionControllerTypeDef TMCMotionController =
|
||||
{
|
||||
.config =
|
||||
{
|
||||
.state = CONFIG_READY,
|
||||
.configIndex = 0,
|
||||
.shadowRegister = { 0 }
|
||||
}
|
||||
};
|
||||
|
||||
void tmcmotioncontroller_init()
|
||||
{
|
||||
Evalboards.ch1.config = &TMCMotionController.config;
|
||||
Evalboards.ch1.config->state = CONFIG_READY;
|
||||
Evalboards.ch1.config->configIndex = 0;
|
||||
|
||||
// A value of 0 indicates the Evalboard not connecting the VM line,
|
||||
// resulting in skipped global minimum voltage checks.
|
||||
// A negative value indicates no board being connected, which skips the
|
||||
// minimum voltage check for that channel
|
||||
Evalboards.ch1.VMMin = -1;
|
||||
Evalboards.ch1.VMMax = s32_MAX;
|
||||
|
||||
Evalboards.ch1.numberOfMotors = 0;
|
||||
Evalboards.ch1.errors = 0;
|
||||
|
||||
Evalboards.ch1.config->channel = CHANNEL_1;
|
||||
|
||||
board_setDummyFunctions(&Evalboards.ch1);
|
||||
}
|
||||
24
Clean_TMC2209/lib/tmc/boards/TMCMotionController.h
Normal file
24
Clean_TMC2209/lib/tmc/boards/TMCMotionController.h
Normal file
@@ -0,0 +1,24 @@
|
||||
/*******************************************************************************
|
||||
* Copyright © 2019 TRINAMIC Motion Control GmbH & Co. KG
|
||||
* (now owned by Analog Devices Inc.),
|
||||
*
|
||||
* Copyright © 2023 Analog Devices Inc. All Rights Reserved. This software is
|
||||
* proprietary & confidential to Analog Devices, Inc. and its licensors.
|
||||
*******************************************************************************/
|
||||
|
||||
|
||||
#ifndef TMCMOTIONCONTROLLER_H_
|
||||
#define TMCMOTIONCONTROLLER_H_
|
||||
|
||||
#include "Board.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ConfigurationTypeDef config;
|
||||
} EvalBoardMotionControllerTypeDef;
|
||||
|
||||
extern EvalBoardMotionControllerTypeDef TMCMotionController;
|
||||
|
||||
void tmcmotioncontroller_init();
|
||||
|
||||
#endif /* TMCMOTIONCONTROLLER_H_ */
|
||||
34
Clean_TMC2209/lib/tmc/hal/ADCs.h
Normal file
34
Clean_TMC2209/lib/tmc/hal/ADCs.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/*******************************************************************************
|
||||
* Copyright © 2019 TRINAMIC Motion Control GmbH & Co. KG
|
||||
* (now owned by Analog Devices Inc.),
|
||||
*
|
||||
* Copyright © 2023 Analog Devices Inc. All Rights Reserved. This software is
|
||||
* proprietary & confidential to Analog Devices, Inc. and its licensors.
|
||||
*******************************************************************************/
|
||||
|
||||
|
||||
#ifndef ADC_H
|
||||
#define ADC_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define N_O_ADC_CHANNELS 7
|
||||
|
||||
static volatile uint16_t ADCValue[N_O_ADC_CHANNELS];
|
||||
|
||||
typedef struct
|
||||
{
|
||||
volatile uint16_t *AIN0;
|
||||
volatile uint16_t *AIN1;
|
||||
volatile uint16_t *AIN2;
|
||||
volatile uint16_t *DIO4;
|
||||
volatile uint16_t *DIO5;
|
||||
volatile uint16_t *VM;
|
||||
volatile uint16_t *AIN_EXT; // Only LB_V3
|
||||
void (*init)();
|
||||
void (*deInit)();
|
||||
} ADCTypeDef;
|
||||
|
||||
extern ADCTypeDef ADCs;
|
||||
|
||||
#endif /* ADC_H */
|
||||
52
Clean_TMC2209/lib/tmc/hal/HAL.h
Normal file
52
Clean_TMC2209/lib/tmc/hal/HAL.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/*******************************************************************************
|
||||
* Copyright © 2019 TRINAMIC Motion Control GmbH & Co. KG
|
||||
* (now owned by Analog Devices Inc.),
|
||||
*
|
||||
* Copyright © 2023 Analog Devices Inc. All Rights Reserved. This software is
|
||||
* proprietary & confidential to Analog Devices, Inc. and its licensors.
|
||||
*******************************************************************************/
|
||||
|
||||
|
||||
#ifndef _HAL_H_
|
||||
#define _HAL_H_
|
||||
|
||||
#include "derivative.h"
|
||||
#include "IOs.h"
|
||||
#include "IOMap.h"
|
||||
#include "SPI.h"
|
||||
#include "ADCs.h"
|
||||
#include "USB.h"
|
||||
#include "LEDs.h"
|
||||
#include "RS232.h"
|
||||
#include "WLAN.h"
|
||||
#include "Timer.h"
|
||||
#include "SysTick.h"
|
||||
#include "UART.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
IOsTypeDef *config;
|
||||
IOPinMapTypeDef *pins;
|
||||
} IOsFunctionsTypeDef;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
void (*init) (void);
|
||||
void (*reset) (uint8_t ResetPeripherals);
|
||||
void (*NVIC_DeInit)(void);
|
||||
const IOsFunctionsTypeDef *IOs;
|
||||
SPITypeDef *SPI;
|
||||
RXTXTypeDef *USB;
|
||||
LEDsTypeDef *LEDs;
|
||||
ADCTypeDef *ADCs;
|
||||
RXTXTypeDef *RS232;
|
||||
RXTXTypeDef *WLAN;
|
||||
TimerTypeDef *Timer;
|
||||
UART_Config *UART;
|
||||
} HALTypeDef;
|
||||
|
||||
extern const HALTypeDef HAL;
|
||||
|
||||
extern uint8_t hwid;
|
||||
|
||||
#endif /* _HAL_H_ */
|
||||
124
Clean_TMC2209/lib/tmc/hal/IOMap.h
Normal file
124
Clean_TMC2209/lib/tmc/hal/IOMap.h
Normal file
@@ -0,0 +1,124 @@
|
||||
/*******************************************************************************
|
||||
* Copyright © 2019 TRINAMIC Motion Control GmbH & Co. KG
|
||||
* (now owned by Analog Devices Inc.),
|
||||
*
|
||||
* Copyright © 2023 Analog Devices Inc. All Rights Reserved. This software is
|
||||
* proprietary & confidential to Analog Devices, Inc. and its licensors.
|
||||
*******************************************************************************/
|
||||
|
||||
|
||||
#ifndef _IO_PIN_MAP_H_
|
||||
#define _IO_PIN_MAP_H_
|
||||
|
||||
#include "IOs.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
void (*init) (void);
|
||||
|
||||
IOPinTypeDef **pins; // Map Pin ID <=> Pin
|
||||
|
||||
IOPinTypeDef ID_CLK;
|
||||
IOPinTypeDef ID_CH0;
|
||||
IOPinTypeDef ID_CH1;
|
||||
|
||||
IOPinTypeDef DIO0;
|
||||
IOPinTypeDef DIO1;
|
||||
IOPinTypeDef DIO2;
|
||||
IOPinTypeDef DIO3;
|
||||
IOPinTypeDef DIO4;
|
||||
IOPinTypeDef DIO5;
|
||||
IOPinTypeDef DIO6;
|
||||
IOPinTypeDef DIO7;
|
||||
IOPinTypeDef DIO8;
|
||||
IOPinTypeDef DIO9;
|
||||
IOPinTypeDef DIO10;
|
||||
IOPinTypeDef DIO11;
|
||||
IOPinTypeDef CLK16;
|
||||
IOPinTypeDef SPI2_CSN0;
|
||||
IOPinTypeDef SPI2_CSN1;
|
||||
IOPinTypeDef SPI2_CSN2;
|
||||
IOPinTypeDef SPI2_SCK;
|
||||
IOPinTypeDef SPI2_SDO;
|
||||
IOPinTypeDef SPI2_SDI;
|
||||
|
||||
IOPinTypeDef SPI1_CSN;
|
||||
IOPinTypeDef SPI1_SCK;
|
||||
IOPinTypeDef SPI1_SDI;
|
||||
IOPinTypeDef SPI1_SDO;
|
||||
|
||||
IOPinTypeDef DIO12;
|
||||
IOPinTypeDef DIO13;
|
||||
IOPinTypeDef DIO14;
|
||||
IOPinTypeDef DIO15;
|
||||
IOPinTypeDef DIO16;
|
||||
IOPinTypeDef DIO17;
|
||||
IOPinTypeDef DIO18;
|
||||
IOPinTypeDef DIO19;
|
||||
|
||||
IOPinTypeDef RS232_TX;
|
||||
IOPinTypeDef RS232_RX;
|
||||
|
||||
IOPinTypeDef USB_V_BUS;
|
||||
IOPinTypeDef USB_V_DM;
|
||||
IOPinTypeDef USB_V_DP;
|
||||
|
||||
IOPinTypeDef LED_STAT;
|
||||
IOPinTypeDef LED_ERROR;
|
||||
|
||||
IOPinTypeDef EEPROM_SCK;
|
||||
IOPinTypeDef EEPROM_SI;
|
||||
IOPinTypeDef EEPROM_SO;
|
||||
IOPinTypeDef EEPROM_NCS;
|
||||
|
||||
#if defined(Landungsbruecke) || defined(LandungsbrueckeSmall)
|
||||
IOPinTypeDef WIRELESS_TX;
|
||||
IOPinTypeDef WIRELESS_RX;
|
||||
IOPinTypeDef WIRELESS_NRST;
|
||||
IOPinTypeDef MIXED0;
|
||||
IOPinTypeDef MIXED1;
|
||||
IOPinTypeDef MIXED2;
|
||||
IOPinTypeDef MIXED3;
|
||||
IOPinTypeDef MIXED4;
|
||||
IOPinTypeDef MIXED5;
|
||||
IOPinTypeDef MIXED6;
|
||||
IOPinTypeDef ID_HW_0;
|
||||
IOPinTypeDef ID_HW_1;
|
||||
IOPinTypeDef ID_HW_2;
|
||||
IOPinTypeDef EXTIO_2;
|
||||
IOPinTypeDef EXTIO_3;
|
||||
IOPinTypeDef EXTIO_4;
|
||||
IOPinTypeDef EXTIO_5;
|
||||
IOPinTypeDef EXTIO_6;
|
||||
IOPinTypeDef EXTIO_7;
|
||||
#endif
|
||||
|
||||
#if defined(LandungsbrueckeV3)
|
||||
IOPinTypeDef DIO10_PWM_WL;
|
||||
IOPinTypeDef DIO10_UART_TX;
|
||||
IOPinTypeDef DIO11_PWM_WH;
|
||||
IOPinTypeDef DIO11_UART_RX;
|
||||
IOPinTypeDef SW_UART_PWM;
|
||||
IOPinTypeDef EXT0;
|
||||
IOPinTypeDef EXT1;
|
||||
IOPinTypeDef EXT2;
|
||||
IOPinTypeDef EXT3;
|
||||
IOPinTypeDef EXT4;
|
||||
IOPinTypeDef ADC_VM;
|
||||
IOPinTypeDef AIN0;
|
||||
IOPinTypeDef AIN1;
|
||||
IOPinTypeDef AIN2;
|
||||
IOPinTypeDef AIN_EXT;
|
||||
IOPinTypeDef WIFI_EN;
|
||||
IOPinTypeDef WIFI_RST;
|
||||
IOPinTypeDef WIFI_TX;
|
||||
IOPinTypeDef WIFI_RX;
|
||||
IOPinTypeDef BUTTON;
|
||||
#endif
|
||||
|
||||
IOPinTypeDef DUMMY;
|
||||
} IOPinMapTypeDef;
|
||||
|
||||
extern IOPinMapTypeDef IOMap;
|
||||
|
||||
#endif /* _IO_PIN_MAP_H_ */
|
||||
164
Clean_TMC2209/lib/tmc/hal/IOs.h
Normal file
164
Clean_TMC2209/lib/tmc/hal/IOs.h
Normal file
@@ -0,0 +1,164 @@
|
||||
/*******************************************************************************
|
||||
* Copyright © 2019 TRINAMIC Motion Control GmbH & Co. KG
|
||||
* (now owned by Analog Devices Inc.),
|
||||
*
|
||||
* Copyright © 2023 Analog Devices Inc. All Rights Reserved. This software is
|
||||
* proprietary & confidential to Analog Devices, Inc. and its licensors.
|
||||
*******************************************************************************/
|
||||
|
||||
|
||||
#ifndef _IO_H_
|
||||
#define _IO_H_
|
||||
|
||||
// #include "derivative.h"
|
||||
|
||||
typedef enum { // Give bits explicitly, because IDE relies on it.
|
||||
IOS_LOW = 0b00,
|
||||
IOS_HIGH = 0b01,
|
||||
IOS_OPEN = 0b10,
|
||||
IOS_NOCHANGE = 0b11
|
||||
} IO_States;
|
||||
|
||||
#if defined(Landungsbruecke) || defined(LandungsbrueckeSmall)
|
||||
// use ST like configuration structures also for Landungsbruecke
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GPIO_Mode_AN = 0x00, /*!< GPIO Analog Mode, Pin disabled */
|
||||
GPIO_Mode_AF1 = 0x01, /*!< GPIO Alternate function Mode GPIO*/
|
||||
GPIO_Mode_AF2 = 0x02, /*!< GPIO Alternate function Mode*/
|
||||
GPIO_Mode_AF3 = 0x03, /*!< GPIO Alternate function Mode*/
|
||||
GPIO_Mode_AF4 = 0x04, /*!< GPIO Alternate function Mode*/
|
||||
GPIO_Mode_AF5 = 0x05, /*!< GPIO Alternate function Mode*/
|
||||
GPIO_Mode_AF6 = 0x06, /*!< GPIO Alternate function Mode*/
|
||||
GPIO_Mode_AF7 = 0x07, /*!< GPIO Alternate function Mode*/
|
||||
GPIO_Mode_IN = 0x08, /*!< GPIO Input Mode */
|
||||
GPIO_Mode_OUT = 0x09 /*!< GPIO Output Mode */
|
||||
} GPIOMode_TypeDef;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GPIO_OType_PP = 0x00,
|
||||
GPIO_OType_OD = 0x01
|
||||
} GPIOOType_TypeDef;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GPIO_PuPd_NOPULL = 0x00,
|
||||
GPIO_PuPd_UP = 0x01,
|
||||
GPIO_PuPd_DOWN = 0x02
|
||||
} GPIOPuPd_TypeDef;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GPIO_Speed_2MHz = 0x00, /*!< Low speed */
|
||||
GPIO_Speed_25MHz = 0x01, /*!< Medium speed */
|
||||
GPIO_Speed_50MHz = 0x02, /*!< Fast speed */
|
||||
GPIO_Speed_100MHz = 0x03 /*!< High speed on 30 pF (80 MHz Output max speed on 15 pF) */
|
||||
} GPIOSpeed_TypeDef;
|
||||
|
||||
#include "hal/Landungsbruecke/freescale/PDD/GPIO_PDD.h"
|
||||
#elif defined(LandungsbrueckeV3)
|
||||
// typedef enum
|
||||
// {
|
||||
// GPIO_MODE_INPUT = 0x00, /*!< GPIO Input Mode */
|
||||
// GPIO_MODE_OUTPUT = 0x01, /*!< GPIO Output Mode */
|
||||
// GPIO_MODE_AF = 0x02, /*!< GPIO Alternate function Mode*/
|
||||
// GPIO_MODE_ANALOG = 0x03, /*!< GPIO Analog Mode*/
|
||||
// } GPIOMode_TypeDef;
|
||||
//
|
||||
// typedef enum
|
||||
// {
|
||||
// GPIO_OTYPE_PP = 0x00,
|
||||
// GPIO_OTYPE_OD = 0x01
|
||||
// } GPIOOType_TypeDef;
|
||||
//
|
||||
// typedef enum
|
||||
// {
|
||||
// GPIO_PUPD_NONE = 0x00,
|
||||
// GPIO_PUPD_PULLUP = 0x01,
|
||||
// GPIO_PUPD_PULLDOWN = 0x02
|
||||
// } GPIOPuPd_TypeDef;
|
||||
//
|
||||
// typedef enum
|
||||
// {
|
||||
// GPIO_OSPEED_2MHZ = 0x00, /*!< Low speed */
|
||||
// GPIO_OSPEED_25MHZ = 0x01, /*!< Medium speed */
|
||||
// GPIO_OSPEED_50MHZ = 0x02, /*!< Fast speed */
|
||||
// GPIO_OSPEED_MAX = 0x03 /*!< GPIO very high output speed, max speed more than 50MHz */
|
||||
// } GPIOSpeed_TypeDef;
|
||||
typedef uint32_t GPIOMode_TypeDef;
|
||||
typedef uint32_t GPIOOType_TypeDef;
|
||||
typedef uint32_t GPIOPuPd_TypeDef;
|
||||
typedef uint32_t GPIOSpeed_TypeDef;
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
enum IOsHighLevelFunctions { IO_DEFAULT, IO_DI, IO_AI, IO_DO, IO_PWM, IO_SD, IO_CLK16, IO_SPI };
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const uint8_t DEFAULT;
|
||||
const uint8_t DI;
|
||||
const uint8_t AI;
|
||||
const uint8_t DO;
|
||||
const uint8_t PWM;
|
||||
const uint8_t SD;
|
||||
const uint8_t CLK16;
|
||||
const uint8_t SPI;
|
||||
} IOsHighLevelFunctionTypeDef;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GPIOMode_TypeDef GPIO_Mode;
|
||||
GPIOSpeed_TypeDef GPIO_Speed;
|
||||
GPIOOType_TypeDef GPIO_OType;
|
||||
GPIOPuPd_TypeDef GPIO_PuPd;
|
||||
} IOPinInitTypeDef;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
#if defined(LandungsbrueckeV3)
|
||||
uint32_t port;
|
||||
volatile uint32_t *setBitRegister;
|
||||
volatile uint32_t *resetBitRegister;
|
||||
#elif defined(Landungsbruecke) || defined(LandungsbrueckeSmall)
|
||||
PORT_MemMapPtr portBase;
|
||||
GPIO_MemMapPtr GPIOBase;
|
||||
volatile uint32_t *setBitRegister;
|
||||
volatile uint32_t *resetBitRegister;
|
||||
#endif
|
||||
uint32_t bitWeight;
|
||||
unsigned char bit;
|
||||
IOPinInitTypeDef configuration;
|
||||
IOPinInitTypeDef resetConfiguration;
|
||||
enum IOsHighLevelFunctions highLevelFunction;
|
||||
IO_States state;
|
||||
} IOPinTypeDef;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
void (*set)(IOPinTypeDef *pin);
|
||||
void (*copy)(IOPinInitTypeDef *from, IOPinTypeDef*to);
|
||||
void (*reset)(IOPinTypeDef *pin);
|
||||
void (*toOutput)(IOPinTypeDef *pin);
|
||||
void (*toInput)(IOPinTypeDef *pin);
|
||||
|
||||
void (*setHigh)(IOPinTypeDef *pin);
|
||||
void (*setLow)(IOPinTypeDef *pin);
|
||||
void (*setToState)(IOPinTypeDef *pin, IO_States state);
|
||||
IO_States (*getState)(IOPinTypeDef *pin);
|
||||
unsigned char (*isHigh)(IOPinTypeDef *pin);
|
||||
void (*init)(void);
|
||||
IOsHighLevelFunctionTypeDef HIGH_LEVEL_FUNCTIONS;
|
||||
} IOsTypeDef;
|
||||
|
||||
extern IOsTypeDef IOs;
|
||||
|
||||
// A bit weight of 0 is used to indicate a nonexistent pin
|
||||
#define DUMMY_BITWEIGHT 0
|
||||
#define IS_DUMMY_PIN(pin) (pin->bitWeight == DUMMY_BITWEIGHT)
|
||||
|
||||
#endif /* _IO_H_ */
|
||||
49
Clean_TMC2209/lib/tmc/hal/LEDs.h
Normal file
49
Clean_TMC2209/lib/tmc/hal/LEDs.h
Normal file
@@ -0,0 +1,49 @@
|
||||
/*******************************************************************************
|
||||
* Copyright © 2019 TRINAMIC Motion Control GmbH & Co. KG
|
||||
* (now owned by Analog Devices Inc.),
|
||||
*
|
||||
* Copyright © 2023 Analog Devices Inc. All Rights Reserved. This software is
|
||||
* proprietary & confidential to Analog Devices, Inc. and its licensors.
|
||||
*******************************************************************************/
|
||||
|
||||
|
||||
#ifndef LEDS_H_
|
||||
#define LEDS_H_
|
||||
|
||||
#if defined(Landungsbruecke) || defined(LandungsbrueckeSmall)
|
||||
#define LED_ON() *HAL.IOs->pins->LED_STAT.resetBitRegister = HAL.IOs->pins->LED_STAT.bitWeight
|
||||
#define LED_OFF() *HAL.IOs->pins->LED_STAT.setBitRegister = HAL.IOs->pins->LED_STAT.bitWeight
|
||||
#define LED_TOGGLE() HAL.IOs->pins->LED_STAT.GPIOBase->PTOR ^= GPIO_PTOR_PTTO(HAL.IOs->pins->LED_STAT.bitWeight)
|
||||
|
||||
#define LED_ERROR_ON() *HAL.IOs->pins->LED_ERROR.resetBitRegister = HAL.IOs->pins->LED_ERROR.bitWeight
|
||||
#define LED_ERROR_OFF() *HAL.IOs->pins->LED_ERROR.setBitRegister = HAL.IOs->pins->LED_ERROR.bitWeight
|
||||
#define LED_ERROR_TOGGLE() HAL.IOs->pins->LED_ERROR.GPIOBase->PTOR ^= GPIO_PTOR_PTTO(HAL.IOs->pins->LED_ERROR.bitWeight)
|
||||
#elif defined(LandungsbrueckeV3)
|
||||
#define LED_ON() *HAL.IOs->pins->LED_STAT.resetBitRegister = HAL.IOs->pins->LED_STAT.bitWeight
|
||||
#define LED_OFF() *HAL.IOs->pins->LED_STAT.setBitRegister = HAL.IOs->pins->LED_STAT.bitWeight
|
||||
#define LED_TOGGLE() GPIO_TG(HAL.IOs->pins->LED_STAT.port) = HAL.IOs->pins->LED_STAT.bitWeight
|
||||
|
||||
#define LED_ERROR_ON() *HAL.IOs->pins->LED_ERROR.resetBitRegister = HAL.IOs->pins->LED_ERROR.bitWeight
|
||||
#define LED_ERROR_OFF() *HAL.IOs->pins->LED_ERROR.setBitRegister = HAL.IOs->pins->LED_ERROR.bitWeight
|
||||
#define LED_ERROR_TOGGLE() GPIO_TG(HAL.IOs->pins->LED_ERROR.port) = HAL.IOs->pins->LED_ERROR.bitWeight
|
||||
#endif
|
||||
|
||||
#include "IOs.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
void (*on)(void);
|
||||
void (*off)(void);
|
||||
void (*toggle)(void);
|
||||
} LEDTypeDef;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
void (*init)(void);
|
||||
LEDTypeDef stat;
|
||||
LEDTypeDef error;
|
||||
} LEDsTypeDef;
|
||||
|
||||
extern LEDsTypeDef LEDs;
|
||||
|
||||
#endif /* LEDS_H_ */
|
||||
295
Clean_TMC2209/lib/tmc/hal/Landungsbruecke/freescale/Cpu.c
Normal file
295
Clean_TMC2209/lib/tmc/hal/Landungsbruecke/freescale/Cpu.c
Normal file
@@ -0,0 +1,295 @@
|
||||
/* ###################################################################
|
||||
** THIS COMPONENT MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.
|
||||
** Filename : Cpu.c
|
||||
** Project : FS_TC_Test
|
||||
** Processor : MK20DN512VLL10
|
||||
** Component : MK20DN512LL10
|
||||
** Version : Component 01.000, Driver 01.04, CPU db: 3.00.000
|
||||
** Datasheet : K20P144M100SF2V2RM Rev. 2, Jun 2012
|
||||
** Compiler : GNU C Compiler
|
||||
** Date/Time : 2014-12-22, 13:39, # CodeGen: 7
|
||||
** Abstract :
|
||||
**
|
||||
** Settings :
|
||||
**
|
||||
** Contents :
|
||||
** No public methods
|
||||
**
|
||||
** Copyright : 1997 - 2014 Freescale Semiconductor, Inc.
|
||||
** All Rights Reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without modification,
|
||||
** are permitted provided that the following conditions are met:
|
||||
**
|
||||
** o Redistributions of source code must retain the above copyright notice, this list
|
||||
** of conditions and the following disclaimer.
|
||||
**
|
||||
** o Redistributions in binary form must reproduce the above copyright notice, this
|
||||
** list of conditions and the following disclaimer in the documentation and/or
|
||||
** other materials provided with the distribution.
|
||||
**
|
||||
** o Neither the name of Freescale Semiconductor, Inc. nor the names of its
|
||||
** contributors may be used to endorse or promote products derived from this
|
||||
** software without specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
** ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
** ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
**
|
||||
** http: www.freescale.com
|
||||
** mail: support@freescale.com
|
||||
** ###################################################################*/
|
||||
/*!
|
||||
** @file Cpu.c
|
||||
** @version 01.04
|
||||
** @brief
|
||||
**
|
||||
*/
|
||||
/*!
|
||||
** @addtogroup Cpu_module Cpu module documentation
|
||||
** @{
|
||||
*/
|
||||
|
||||
/* MODULE Cpu. */
|
||||
|
||||
/* {Default RTOS Adapter} No RTOS includes */
|
||||
|
||||
#include "hal/derivative.h"
|
||||
#include "Cpu.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Global variables */
|
||||
volatile uint8 SR_reg; /* Current value of the FAULTMASK register */
|
||||
volatile uint8 SR_lock = 0x00U; /* Lock */
|
||||
|
||||
void LowLevelInit(void);
|
||||
void InitClocks(void);
|
||||
|
||||
|
||||
CpuTypeDef Cpu =
|
||||
{
|
||||
.initClocks = InitClocks,
|
||||
.initLowLevel = LowLevelInit,
|
||||
};
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : Cpu_SetBASEPRI (component MK20DN512LL10)
|
||||
**
|
||||
** Description :
|
||||
** This method sets the BASEPRI core register.
|
||||
** This method is internal. It is used by Processor Expert only.
|
||||
** ===================================================================
|
||||
*/
|
||||
void Cpu_SetBASEPRI(uint32 Level);
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : Cpu_INT_NMIInterrupt (component MK20DN512LL10)
|
||||
**
|
||||
** Description :
|
||||
** This ISR services the Non Maskable Interrupt interrupt.
|
||||
** This method is internal. It is used by Processor Expert only.
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
void __attribute__ ((interrupt)) Cpu_INT_NMIInterrupt(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : Cpu_Cpu_Interrupt (component MK20DN512LL10)
|
||||
**
|
||||
** Description :
|
||||
** This ISR services an unused interrupt/exception vector.
|
||||
** This method is internal. It is used by Processor Expert only.
|
||||
** ===================================================================
|
||||
*/
|
||||
void __attribute__ ((interrupt)) Cpu_Interrupt(void)
|
||||
{
|
||||
/* This code can be changed using the CPU component property "Build Options / Unhandled int code" */
|
||||
PE_DEBUGHALT();
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************//**
|
||||
\fn InitClocks(void)
|
||||
\brief Initialize the clock PLL
|
||||
|
||||
This function inializes the PLL to 96MHz (with 16MHz crystal
|
||||
freqeuncy) and then switches to PLL clock.
|
||||
So the following frequencies are used:
|
||||
Core: 96MHz
|
||||
Bus: 48MHz
|
||||
FlexBus: 48MHz
|
||||
Flash: 24MHz
|
||||
|
||||
This routine has been generated by ProcessorExpert and cleaned
|
||||
up manually.
|
||||
********************************************************************/
|
||||
void InitClocks(void)
|
||||
{
|
||||
//Turn on clocking for all ports to enable pin routing
|
||||
SIM_SCGC5 |= (SIM_SCGC5_PORTA_MASK
|
||||
| SIM_SCGC5_PORTB_MASK
|
||||
| SIM_SCGC5_PORTC_MASK
|
||||
| SIM_SCGC5_PORTD_MASK
|
||||
| SIM_SCGC5_PORTE_MASK );
|
||||
|
||||
//PLL already selected by bootloader? => exit
|
||||
if((MCG_S & 0x0C)==0x0C) return;
|
||||
|
||||
SIM_CLKDIV1 = SIM_CLKDIV1_OUTDIV1(0x00) |
|
||||
SIM_CLKDIV1_OUTDIV2(0x01) |
|
||||
SIM_CLKDIV1_OUTDIV3(0x03) |
|
||||
SIM_CLKDIV1_OUTDIV4(0x03); /* Set the system prescalers to safe value */
|
||||
|
||||
if((PMC_REGSC & PMC_REGSC_ACKISO_MASK) != 0x0U)
|
||||
{
|
||||
/* PMC_REGSC: ACKISO=1 */
|
||||
PMC_REGSC |= PMC_REGSC_ACKISO_MASK; /* Release IO pads after wakeup from VLLS mode. */
|
||||
}
|
||||
/* SIM_CLKDIV1: OUTDIV1=0,OUTDIV2=1,OUTDIV3=1,OUTDIV4=3,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0 */
|
||||
SIM_CLKDIV1 = SIM_CLKDIV1_OUTDIV1(0x00) |
|
||||
SIM_CLKDIV1_OUTDIV2(0x01) |
|
||||
SIM_CLKDIV1_OUTDIV3(0x01) |
|
||||
SIM_CLKDIV1_OUTDIV4(0x03); /* Update system prescalers */
|
||||
/* SIM_SOPT2: PLLFLLSEL=1 */
|
||||
SIM_SOPT2 |= SIM_SOPT2_PLLFLLSEL_MASK|SIM_SOPT2_CLKOUTSEL(6); /* Select PLL as a clock source for various peripherals */
|
||||
/* SIM_SOPT1: OSC32KSEL=3 */
|
||||
SIM_SOPT1 |= SIM_SOPT1_OSC32KSEL(0x03); /* LPO 1kHz oscillator drives 32 kHz clock for various peripherals */
|
||||
/* Switch to FBE Mode */
|
||||
/* MCG_C2: LOCRE0=0,??=0,RANGE0=2,HGO0=0,EREFS0=1,LP=0,IRCS=0 */
|
||||
MCG_C2 = (MCG_C2_RANGE0(0x02) | MCG_C2_EREFS0_MASK);
|
||||
/* OSC_CR: ERCLKEN=1,??=0,EREFSTEN=0,??=0,SC2P=0,SC4P=0,SC8P=0,SC16P=0 */
|
||||
OSC_CR = OSC_CR_ERCLKEN_MASK;
|
||||
/* MCG_C1: CLKS=2,FRDIV=4,IREFS=0,IRCLKEN=1,IREFSTEN=0 */
|
||||
MCG_C1 = (MCG_C1_CLKS(0x02) | MCG_C1_FRDIV(0x04) | MCG_C1_IRCLKEN_MASK);
|
||||
/* MCG_C4: DMX32=0,DRST_DRS=0 */
|
||||
MCG_C4 &= (uint8)~(uint8)((MCG_C4_DMX32_MASK | MCG_C4_DRST_DRS(0x03)));
|
||||
/* MCG_C5: ??=0,PLLCLKEN0=0,PLLSTEN0=0,PRDIV0=3 */
|
||||
MCG_C5 = MCG_C5_PRDIV0(0x03);
|
||||
/* MCG_C6: LOLIE0=0,PLLS=0,CME0=0,VDIV0=0 */
|
||||
MCG_C6 = MCG_C6_VDIV0(0x00);
|
||||
while((MCG_S & MCG_S_OSCINIT0_MASK) == 0x00U); /* Check that the oscillator is running */
|
||||
while((MCG_S & MCG_S_IREFST_MASK) != 0x00U); /* Check that the source of the FLL reference clock is the external reference clock. */
|
||||
while((MCG_S & 0x0CU) != 0x08U); /* Wait until external reference clock is selected as MCG output */
|
||||
/* Switch to PBE Mode */
|
||||
/* MCG_C6: LOLIE0=0,PLLS=1,CME0=0,VDIV0=0 */
|
||||
MCG_C6 = (MCG_C6_PLLS_MASK | MCG_C6_VDIV0(0x00));
|
||||
while((MCG_S & 0x0CU) != 0x08U); /* Wait until external reference clock is selected as MCG output */
|
||||
while((MCG_S & MCG_S_LOCK0_MASK) == 0x00U); /* Wait until locked */
|
||||
/* Switch to PEE Mode */
|
||||
/* MCG_C1: CLKS=0,FRDIV=4,IREFS=0,IRCLKEN=1,IREFSTEN=0 */
|
||||
MCG_C1 = (MCG_C1_CLKS(0x00) | MCG_C1_FRDIV(0x04) | MCG_C1_IRCLKEN_MASK);
|
||||
while((MCG_S & 0x0CU) != 0x0CU); /* Wait until output of the PLL is selected */
|
||||
}
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : Cpu_SetBASEPRI (component MK20DN512LL10)
|
||||
**
|
||||
** Description :
|
||||
** This method sets the BASEPRI core register.
|
||||
** This method is internal. It is used by Processor Expert only.
|
||||
** ===================================================================
|
||||
*/
|
||||
/*lint -save -e586 -e950 Disable MISRA rule (2.1,1.1) checking. */
|
||||
#ifdef _lint
|
||||
#define Cpu_SetBASEPRI(Level) /* empty */
|
||||
#else
|
||||
void Cpu_SetBASEPRI(uint32 Level) {
|
||||
__asm ("msr basepri, %[input]"::[input] "r" (Level):);
|
||||
}
|
||||
#endif
|
||||
/*lint -restore Enable MISRA rule (2.1,1.1) checking. */
|
||||
|
||||
|
||||
|
||||
/***************************************************************//**
|
||||
\fn LowLevelInit(void)
|
||||
\brief Low level initialization of the MCU
|
||||
|
||||
This function does some low level initialization of the MCU.
|
||||
Generated by ProcessorExpert and then cleaned up manually.
|
||||
********************************************************************/
|
||||
void LowLevelInit(void)
|
||||
{
|
||||
/* Initialization of the RCM module */ //***TEST_OK: Kann je nach Beschaltung des Reset-Pins zum Absturz führen
|
||||
/* RCM_RPFW: RSTFLTSEL=0 */
|
||||
RCM_RPFW &= (uint8)~(uint8)(RCM_RPFW_RSTFLTSEL(0x1F));
|
||||
/* RCM_RPFC: RSTFLTSS=0,RSTFLTSRW=0 */
|
||||
RCM_RPFC &= (uint8)~(uint8)(
|
||||
RCM_RPFC_RSTFLTSS_MASK |
|
||||
RCM_RPFC_RSTFLTSRW(0x03)
|
||||
);
|
||||
/* Initialization of the FTFL_FlashConfig module */
|
||||
/* SIM_SCGC7: MPU=1 */
|
||||
SIM_SCGC7 |= SIM_SCGC7_MPU_MASK;
|
||||
/* Initialization of the MPU module */
|
||||
|
||||
//Turn off MPU (important e.g. for the USB stack to work properly)
|
||||
/* MPU_CESR: SPERR=0,VLD=0 */
|
||||
MPU_CESR &= (uint32)~(uint32)((MPU_CESR_SPERR(0x1F) | MPU_CESR_VLD_MASK));
|
||||
|
||||
/* Initialization of the PMC module */
|
||||
/* PMC_LVDSC1: LVDACK=1,LVDIE=0,LVDRE=1,LVDV=0 */
|
||||
PMC_LVDSC1 = (uint8)((PMC_LVDSC1 & (uint8)~(uint8)(
|
||||
PMC_LVDSC1_LVDIE_MASK |
|
||||
PMC_LVDSC1_LVDV(0x03)
|
||||
)) | (uint8)(
|
||||
PMC_LVDSC1_LVDACK_MASK |
|
||||
PMC_LVDSC1_LVDRE_MASK
|
||||
));
|
||||
/* PMC_LVDSC2: LVWACK=1,LVWIE=0,LVWV=0 */
|
||||
PMC_LVDSC2 = (uint8)((PMC_LVDSC2 & (uint8)~(uint8)(
|
||||
PMC_LVDSC2_LVWIE_MASK |
|
||||
PMC_LVDSC2_LVWV(0x03)
|
||||
)) | (uint8)(
|
||||
PMC_LVDSC2_LVWACK_MASK
|
||||
));
|
||||
/* PMC_REGSC: BGEN=0,ACKISO=0,BGBE=0 */
|
||||
PMC_REGSC &= (uint8)~(uint8)(
|
||||
PMC_REGSC_BGEN_MASK |
|
||||
PMC_REGSC_ACKISO_MASK |
|
||||
PMC_REGSC_BGBE_MASK
|
||||
);
|
||||
/* SMC_PMPROT: ??=0,??=0,AVLP=0,??=0,ALLS=0,??=0,AVLLS=0,??=0 */
|
||||
SMC_PMPROT = 0x00U; /* Setup Power mode protection register */
|
||||
|
||||
//Interrupt priority base setting
|
||||
Cpu_SetBASEPRI(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* END Cpu. */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
/*!
|
||||
** @}
|
||||
*/
|
||||
/*
|
||||
** ###################################################################
|
||||
**
|
||||
** This file was created by Processor Expert 10.4 [05.11]
|
||||
** for the Freescale Kinetis series of microcontrollers.
|
||||
**
|
||||
** ###################################################################
|
||||
*/
|
||||
202
Clean_TMC2209/lib/tmc/hal/Landungsbruecke/freescale/Cpu.h
Normal file
202
Clean_TMC2209/lib/tmc/hal/Landungsbruecke/freescale/Cpu.h
Normal file
@@ -0,0 +1,202 @@
|
||||
/* ###################################################################
|
||||
** THIS COMPONENT MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.
|
||||
** Filename : Cpu.h
|
||||
** Project : FS_TC_Test
|
||||
** Processor : MK20DN512VLL10
|
||||
** Component : MK20DN512LL10
|
||||
** Version : Component 01.000, Driver 01.04, CPU db: 3.00.000
|
||||
** Datasheet : K20P144M100SF2V2RM Rev. 2, Jun 2012
|
||||
** Compiler : GNU C Compiler
|
||||
** Date/Time : 2014-12-17, 14:57, # CodeGen: 6
|
||||
** Abstract :
|
||||
**
|
||||
** Settings :
|
||||
**
|
||||
** Contents :
|
||||
** No public methods
|
||||
**
|
||||
** (c) Freescale Semiconductor, Inc.
|
||||
** 2004 All Rights Reserved
|
||||
**
|
||||
** Copyright : 1997 - 2014 Freescale Semiconductor, Inc.
|
||||
** All Rights Reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without modification,
|
||||
** are permitted provided that the following conditions are met:
|
||||
**
|
||||
** o Redistributions of source code must retain the above copyright notice, this list
|
||||
** of conditions and the following disclaimer.
|
||||
**
|
||||
** o Redistributions in binary form must reproduce the above copyright notice, this
|
||||
** list of conditions and the following disclaimer in the documentation and/or
|
||||
** other materials provided with the distribution.
|
||||
**
|
||||
** o Neither the name of Freescale Semiconductor, Inc. nor the names of its
|
||||
** contributors may be used to endorse or promote products derived from this
|
||||
** software without specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
** ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
** ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
**
|
||||
** http: www.freescale.com
|
||||
** mail: support@freescale.com
|
||||
** ###################################################################*/
|
||||
/*!
|
||||
** @file Cpu.h
|
||||
** @version 01.04
|
||||
** @brief
|
||||
**
|
||||
*/
|
||||
/*!
|
||||
** @addtogroup Cpu_module Cpu module documentation
|
||||
** @{
|
||||
*/
|
||||
|
||||
#ifndef __Cpu_H
|
||||
#define __Cpu_H
|
||||
|
||||
/* MODULE Cpu. */
|
||||
/*Include shared modules, which are used for whole project*/
|
||||
#include "USB_CDC/PE_Types.h"
|
||||
#include "USB_CDC/PE_Error.h"
|
||||
#include "USB_CDC/PE_Const.h"
|
||||
#include "hal/derivative.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Active configuration define symbol */
|
||||
#define PEcfg_FLASH 1U
|
||||
|
||||
/* Methods configuration constants - generated for all enabled component's methods */
|
||||
|
||||
/* Events configuration constants - generated for all enabled component's events */
|
||||
#define Cpu_OnNMIINT_EVENT_ENABLED
|
||||
|
||||
#define CPU_BUS_CLK_HZ 48000000U /* Initial value of the bus clock frequency in Hz */
|
||||
#define CPU_CORE_CLK_HZ 96000000U /* Initial value of the core/system clock frequency in Hz. */
|
||||
|
||||
#define CPU_CLOCK_CONFIG_NUMBER 0x01U /* Specifies number of defined clock configurations. */
|
||||
|
||||
#define CPU_BUS_CLK_HZ_CLOCK_CONFIG0 48000000U /* Value of the bus clock frequency in the clock configuration 0 in Hz. */
|
||||
#define CPU_CORE_CLK_HZ_CLOCK_CONFIG0 96000000U /* Value of the core/system clock frequency in the clock configuration 0 in Hz. */
|
||||
|
||||
|
||||
#define CPU_XTAL_CLK_HZ 16000000U /* Value of the external crystal or oscillator clock frequency in Hz */
|
||||
#define CPU_INT_SLOW_CLK_HZ 32768U /* Value of the slow internal oscillator clock frequency in Hz */
|
||||
#define CPU_INT_FAST_CLK_HZ 4000000U /* Value of the fast internal oscillator clock frequency in Hz */
|
||||
|
||||
#define CPU_FAMILY_Kinetis /* Specification of the core type of the selected cpu */
|
||||
#define CPU_DERIVATIVE_MK20DN512LL10 /* Name of the selected cpu derivative */
|
||||
#define CPU_PARTNUM_MK20DN512VLL10 /* Part number of the selected cpu */
|
||||
#define CPU_LITTLE_ENDIAN /* The selected cpu uses little endian */
|
||||
|
||||
|
||||
/* CPU frequencies in clock configuration 0 */
|
||||
#define CPU_CLOCK_CONFIG_0 0x00U /* Clock configuration 0 identifier */
|
||||
#define CPU_CORE_CLK_HZ_CONFIG_0 96000000UL /* Core clock frequency in clock configuration 0 */
|
||||
#define CPU_BUS_CLK_HZ_CONFIG_0 48000000UL /* Bus clock frequency in clock configuration 0 */
|
||||
#define CPU_FLEXBUS_CLK_HZ_CONFIG_0 48000000UL /* Flexbus clock frequency in clock configuration 0 */
|
||||
#define CPU_FLASH_CLK_HZ_CONFIG_0 24000000UL /* FLASH clock frequency in clock configuration 0 */
|
||||
#define CPU_USB_CLK_HZ_CONFIG_0 0UL /* USB clock frequency in clock configuration 0 */
|
||||
#define CPU_PLL_FLL_CLK_HZ_CONFIG_0 96000000UL /* PLL/FLL clock frequency in clock configuration 0 */
|
||||
#define CPU_MCGIR_CLK_HZ_CONFIG_0 32768UL /* MCG internal reference clock frequency in clock configuration 0 */
|
||||
#define CPU_OSCER_CLK_HZ_CONFIG_0 16000000UL /* System OSC external reference clock frequency in clock configuration 0 */
|
||||
#define CPU_ERCLK32K_CLK_HZ_CONFIG_0 1000UL /* External reference clock 32k frequency in clock configuration 0 */
|
||||
#define CPU_MCGFF_CLK_HZ_CONFIG_0 31250UL /* MCG fixed frequency clock */
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint32 cpu_core_clk_hz; /* Core clock frequency in clock configuration */
|
||||
uint32 cpu_bus_clk_hz; /* Bus clock frequency in clock configuration */
|
||||
uint32 cpu_flexbus_clk_hz; /* Flexbus clock frequency in clock configuration */
|
||||
uint32 cpu_flash_clk_hz; /* FLASH clock frequency in clock configuration */
|
||||
uint32 cpu_usb_clk_hz; /* USB clock frequency in clock configuration */
|
||||
uint32 cpu_pll_fll_clk_hz; /* PLL/FLL clock frequency in clock configuration */
|
||||
uint32 cpu_mcgir_clk_hz; /* MCG internal reference clock frequency in clock configuration */
|
||||
uint32 cpu_oscer_clk_hz; /* System OSC external reference clock frequency in clock configuration */
|
||||
uint32 cpu_erclk32k_clk_hz; /* External reference clock 32k frequency in clock configuration */
|
||||
uint32 cpu_mcgff_clk_hz; /* MCG fixed frequency clock */
|
||||
} TCpuClockConfiguration;
|
||||
|
||||
/* The array of clock frequencies in configured clock configurations */
|
||||
extern const TCpuClockConfiguration PE_CpuClockConfigurations[CPU_CLOCK_CONFIG_NUMBER];
|
||||
|
||||
/* Interrupt vector table type definition */
|
||||
typedef void (*const tIsrFunc)(void);
|
||||
typedef struct {
|
||||
void * __ptr;
|
||||
tIsrFunc __fun[0x77];
|
||||
} tVectorTable;
|
||||
|
||||
extern const tVectorTable __vect_table;
|
||||
|
||||
/* Global variables */
|
||||
/*lint -esym(765,SR_reg) Disable MISRA rule (8.10) checking for symbols (SR_reg). The SR_reg is used in inline assembler. */
|
||||
extern volatile uint8 SR_reg; /* Current FAULTMASK register */
|
||||
/*lint -esym(765,SR_lock) Disable MISRA rule (8.10) checking for symbols (SR_lock). The SR_reg is used in inline assembler. */
|
||||
extern volatile uint8 SR_lock;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
void (*initClocks)(void);
|
||||
void (*initLowLevel)(void);
|
||||
} CpuTypeDef;
|
||||
|
||||
|
||||
extern CpuTypeDef Cpu;
|
||||
|
||||
|
||||
/* {Default RTOS Adapter} ISR function prototype */
|
||||
void __attribute__ ((interrupt)) Cpu_INT_NMIInterrupt(void);
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : Cpu_INT_NMIInterrupt (component MK20DN512LL10)
|
||||
**
|
||||
** Description :
|
||||
** This ISR services the Non Maskable Interrupt interrupt.
|
||||
** This method is internal. It is used by Processor Expert only.
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
void __attribute__ ((interrupt)) Cpu_Interrupt(void);
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : Cpu_Cpu_Interrupt (component MK20DN512LL10)
|
||||
**
|
||||
** Description :
|
||||
** This ISR services an unused interrupt/exception vector.
|
||||
** This method is internal. It is used by Processor Expert only.
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
/* END Cpu. */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/* __Cpu_H */
|
||||
|
||||
/*!
|
||||
** @}
|
||||
*/
|
||||
/*
|
||||
** ###################################################################
|
||||
**
|
||||
** This file was created by Processor Expert 10.4 [05.11]
|
||||
** for the Freescale Kinetis series of microcontrollers.
|
||||
**
|
||||
** ###################################################################
|
||||
*/
|
||||
14458
Clean_TMC2209/lib/tmc/hal/Landungsbruecke/freescale/MK20D10.h
Normal file
14458
Clean_TMC2209/lib/tmc/hal/Landungsbruecke/freescale/MK20D10.h
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,205 @@
|
||||
/*
|
||||
*****************************************************************************
|
||||
**
|
||||
** File : MK20DN512.ld
|
||||
**
|
||||
** Default linker command file for Flash targets
|
||||
**
|
||||
*****************************************************************************
|
||||
*/
|
||||
/* Entry Point */
|
||||
ENTRY(__thumb_startup)
|
||||
|
||||
/* Highest address of the user mode stack */
|
||||
_estack = 0x20010000; /* end of SRAM */
|
||||
__SP_INIT = _estack;
|
||||
|
||||
/* Generate a link error if heap and stack don't fit into RAM */
|
||||
__heap_size = 0x400; /* required amount of heap */
|
||||
__stack_size = 0x400; /* required amount of stack */
|
||||
|
||||
/* Specify the memory areas */
|
||||
MEMORY
|
||||
{
|
||||
m_interrupts (rx) : ORIGIN = 0x00008000, LENGTH = 0x1BC
|
||||
m_cfmprotrom (rx) : ORIGIN = 0x00008400, LENGTH = 0x10
|
||||
m_text (rx) : ORIGIN = 0x00008410, LENGTH = 512K-32K-0x410
|
||||
m_data (rwx) : ORIGIN = 0x1FFF0000, LENGTH = 128K /* SRAM */
|
||||
}
|
||||
|
||||
|
||||
/* Define output sections */
|
||||
SECTIONS
|
||||
{
|
||||
/* The startup code goes first into Flash */
|
||||
.interrupts :
|
||||
{
|
||||
__vector_table = .;
|
||||
. = ALIGN(4);
|
||||
KEEP(*(.vectortable)) /* Startup code */
|
||||
. = ALIGN(4);
|
||||
} > m_interrupts
|
||||
|
||||
.cfmprotect :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
KEEP(*(.cfmconfig)) /* Flash Configuration Field (FCF) */
|
||||
. = ALIGN(4);
|
||||
} > m_cfmprotrom
|
||||
|
||||
/* The program code and other data goes into Flash */
|
||||
.text :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
*(.text) /* .text sections (code) */
|
||||
*(.text*) /* .text* sections (code) */
|
||||
*(.rodata) /* .rodata sections (constants, strings, etc.) */
|
||||
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
|
||||
*(.glue_7) /* glue arm to thumb code */
|
||||
*(.glue_7t) /* glue thumb to arm code */
|
||||
*(.eh_frame)
|
||||
|
||||
KEEP (*(.init))
|
||||
KEEP (*(.fini))
|
||||
|
||||
. = ALIGN(4);
|
||||
_etext = .; /* define a global symbols at end of code */
|
||||
} > m_text
|
||||
|
||||
.ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } > m_text
|
||||
.ARM : {
|
||||
__exidx_start = .;
|
||||
*(.ARM.exidx*)
|
||||
__exidx_end = .;
|
||||
} > m_text
|
||||
|
||||
.ctors :
|
||||
{
|
||||
__CTOR_LIST__ = .;
|
||||
/* gcc uses crtbegin.o to find the start of
|
||||
the constructors, so we make sure it is
|
||||
first. Because this is a wildcard, it
|
||||
doesn't matter if the user does not
|
||||
actually link against crtbegin.o; the
|
||||
linker won't look for a file to match a
|
||||
wildcard. The wildcard also means that it
|
||||
doesn't matter which directory crtbegin.o
|
||||
is in. */
|
||||
KEEP (*crtbegin.o(.ctors))
|
||||
/* We don't want to include the .ctor section from
|
||||
from the crtend.o file until after the sorted ctors.
|
||||
The .ctor section from the crtend file contains the
|
||||
end of ctors marker and it must be last */
|
||||
KEEP (*(EXCLUDE_FILE (*crtend.o ) .ctors))
|
||||
KEEP (*(SORT(.ctors.*)))
|
||||
KEEP (*(.ctors))
|
||||
__CTOR_END__ = .;
|
||||
} > m_text
|
||||
.dtors :
|
||||
{
|
||||
__DTOR_LIST__ = .;
|
||||
KEEP (*crtbegin.o(.dtors))
|
||||
KEEP (*(EXCLUDE_FILE (*crtend.o ) .dtors))
|
||||
KEEP (*(SORT(.dtors.*)))
|
||||
KEEP (*(.dtors))
|
||||
__DTOR_END__ = .;
|
||||
} > m_text
|
||||
|
||||
.preinit_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__preinit_array_start = .);
|
||||
KEEP (*(.preinit_array*))
|
||||
PROVIDE_HIDDEN (__preinit_array_end = .);
|
||||
} > m_text
|
||||
.init_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__init_array_start = .);
|
||||
KEEP (*(SORT(.init_array.*)))
|
||||
KEEP (*(.init_array*))
|
||||
PROVIDE_HIDDEN (__init_array_end = .);
|
||||
} > m_text
|
||||
.fini_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__fini_array_start = .);
|
||||
KEEP (*(SORT(.fini_array.*)))
|
||||
KEEP (*(.fini_array*))
|
||||
PROVIDE_HIDDEN (__fini_array_end = .);
|
||||
|
||||
___ROM_AT = .;
|
||||
} > m_text
|
||||
|
||||
/* special area for data exchange between boot loader and application
|
||||
at the beginning of the RAM*/
|
||||
.bldata (NOLOAD) :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
KEEP(*(.bldata))
|
||||
. = ALIGN(4);
|
||||
} > m_data
|
||||
|
||||
/* reserve MTB memory at the beginning of m_data */
|
||||
.mtb : /* MTB buffer address as defined by the hardware */
|
||||
{
|
||||
. = ALIGN(8);
|
||||
_mtb_start = .;
|
||||
KEEP(*(.mtb_buf)) /* need to KEEP Micro Trace Buffer as not referenced by application */
|
||||
. = ALIGN(8);
|
||||
_mtb_end = .;
|
||||
} > m_data
|
||||
|
||||
/* Initialized data sections goes into RAM, load LMA copy after code */
|
||||
.data : AT(___ROM_AT)
|
||||
{
|
||||
. = ALIGN(4);
|
||||
_sdata = .; /* create a global symbol at data start */
|
||||
*(.data) /* .data sections */
|
||||
*(.data*) /* .data* sections */
|
||||
|
||||
. = ALIGN(4);
|
||||
_edata = .; /* define a global symbol at data end */
|
||||
} > m_data
|
||||
|
||||
___data_size = _edata - _sdata;
|
||||
|
||||
/* Uninitialized data section */
|
||||
. = ALIGN(4);
|
||||
.bss :
|
||||
{
|
||||
/* This is used by the startup in order to initialize the .bss section */
|
||||
__START_BSS = .;
|
||||
PROVIDE ( __bss_start__ = __START_BSS );
|
||||
*(.bss)
|
||||
*(.bss*)
|
||||
*(COMMON)
|
||||
|
||||
. = ALIGN(4);
|
||||
__END_BSS = .;
|
||||
PROVIDE ( __bss_end__ = __END_BSS );
|
||||
} > m_data
|
||||
|
||||
_romp_at = ___ROM_AT + SIZEOF(.data);
|
||||
.romp : AT(_romp_at)
|
||||
{
|
||||
__S_romp = _romp_at;
|
||||
LONG(___ROM_AT);
|
||||
LONG(_sdata);
|
||||
LONG(___data_size);
|
||||
LONG(0);
|
||||
LONG(0);
|
||||
LONG(0);
|
||||
} > m_data
|
||||
|
||||
/* User_heap_stack section, used to check that there is enough RAM left */
|
||||
._user_heap_stack :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
PROVIDE ( end = . );
|
||||
PROVIDE ( _end = . );
|
||||
__heap_addr = .;
|
||||
. = . + __heap_size;
|
||||
. = . + __stack_size;
|
||||
. = ALIGN(4);
|
||||
} > m_data
|
||||
|
||||
.ARM.attributes 0 : { *(.ARM.attributes) }
|
||||
}
|
||||
205
Clean_TMC2209/lib/tmc/hal/Landungsbruecke/freescale/MK20DN512.ld
Normal file
205
Clean_TMC2209/lib/tmc/hal/Landungsbruecke/freescale/MK20DN512.ld
Normal file
@@ -0,0 +1,205 @@
|
||||
/*
|
||||
*****************************************************************************
|
||||
**
|
||||
** File : MK20DN512.ld
|
||||
**
|
||||
** Default linker command file for Flash targets
|
||||
**
|
||||
*****************************************************************************
|
||||
*/
|
||||
/* Entry Point */
|
||||
ENTRY(__thumb_startup)
|
||||
|
||||
/* Highest address of the user mode stack */
|
||||
_estack = 0x20010000; /* end of SRAM */
|
||||
__SP_INIT = _estack;
|
||||
|
||||
/* Generate a link error if heap and stack don't fit into RAM */
|
||||
__heap_size = 0x400; /* required amount of heap */
|
||||
__stack_size = 0x400; /* required amount of stack */
|
||||
|
||||
/* Specify the memory areas */
|
||||
MEMORY
|
||||
{
|
||||
m_interrupts (rx) : ORIGIN = 0x00000000, LENGTH = 0x1BC
|
||||
m_cfmprotrom (rx) : ORIGIN = 0x00000400, LENGTH = 0x10
|
||||
m_text (rx) : ORIGIN = 0x00000410, LENGTH = 512K-0x410
|
||||
m_data (rwx) : ORIGIN = 0x1FFF0000, LENGTH = 128K /* SRAM */
|
||||
}
|
||||
|
||||
|
||||
/* Define output sections */
|
||||
SECTIONS
|
||||
{
|
||||
/* The startup code goes first into Flash */
|
||||
.interrupts :
|
||||
{
|
||||
__vector_table = .;
|
||||
. = ALIGN(4);
|
||||
KEEP(*(.vectortable)) /* Startup code */
|
||||
. = ALIGN(4);
|
||||
} > m_interrupts
|
||||
|
||||
.cfmprotect :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
KEEP(*(.cfmconfig)) /* Flash Configuration Field (FCF) */
|
||||
. = ALIGN(4);
|
||||
} > m_cfmprotrom
|
||||
|
||||
/* The program code and other data goes into Flash */
|
||||
.text :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
*(.text) /* .text sections (code) */
|
||||
*(.text*) /* .text* sections (code) */
|
||||
*(.rodata) /* .rodata sections (constants, strings, etc.) */
|
||||
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
|
||||
*(.glue_7) /* glue arm to thumb code */
|
||||
*(.glue_7t) /* glue thumb to arm code */
|
||||
*(.eh_frame)
|
||||
|
||||
KEEP (*(.init))
|
||||
KEEP (*(.fini))
|
||||
|
||||
. = ALIGN(4);
|
||||
_etext = .; /* define a global symbols at end of code */
|
||||
} > m_text
|
||||
|
||||
.ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } > m_text
|
||||
.ARM : {
|
||||
__exidx_start = .;
|
||||
*(.ARM.exidx*)
|
||||
__exidx_end = .;
|
||||
} > m_text
|
||||
|
||||
.ctors :
|
||||
{
|
||||
__CTOR_LIST__ = .;
|
||||
/* gcc uses crtbegin.o to find the start of
|
||||
the constructors, so we make sure it is
|
||||
first. Because this is a wildcard, it
|
||||
doesn't matter if the user does not
|
||||
actually link against crtbegin.o; the
|
||||
linker won't look for a file to match a
|
||||
wildcard. The wildcard also means that it
|
||||
doesn't matter which directory crtbegin.o
|
||||
is in. */
|
||||
KEEP (*crtbegin.o(.ctors))
|
||||
/* We don't want to include the .ctor section from
|
||||
from the crtend.o file until after the sorted ctors.
|
||||
The .ctor section from the crtend file contains the
|
||||
end of ctors marker and it must be last */
|
||||
KEEP (*(EXCLUDE_FILE (*crtend.o ) .ctors))
|
||||
KEEP (*(SORT(.ctors.*)))
|
||||
KEEP (*(.ctors))
|
||||
__CTOR_END__ = .;
|
||||
} > m_text
|
||||
.dtors :
|
||||
{
|
||||
__DTOR_LIST__ = .;
|
||||
KEEP (*crtbegin.o(.dtors))
|
||||
KEEP (*(EXCLUDE_FILE (*crtend.o ) .dtors))
|
||||
KEEP (*(SORT(.dtors.*)))
|
||||
KEEP (*(.dtors))
|
||||
__DTOR_END__ = .;
|
||||
} > m_text
|
||||
|
||||
.preinit_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__preinit_array_start = .);
|
||||
KEEP (*(.preinit_array*))
|
||||
PROVIDE_HIDDEN (__preinit_array_end = .);
|
||||
} > m_text
|
||||
.init_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__init_array_start = .);
|
||||
KEEP (*(SORT(.init_array.*)))
|
||||
KEEP (*(.init_array*))
|
||||
PROVIDE_HIDDEN (__init_array_end = .);
|
||||
} > m_text
|
||||
.fini_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__fini_array_start = .);
|
||||
KEEP (*(SORT(.fini_array.*)))
|
||||
KEEP (*(.fini_array*))
|
||||
PROVIDE_HIDDEN (__fini_array_end = .);
|
||||
|
||||
___ROM_AT = .;
|
||||
} > m_text
|
||||
|
||||
/* special area for data exchange between boot loader and application
|
||||
at the beginning of the RAM*/
|
||||
.bldata (NOLOAD) :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
KEEP(*(.bldata))
|
||||
. = ALIGN(4);
|
||||
} > m_data
|
||||
|
||||
/* reserve MTB memory at the beginning of m_data */
|
||||
.mtb : /* MTB buffer address as defined by the hardware */
|
||||
{
|
||||
. = ALIGN(8);
|
||||
_mtb_start = .;
|
||||
KEEP(*(.mtb_buf)) /* need to KEEP Micro Trace Buffer as not referenced by application */
|
||||
. = ALIGN(8);
|
||||
_mtb_end = .;
|
||||
} > m_data
|
||||
|
||||
/* Initialized data sections goes into RAM, load LMA copy after code */
|
||||
.data : AT(___ROM_AT)
|
||||
{
|
||||
. = ALIGN(4);
|
||||
_sdata = .; /* create a global symbol at data start */
|
||||
*(.data) /* .data sections */
|
||||
*(.data*) /* .data* sections */
|
||||
*(.ramcode) /* .ramcode section for code to be executed in SRAM */
|
||||
. = ALIGN(4);
|
||||
_edata = .; /* define a global symbol at data end */
|
||||
} > m_data
|
||||
|
||||
___data_size = _edata - _sdata;
|
||||
|
||||
/* Uninitialized data section */
|
||||
. = ALIGN(4);
|
||||
.bss :
|
||||
{
|
||||
/* This is used by the startup in order to initialize the .bss section */
|
||||
__START_BSS = .;
|
||||
PROVIDE ( __bss_start__ = __START_BSS );
|
||||
*(.bss)
|
||||
*(.bss*)
|
||||
*(COMMON)
|
||||
|
||||
. = ALIGN(4);
|
||||
__END_BSS = .;
|
||||
PROVIDE ( __bss_end__ = __END_BSS );
|
||||
} > m_data
|
||||
|
||||
_romp_at = ___ROM_AT + SIZEOF(.data);
|
||||
.romp : AT(_romp_at)
|
||||
{
|
||||
__S_romp = _romp_at;
|
||||
LONG(___ROM_AT);
|
||||
LONG(_sdata);
|
||||
LONG(___data_size);
|
||||
LONG(0);
|
||||
LONG(0);
|
||||
LONG(0);
|
||||
} > m_data
|
||||
|
||||
/* User_heap_stack section, used to check that there is enough RAM left */
|
||||
._user_heap_stack :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
PROVIDE ( end = . );
|
||||
PROVIDE ( _end = . );
|
||||
__heap_addr = .;
|
||||
. = . + __heap_size;
|
||||
. = . + __stack_size;
|
||||
. = ALIGN(4);
|
||||
} > m_data
|
||||
|
||||
.ARM.attributes 0 : { *(.ARM.attributes) }
|
||||
}
|
||||
@@ -0,0 +1,205 @@
|
||||
/*
|
||||
*****************************************************************************
|
||||
**
|
||||
** File : MK20DX256-TMCM.ld
|
||||
**
|
||||
** Default linker command file for Flash targets
|
||||
**
|
||||
*****************************************************************************
|
||||
*/
|
||||
/* Entry Point */
|
||||
ENTRY(__thumb_startup)
|
||||
|
||||
/* Highest address of the user mode stack */
|
||||
_estack = 0x20008000; /* end of SRAM */
|
||||
__SP_INIT = _estack;
|
||||
|
||||
/* Generate a link error if heap and stack don't fit into RAM */
|
||||
__heap_size = 0x400; /* required amount of heap */
|
||||
__stack_size = 0x400; /* required amount of stack */
|
||||
|
||||
/* Specify the memory areas */
|
||||
MEMORY
|
||||
{
|
||||
m_interrupts (rx) : ORIGIN = 0x00008000, LENGTH = 0x1BC
|
||||
m_cfmprotrom (rx) : ORIGIN = 0x00008400, LENGTH = 0x10
|
||||
m_text (rx) : ORIGIN = 0x00008410, LENGTH = 512K-32K-0x410
|
||||
m_data (rwx) : ORIGIN = 0x1FFF8000, LENGTH = 64K /* SRAM */
|
||||
}
|
||||
|
||||
|
||||
/* Define output sections */
|
||||
SECTIONS
|
||||
{
|
||||
/* The startup code goes first into Flash */
|
||||
.interrupts :
|
||||
{
|
||||
__vector_table = .;
|
||||
. = ALIGN(4);
|
||||
KEEP(*(.vectortable)) /* Startup code */
|
||||
. = ALIGN(4);
|
||||
} > m_interrupts
|
||||
|
||||
.cfmprotect :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
KEEP(*(.cfmconfig)) /* Flash Configuration Field (FCF) */
|
||||
. = ALIGN(4);
|
||||
} > m_cfmprotrom
|
||||
|
||||
/* The program code and other data goes into Flash */
|
||||
.text :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
*(.text) /* .text sections (code) */
|
||||
*(.text*) /* .text* sections (code) */
|
||||
*(.rodata) /* .rodata sections (constants, strings, etc.) */
|
||||
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
|
||||
*(.glue_7) /* glue arm to thumb code */
|
||||
*(.glue_7t) /* glue thumb to arm code */
|
||||
*(.eh_frame)
|
||||
|
||||
KEEP (*(.init))
|
||||
KEEP (*(.fini))
|
||||
|
||||
. = ALIGN(4);
|
||||
_etext = .; /* define a global symbols at end of code */
|
||||
} > m_text
|
||||
|
||||
.ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } > m_text
|
||||
.ARM : {
|
||||
__exidx_start = .;
|
||||
*(.ARM.exidx*)
|
||||
__exidx_end = .;
|
||||
} > m_text
|
||||
|
||||
.ctors :
|
||||
{
|
||||
__CTOR_LIST__ = .;
|
||||
/* gcc uses crtbegin.o to find the start of
|
||||
the constructors, so we make sure it is
|
||||
first. Because this is a wildcard, it
|
||||
doesn't matter if the user does not
|
||||
actually link against crtbegin.o; the
|
||||
linker won't look for a file to match a
|
||||
wildcard. The wildcard also means that it
|
||||
doesn't matter which directory crtbegin.o
|
||||
is in. */
|
||||
KEEP (*crtbegin.o(.ctors))
|
||||
/* We don't want to include the .ctor section from
|
||||
from the crtend.o file until after the sorted ctors.
|
||||
The .ctor section from the crtend file contains the
|
||||
end of ctors marker and it must be last */
|
||||
KEEP (*(EXCLUDE_FILE (*crtend.o ) .ctors))
|
||||
KEEP (*(SORT(.ctors.*)))
|
||||
KEEP (*(.ctors))
|
||||
__CTOR_END__ = .;
|
||||
} > m_text
|
||||
.dtors :
|
||||
{
|
||||
__DTOR_LIST__ = .;
|
||||
KEEP (*crtbegin.o(.dtors))
|
||||
KEEP (*(EXCLUDE_FILE (*crtend.o ) .dtors))
|
||||
KEEP (*(SORT(.dtors.*)))
|
||||
KEEP (*(.dtors))
|
||||
__DTOR_END__ = .;
|
||||
} > m_text
|
||||
|
||||
.preinit_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__preinit_array_start = .);
|
||||
KEEP (*(.preinit_array*))
|
||||
PROVIDE_HIDDEN (__preinit_array_end = .);
|
||||
} > m_text
|
||||
.init_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__init_array_start = .);
|
||||
KEEP (*(SORT(.init_array.*)))
|
||||
KEEP (*(.init_array*))
|
||||
PROVIDE_HIDDEN (__init_array_end = .);
|
||||
} > m_text
|
||||
.fini_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__fini_array_start = .);
|
||||
KEEP (*(SORT(.fini_array.*)))
|
||||
KEEP (*(.fini_array*))
|
||||
PROVIDE_HIDDEN (__fini_array_end = .);
|
||||
|
||||
___ROM_AT = .;
|
||||
} > m_text
|
||||
|
||||
/* special area for data exchange between boot loader and application
|
||||
at the beginning of the RAM*/
|
||||
.bldata (NOLOAD) :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
KEEP(*(.bldata))
|
||||
. = ALIGN(4);
|
||||
} > m_data
|
||||
|
||||
/* reserve MTB memory at the beginning of m_data */
|
||||
.mtb : /* MTB buffer address as defined by the hardware */
|
||||
{
|
||||
. = ALIGN(8);
|
||||
_mtb_start = .;
|
||||
KEEP(*(.mtb_buf)) /* need to KEEP Micro Trace Buffer as not referenced by application */
|
||||
. = ALIGN(8);
|
||||
_mtb_end = .;
|
||||
} > m_data
|
||||
|
||||
/* Initialized data sections goes into RAM, load LMA copy after code */
|
||||
.data : AT(___ROM_AT)
|
||||
{
|
||||
. = ALIGN(4);
|
||||
_sdata = .; /* create a global symbol at data start */
|
||||
*(.data) /* .data sections */
|
||||
*(.data*) /* .data* sections */
|
||||
|
||||
. = ALIGN(4);
|
||||
_edata = .; /* define a global symbol at data end */
|
||||
} > m_data
|
||||
|
||||
___data_size = _edata - _sdata;
|
||||
|
||||
/* Uninitialized data section */
|
||||
. = ALIGN(4);
|
||||
.bss :
|
||||
{
|
||||
/* This is used by the startup in order to initialize the .bss section */
|
||||
__START_BSS = .;
|
||||
PROVIDE ( __bss_start__ = __START_BSS );
|
||||
*(.bss)
|
||||
*(.bss*)
|
||||
*(COMMON)
|
||||
|
||||
. = ALIGN(4);
|
||||
__END_BSS = .;
|
||||
PROVIDE ( __bss_end__ = __END_BSS );
|
||||
} > m_data
|
||||
|
||||
_romp_at = ___ROM_AT + SIZEOF(.data);
|
||||
.romp : AT(_romp_at)
|
||||
{
|
||||
__S_romp = _romp_at;
|
||||
LONG(___ROM_AT);
|
||||
LONG(_sdata);
|
||||
LONG(___data_size);
|
||||
LONG(0);
|
||||
LONG(0);
|
||||
LONG(0);
|
||||
} > m_data
|
||||
|
||||
/* User_heap_stack section, used to check that there is enough RAM left */
|
||||
._user_heap_stack :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
PROVIDE ( end = . );
|
||||
PROVIDE ( _end = . );
|
||||
__heap_addr = .;
|
||||
. = . + __heap_size;
|
||||
. = . + __stack_size;
|
||||
. = ALIGN(4);
|
||||
} > m_data
|
||||
|
||||
.ARM.attributes 0 : { *(.ARM.attributes) }
|
||||
}
|
||||
205
Clean_TMC2209/lib/tmc/hal/Landungsbruecke/freescale/MK20DX256.ld
Normal file
205
Clean_TMC2209/lib/tmc/hal/Landungsbruecke/freescale/MK20DX256.ld
Normal file
@@ -0,0 +1,205 @@
|
||||
/*
|
||||
*****************************************************************************
|
||||
**
|
||||
** File : MK20DN512.ld
|
||||
**
|
||||
** Default linker command file for Flash targets
|
||||
**
|
||||
*****************************************************************************
|
||||
*/
|
||||
/* Entry Point */
|
||||
ENTRY(__thumb_startup)
|
||||
|
||||
/* Highest address of the user mode stack */
|
||||
_estack = 0x20008000; /* end of SRAM */
|
||||
__SP_INIT = _estack;
|
||||
|
||||
/* Generate a link error if heap and stack don't fit into RAM */
|
||||
__heap_size = 0x400; /* required amount of heap */
|
||||
__stack_size = 0x400; /* required amount of stack */
|
||||
|
||||
/* Specify the memory areas */
|
||||
MEMORY
|
||||
{
|
||||
m_interrupts (rx) : ORIGIN = 0x00000000, LENGTH = 0x1BC
|
||||
m_cfmprotrom (rx) : ORIGIN = 0x00000400, LENGTH = 0x10
|
||||
m_text (rx) : ORIGIN = 0x00000410, LENGTH = 512K-0x410
|
||||
m_data (rwx) : ORIGIN = 0x1FFF8000, LENGTH = 64K /* SRAM */
|
||||
}
|
||||
|
||||
|
||||
/* Define output sections */
|
||||
SECTIONS
|
||||
{
|
||||
/* The startup code goes first into Flash */
|
||||
.interrupts :
|
||||
{
|
||||
__vector_table = .;
|
||||
. = ALIGN(4);
|
||||
KEEP(*(.vectortable)) /* Startup code */
|
||||
. = ALIGN(4);
|
||||
} > m_interrupts
|
||||
|
||||
.cfmprotect :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
KEEP(*(.cfmconfig)) /* Flash Configuration Field (FCF) */
|
||||
. = ALIGN(4);
|
||||
} > m_cfmprotrom
|
||||
|
||||
/* The program code and other data goes into Flash */
|
||||
.text :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
*(.text) /* .text sections (code) */
|
||||
*(.text*) /* .text* sections (code) */
|
||||
*(.rodata) /* .rodata sections (constants, strings, etc.) */
|
||||
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
|
||||
*(.glue_7) /* glue arm to thumb code */
|
||||
*(.glue_7t) /* glue thumb to arm code */
|
||||
*(.eh_frame)
|
||||
|
||||
KEEP (*(.init))
|
||||
KEEP (*(.fini))
|
||||
|
||||
. = ALIGN(4);
|
||||
_etext = .; /* define a global symbols at end of code */
|
||||
} > m_text
|
||||
|
||||
.ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } > m_text
|
||||
.ARM : {
|
||||
__exidx_start = .;
|
||||
*(.ARM.exidx*)
|
||||
__exidx_end = .;
|
||||
} > m_text
|
||||
|
||||
.ctors :
|
||||
{
|
||||
__CTOR_LIST__ = .;
|
||||
/* gcc uses crtbegin.o to find the start of
|
||||
the constructors, so we make sure it is
|
||||
first. Because this is a wildcard, it
|
||||
doesn't matter if the user does not
|
||||
actually link against crtbegin.o; the
|
||||
linker won't look for a file to match a
|
||||
wildcard. The wildcard also means that it
|
||||
doesn't matter which directory crtbegin.o
|
||||
is in. */
|
||||
KEEP (*crtbegin.o(.ctors))
|
||||
/* We don't want to include the .ctor section from
|
||||
from the crtend.o file until after the sorted ctors.
|
||||
The .ctor section from the crtend file contains the
|
||||
end of ctors marker and it must be last */
|
||||
KEEP (*(EXCLUDE_FILE (*crtend.o ) .ctors))
|
||||
KEEP (*(SORT(.ctors.*)))
|
||||
KEEP (*(.ctors))
|
||||
__CTOR_END__ = .;
|
||||
} > m_text
|
||||
.dtors :
|
||||
{
|
||||
__DTOR_LIST__ = .;
|
||||
KEEP (*crtbegin.o(.dtors))
|
||||
KEEP (*(EXCLUDE_FILE (*crtend.o ) .dtors))
|
||||
KEEP (*(SORT(.dtors.*)))
|
||||
KEEP (*(.dtors))
|
||||
__DTOR_END__ = .;
|
||||
} > m_text
|
||||
|
||||
.preinit_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__preinit_array_start = .);
|
||||
KEEP (*(.preinit_array*))
|
||||
PROVIDE_HIDDEN (__preinit_array_end = .);
|
||||
} > m_text
|
||||
.init_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__init_array_start = .);
|
||||
KEEP (*(SORT(.init_array.*)))
|
||||
KEEP (*(.init_array*))
|
||||
PROVIDE_HIDDEN (__init_array_end = .);
|
||||
} > m_text
|
||||
.fini_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__fini_array_start = .);
|
||||
KEEP (*(SORT(.fini_array.*)))
|
||||
KEEP (*(.fini_array*))
|
||||
PROVIDE_HIDDEN (__fini_array_end = .);
|
||||
|
||||
___ROM_AT = .;
|
||||
} > m_text
|
||||
|
||||
/* special area for data exchange between boot loader and application
|
||||
at the beginning of the RAM*/
|
||||
.bldata (NOLOAD) :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
KEEP(*(.bldata))
|
||||
. = ALIGN(4);
|
||||
} > m_data
|
||||
|
||||
/* reserve MTB memory at the beginning of m_data */
|
||||
.mtb : /* MTB buffer address as defined by the hardware */
|
||||
{
|
||||
. = ALIGN(8);
|
||||
_mtb_start = .;
|
||||
KEEP(*(.mtb_buf)) /* need to KEEP Micro Trace Buffer as not referenced by application */
|
||||
. = ALIGN(8);
|
||||
_mtb_end = .;
|
||||
} > m_data
|
||||
|
||||
/* Initialized data sections goes into RAM, load LMA copy after code */
|
||||
.data : AT(___ROM_AT)
|
||||
{
|
||||
. = ALIGN(4);
|
||||
_sdata = .; /* create a global symbol at data start */
|
||||
*(.data) /* .data sections */
|
||||
*(.data*) /* .data* sections */
|
||||
*(.ramcode) /* .ramcode section for code to be executed in SRAM */
|
||||
. = ALIGN(4);
|
||||
_edata = .; /* define a global symbol at data end */
|
||||
} > m_data
|
||||
|
||||
___data_size = _edata - _sdata;
|
||||
|
||||
/* Uninitialized data section */
|
||||
. = ALIGN(4);
|
||||
.bss :
|
||||
{
|
||||
/* This is used by the startup in order to initialize the .bss section */
|
||||
__START_BSS = .;
|
||||
PROVIDE ( __bss_start__ = __START_BSS );
|
||||
*(.bss)
|
||||
*(.bss*)
|
||||
*(COMMON)
|
||||
|
||||
. = ALIGN(4);
|
||||
__END_BSS = .;
|
||||
PROVIDE ( __bss_end__ = __END_BSS );
|
||||
} > m_data
|
||||
|
||||
_romp_at = ___ROM_AT + SIZEOF(.data);
|
||||
.romp : AT(_romp_at)
|
||||
{
|
||||
__S_romp = _romp_at;
|
||||
LONG(___ROM_AT);
|
||||
LONG(_sdata);
|
||||
LONG(___data_size);
|
||||
LONG(0);
|
||||
LONG(0);
|
||||
LONG(0);
|
||||
} > m_data
|
||||
|
||||
/* User_heap_stack section, used to check that there is enough RAM left */
|
||||
._user_heap_stack :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
PROVIDE ( end = . );
|
||||
PROVIDE ( _end = . );
|
||||
__heap_addr = .;
|
||||
. = . + __heap_size;
|
||||
. = . + __stack_size;
|
||||
. = ALIGN(4);
|
||||
} > m_data
|
||||
|
||||
.ARM.attributes 0 : { *(.ARM.attributes) }
|
||||
}
|
||||
3727
Clean_TMC2209/lib/tmc/hal/Landungsbruecke/freescale/PDD/ADC_PDD.h
Normal file
3727
Clean_TMC2209/lib/tmc/hal/Landungsbruecke/freescale/PDD/ADC_PDD.h
Normal file
File diff suppressed because it is too large
Load Diff
2898
Clean_TMC2209/lib/tmc/hal/Landungsbruecke/freescale/PDD/CAN_PDD.h
Normal file
2898
Clean_TMC2209/lib/tmc/hal/Landungsbruecke/freescale/PDD/CAN_PDD.h
Normal file
File diff suppressed because it is too large
Load Diff
2501
Clean_TMC2209/lib/tmc/hal/Landungsbruecke/freescale/PDD/CMP_PDD.h
Normal file
2501
Clean_TMC2209/lib/tmc/hal/Landungsbruecke/freescale/PDD/CMP_PDD.h
Normal file
File diff suppressed because it is too large
Load Diff
1110
Clean_TMC2209/lib/tmc/hal/Landungsbruecke/freescale/PDD/CMT_PDD.h
Normal file
1110
Clean_TMC2209/lib/tmc/hal/Landungsbruecke/freescale/PDD/CMT_PDD.h
Normal file
File diff suppressed because it is too large
Load Diff
1134
Clean_TMC2209/lib/tmc/hal/Landungsbruecke/freescale/PDD/CRC_PDD.h
Normal file
1134
Clean_TMC2209/lib/tmc/hal/Landungsbruecke/freescale/PDD/CRC_PDD.h
Normal file
File diff suppressed because it is too large
Load Diff
1353
Clean_TMC2209/lib/tmc/hal/Landungsbruecke/freescale/PDD/DAC_PDD.h
Normal file
1353
Clean_TMC2209/lib/tmc/hal/Landungsbruecke/freescale/PDD/DAC_PDD.h
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,402 @@
|
||||
/*
|
||||
PDD layer implementation for peripheral type DMAMUX
|
||||
(C) 2013 Freescale, Inc. All rights reserved.
|
||||
|
||||
This file is static and it is generated from API-Factory
|
||||
*/
|
||||
|
||||
#if !defined(DMAMUX_PDD_H_)
|
||||
#define DMAMUX_PDD_H_
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- Test if supported MCU is active
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
#if !defined(MCU_ACTIVE)
|
||||
// No MCU is active
|
||||
#error DMAMUX PDD library: No derivative is active. Place proper #include with PDD memory map before including PDD library.
|
||||
#elif \
|
||||
!defined(MCU_MK10D10) /* DMAMUX */ && \
|
||||
!defined(MCU_MK10D5) /* DMAMUX */ && \
|
||||
!defined(MCU_MK10D7) /* DMAMUX */ && \
|
||||
!defined(MCU_MK10F12) /* DMAMUX0, DMAMUX1 */ && \
|
||||
!defined(MCU_MK10DZ10) /* DMAMUX */ && \
|
||||
!defined(MCU_MK11D5) /* DMAMUX */ && \
|
||||
!defined(MCU_MK11D5WS) /* DMAMUX */ && \
|
||||
!defined(MCU_MK12D5) /* DMAMUX */ && \
|
||||
!defined(MCU_MK20D10) /* DMAMUX */ && \
|
||||
!defined(MCU_MK20D5) /* DMAMUX */ && \
|
||||
!defined(MCU_MK20D7) /* DMAMUX */ && \
|
||||
!defined(MCU_MK20F12) /* DMAMUX0, DMAMUX1 */ && \
|
||||
!defined(MCU_MK20DZ10) /* DMAMUX */ && \
|
||||
!defined(MCU_MK21D5) /* DMAMUX */ && \
|
||||
!defined(MCU_MK21D5WS) /* DMAMUX */ && \
|
||||
!defined(MCU_MK21F12) /* DMAMUX */ && \
|
||||
!defined(MCU_MK21F12WS) /* DMAMUX */ && \
|
||||
!defined(MCU_MK22D5) /* DMAMUX */ && \
|
||||
!defined(MCU_MK22F12810) /* DMAMUX */ && \
|
||||
!defined(MCU_MK22F12) /* DMAMUX */ && \
|
||||
!defined(MCU_MK22F25612) /* DMAMUX */ && \
|
||||
!defined(MCU_MK22F51212) /* DMAMUX */ && \
|
||||
!defined(MCU_MK24F12) /* DMAMUX */ && \
|
||||
!defined(MCU_MK30D10) /* DMAMUX */ && \
|
||||
!defined(MCU_MK30D7) /* DMAMUX */ && \
|
||||
!defined(MCU_MK30DZ10) /* DMAMUX */ && \
|
||||
!defined(MCU_MK40D10) /* DMAMUX */ && \
|
||||
!defined(MCU_MK40D7) /* DMAMUX */ && \
|
||||
!defined(MCU_MK40DZ10) /* DMAMUX */ && \
|
||||
!defined(MCU_MK40X256VMD100) /* DMAMUX */ && \
|
||||
!defined(MCU_MK50D10) /* DMAMUX */ && \
|
||||
!defined(MCU_MK50D7) /* DMAMUX */ && \
|
||||
!defined(MCU_MK50DZ10) /* DMAMUX */ && \
|
||||
!defined(MCU_MK51D10) /* DMAMUX */ && \
|
||||
!defined(MCU_MK51D7) /* DMAMUX */ && \
|
||||
!defined(MCU_MK51DZ10) /* DMAMUX */ && \
|
||||
!defined(MCU_MK52D10) /* DMAMUX */ && \
|
||||
!defined(MCU_MK52DZ10) /* DMAMUX */ && \
|
||||
!defined(MCU_MK53D10) /* DMAMUX */ && \
|
||||
!defined(MCU_MK53DZ10) /* DMAMUX */ && \
|
||||
!defined(MCU_MK60D10) /* DMAMUX */ && \
|
||||
!defined(MCU_MK60F12) /* DMAMUX0, DMAMUX1 */ && \
|
||||
!defined(MCU_MK60F15) /* DMAMUX0, DMAMUX1 */ && \
|
||||
!defined(MCU_MK60DZ10) /* DMAMUX */ && \
|
||||
!defined(MCU_MK60N512VMD100) /* DMAMUX */ && \
|
||||
!defined(MCU_MK61F12) /* DMAMUX0, DMAMUX1 */ && \
|
||||
!defined(MCU_MK61F15) /* DMAMUX0, DMAMUX1 */ && \
|
||||
!defined(MCU_MK61F12WS) /* DMAMUX0, DMAMUX1 */ && \
|
||||
!defined(MCU_MK61F15WS) /* DMAMUX0, DMAMUX1 */ && \
|
||||
!defined(MCU_MK63F12) /* DMAMUX */ && \
|
||||
!defined(MCU_MK63F12WS) /* DMAMUX */ && \
|
||||
!defined(MCU_MK64F12) /* DMAMUX */ && \
|
||||
!defined(MCU_MK65F18) /* DMAMUX */ && \
|
||||
!defined(MCU_MK65F18WS) /* DMAMUX */ && \
|
||||
!defined(MCU_MK66F18) /* DMAMUX */ && \
|
||||
!defined(MCU_MK70F12) /* DMAMUX0, DMAMUX1 */ && \
|
||||
!defined(MCU_MK70F15) /* DMAMUX0, DMAMUX1 */ && \
|
||||
!defined(MCU_MK70F12WS) /* DMAMUX0, DMAMUX1 */ && \
|
||||
!defined(MCU_MK70F15WS) /* DMAMUX0, DMAMUX1 */ && \
|
||||
!defined(MCU_MKL04Z4) /* DMAMUX0 */ && \
|
||||
!defined(MCU_MKL05Z4) /* DMAMUX0 */ && \
|
||||
!defined(MCU_MKL14Z4) /* DMAMUX0 */ && \
|
||||
!defined(MCU_MKL15Z4) /* DMAMUX0 */ && \
|
||||
!defined(MCU_MKL16Z4) /* DMAMUX0 */ && \
|
||||
!defined(MCU_MKL24Z4) /* DMAMUX0 */ && \
|
||||
!defined(MCU_MKL25Z4) /* DMAMUX0 */ && \
|
||||
!defined(MCU_MKL26Z4) /* DMAMUX0 */ && \
|
||||
!defined(MCU_MKL34Z4) /* DMAMUX0 */ && \
|
||||
!defined(MCU_MKL36Z4) /* DMAMUX0 */ && \
|
||||
!defined(MCU_MKL46Z4) /* DMAMUX0 */ && \
|
||||
!defined(MCU_MKV10Z7) /* DMAMUX */ && \
|
||||
!defined(MCU_MKV31F12810) /* DMAMUX */ && \
|
||||
!defined(MCU_MKV31F25612) /* DMAMUX */ && \
|
||||
!defined(MCU_MKV31F51212) /* DMAMUX */ && \
|
||||
!defined(MCU_MKW01Z4) /* DMAMUX0 */ && \
|
||||
!defined(MCU_MKW21D5) /* DMAMUX */ && \
|
||||
!defined(MCU_MKW21D5WS) /* DMAMUX */ && \
|
||||
!defined(MCU_MKW22D5) /* DMAMUX */ && \
|
||||
!defined(MCU_MKW22D5WS) /* DMAMUX */ && \
|
||||
!defined(MCU_MKW24D5) /* DMAMUX */ && \
|
||||
!defined(MCU_MKW24D5WS) /* DMAMUX */ && \
|
||||
!defined(MCU_PCK20L4) /* DMAMUX */
|
||||
// Unsupported MCU is active
|
||||
#error DMAMUX PDD library: Unsupported derivative is active.
|
||||
#endif
|
||||
|
||||
#include "PDD_Types.h"
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- Method symbol definitions
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/* Channel request source constants. */
|
||||
#define DMAMUX_PDD_CHANNEL_SOURCE_0 0U /**< Channel request source 0. */
|
||||
#define DMAMUX_PDD_CHANNEL_SOURCE_1 0x1U /**< Channel request source 1. */
|
||||
#define DMAMUX_PDD_CHANNEL_SOURCE_2 0x2U /**< Channel request source 2. */
|
||||
#define DMAMUX_PDD_CHANNEL_SOURCE_3 0x3U /**< Channel request source 3. */
|
||||
#define DMAMUX_PDD_CHANNEL_SOURCE_4 0x4U /**< Channel request source 4. */
|
||||
#define DMAMUX_PDD_CHANNEL_SOURCE_5 0x5U /**< Channel request source 5. */
|
||||
#define DMAMUX_PDD_CHANNEL_SOURCE_6 0x6U /**< Channel request source 6. */
|
||||
#define DMAMUX_PDD_CHANNEL_SOURCE_7 0x7U /**< Channel request source 7. */
|
||||
#define DMAMUX_PDD_CHANNEL_SOURCE_8 0x8U /**< Channel request source 8. */
|
||||
#define DMAMUX_PDD_CHANNEL_SOURCE_9 0x9U /**< Channel request source 9. */
|
||||
#define DMAMUX_PDD_CHANNEL_SOURCE_10 0xAU /**< Channel request source 10. */
|
||||
#define DMAMUX_PDD_CHANNEL_SOURCE_11 0xBU /**< Channel request source 11. */
|
||||
#define DMAMUX_PDD_CHANNEL_SOURCE_12 0xCU /**< Channel request source 12. */
|
||||
#define DMAMUX_PDD_CHANNEL_SOURCE_13 0xDU /**< Channel request source 13. */
|
||||
#define DMAMUX_PDD_CHANNEL_SOURCE_14 0xEU /**< Channel request source 14. */
|
||||
#define DMAMUX_PDD_CHANNEL_SOURCE_15 0xFU /**< Channel request source 15. */
|
||||
#define DMAMUX_PDD_CHANNEL_SOURCE_16 0x10U /**< Channel request source 16. */
|
||||
#define DMAMUX_PDD_CHANNEL_SOURCE_17 0x11U /**< Channel request source 17. */
|
||||
#define DMAMUX_PDD_CHANNEL_SOURCE_18 0x12U /**< Channel request source 18. */
|
||||
#define DMAMUX_PDD_CHANNEL_SOURCE_19 0x13U /**< Channel request source 19. */
|
||||
#define DMAMUX_PDD_CHANNEL_SOURCE_20 0x14U /**< Channel request source 20. */
|
||||
#define DMAMUX_PDD_CHANNEL_SOURCE_21 0x15U /**< Channel request source 21. */
|
||||
#define DMAMUX_PDD_CHANNEL_SOURCE_22 0x16U /**< Channel request source 22. */
|
||||
#define DMAMUX_PDD_CHANNEL_SOURCE_23 0x17U /**< Channel request source 23. */
|
||||
#define DMAMUX_PDD_CHANNEL_SOURCE_24 0x18U /**< Channel request source 24. */
|
||||
#define DMAMUX_PDD_CHANNEL_SOURCE_25 0x19U /**< Channel request source 25. */
|
||||
#define DMAMUX_PDD_CHANNEL_SOURCE_26 0x1AU /**< Channel request source 26. */
|
||||
#define DMAMUX_PDD_CHANNEL_SOURCE_27 0x1BU /**< Channel request source 27. */
|
||||
#define DMAMUX_PDD_CHANNEL_SOURCE_28 0x1CU /**< Channel request source 28. */
|
||||
#define DMAMUX_PDD_CHANNEL_SOURCE_29 0x1DU /**< Channel request source 29. */
|
||||
#define DMAMUX_PDD_CHANNEL_SOURCE_30 0x1EU /**< Channel request source 30. */
|
||||
#define DMAMUX_PDD_CHANNEL_SOURCE_31 0x1FU /**< Channel request source 31. */
|
||||
#define DMAMUX_PDD_CHANNEL_SOURCE_32 0x20U /**< Channel request source 32. */
|
||||
#define DMAMUX_PDD_CHANNEL_SOURCE_33 0x21U /**< Channel request source 33. */
|
||||
#define DMAMUX_PDD_CHANNEL_SOURCE_34 0x22U /**< Channel request source 34. */
|
||||
#define DMAMUX_PDD_CHANNEL_SOURCE_35 0x23U /**< Channel request source 35. */
|
||||
#define DMAMUX_PDD_CHANNEL_SOURCE_36 0x24U /**< Channel request source 36. */
|
||||
#define DMAMUX_PDD_CHANNEL_SOURCE_37 0x25U /**< Channel request source 37. */
|
||||
#define DMAMUX_PDD_CHANNEL_SOURCE_38 0x26U /**< Channel request source 38. */
|
||||
#define DMAMUX_PDD_CHANNEL_SOURCE_39 0x27U /**< Channel request source 39. */
|
||||
#define DMAMUX_PDD_CHANNEL_SOURCE_40 0x28U /**< Channel request source 40. */
|
||||
#define DMAMUX_PDD_CHANNEL_SOURCE_41 0x29U /**< Channel request source 41. */
|
||||
#define DMAMUX_PDD_CHANNEL_SOURCE_42 0x2AU /**< Channel request source 42. */
|
||||
#define DMAMUX_PDD_CHANNEL_SOURCE_43 0x2BU /**< Channel request source 43. */
|
||||
#define DMAMUX_PDD_CHANNEL_SOURCE_44 0x2CU /**< Channel request source 44. */
|
||||
#define DMAMUX_PDD_CHANNEL_SOURCE_45 0x2DU /**< Channel request source 45. */
|
||||
#define DMAMUX_PDD_CHANNEL_SOURCE_46 0x2EU /**< Channel request source 46. */
|
||||
#define DMAMUX_PDD_CHANNEL_SOURCE_47 0x2FU /**< Channel request source 47. */
|
||||
#define DMAMUX_PDD_CHANNEL_SOURCE_48 0x30U /**< Channel request source 48. */
|
||||
#define DMAMUX_PDD_CHANNEL_SOURCE_49 0x31U /**< Channel request source 49. */
|
||||
#define DMAMUX_PDD_CHANNEL_SOURCE_50 0x32U /**< Channel request source 50. */
|
||||
#define DMAMUX_PDD_CHANNEL_SOURCE_51 0x33U /**< Channel request source 51. */
|
||||
#define DMAMUX_PDD_CHANNEL_SOURCE_52 0x34U /**< Channel request source 52. */
|
||||
#define DMAMUX_PDD_CHANNEL_SOURCE_53 0x35U /**< Channel request source 53. */
|
||||
#define DMAMUX_PDD_CHANNEL_SOURCE_54 0x36U /**< Channel request source 54. */
|
||||
#define DMAMUX_PDD_CHANNEL_SOURCE_55 0x37U /**< Channel request source 55. */
|
||||
#define DMAMUX_PDD_CHANNEL_SOURCE_56 0x38U /**< Channel request source 56. */
|
||||
#define DMAMUX_PDD_CHANNEL_SOURCE_57 0x39U /**< Channel request source 57. */
|
||||
#define DMAMUX_PDD_CHANNEL_SOURCE_58 0x3AU /**< Channel request source 58. */
|
||||
#define DMAMUX_PDD_CHANNEL_SOURCE_59 0x3BU /**< Channel request source 59. */
|
||||
#define DMAMUX_PDD_CHANNEL_SOURCE_60 0x3CU /**< Channel request source 60. */
|
||||
#define DMAMUX_PDD_CHANNEL_SOURCE_61 0x3DU /**< Channel request source 61. */
|
||||
#define DMAMUX_PDD_CHANNEL_SOURCE_62 0x3EU /**< Channel request source 62. */
|
||||
#define DMAMUX_PDD_CHANNEL_SOURCE_63 0x3FU /**< Channel request source 63. */
|
||||
|
||||
/* Channel enabled bit mask */
|
||||
#define DMAMUX_PDD_CHANNEL_ENABLED DMAMUX_CHCFG_ENBL_MASK /**< Channel enabled bit mask */
|
||||
|
||||
/* Trigger enabled bit mask */
|
||||
#define DMAMUX_PDD_TRIGGER_ENABLED DMAMUX_CHCFG_TRIG_MASK /**< Trigger enabled bit mask */
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- WriteChannelConfigurationReg
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Writes to DMA MUX channel configuration register.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param Channel DMA channel number. This parameter is of index type.
|
||||
* @param Value DMA MUX channel configuration register value. This parameter is
|
||||
* a 8-bit value.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: CHCFG[Channel].
|
||||
* @par Example:
|
||||
* @code
|
||||
* DMAMUX_PDD_WriteChannelConfigurationReg(<peripheral>_BASE_PTR,
|
||||
* periphID, 1);
|
||||
* @endcode
|
||||
*/
|
||||
#define DMAMUX_PDD_WriteChannelConfigurationReg(PeripheralBase, Channel, Value) ( \
|
||||
DMAMUX_CHCFG_REG(PeripheralBase,(Channel)) = \
|
||||
(uint8)(Value) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- ReadChannelConfigurationReg
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Returns DMA MUX channel configuration register.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param Channel DMA channel number. This parameter is of index type.
|
||||
* @return Returns a 8-bit value.
|
||||
* @remarks The macro accesses the following registers: CHCFG[Channel].
|
||||
* @par Example:
|
||||
* @code
|
||||
* uint8 result =
|
||||
* DMAMUX_PDD_ReadChannelConfigurationReg(<peripheral>_BASE_PTR, periphID);
|
||||
* @endcode
|
||||
*/
|
||||
#define DMAMUX_PDD_ReadChannelConfigurationReg(PeripheralBase, Channel) ( \
|
||||
DMAMUX_CHCFG_REG(PeripheralBase,(Channel)) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- EnableChannel
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Enables or disables DMA MUX channel.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param Channel DMA channel number. This parameter is of index type.
|
||||
* @param State Parameter specifying if DMA MUX channel will be enabled or
|
||||
* disabled. This parameter is of "Global enumeration used for specifying
|
||||
* general enable/disable states (PDD_DISABLE and PDD_ENABLE defined in
|
||||
* PDD_Types.h)" type.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: CHCFG[Channel].
|
||||
* @par Example:
|
||||
* @code
|
||||
* DMAMUX_PDD_EnableChannel(<peripheral>_BASE_PTR, periphID, PDD_DISABLE);
|
||||
* @endcode
|
||||
*/
|
||||
#define DMAMUX_PDD_EnableChannel(PeripheralBase, Channel, State) ( \
|
||||
DMAMUX_CHCFG_REG(PeripheralBase,(Channel)) = \
|
||||
(uint8)(( \
|
||||
(uint8)(( \
|
||||
DMAMUX_CHCFG_REG(PeripheralBase,(Channel))) & ( \
|
||||
(uint8)(~(uint8)DMAMUX_CHCFG_ENBL_MASK)))) | ( \
|
||||
(uint8)((uint8)(State) << DMAMUX_CHCFG_ENBL_SHIFT))) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- GetChannelEnabled
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Returns DMA MUX channel state.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param Channel DMA channel number. This parameter is of index type.
|
||||
* @return Returns a 8-bit value.
|
||||
* @remarks The macro accesses the following registers: CHCFG[Channel].
|
||||
* @par Example:
|
||||
* @code
|
||||
* uint8 result = DMAMUX_PDD_GetChannelEnabled(<peripheral>_BASE_PTR,
|
||||
* periphID);
|
||||
* @endcode
|
||||
*/
|
||||
#define DMAMUX_PDD_GetChannelEnabled(PeripheralBase, Channel) ( \
|
||||
(uint8)(DMAMUX_CHCFG_REG(PeripheralBase,(Channel)) & DMAMUX_CHCFG_ENBL_MASK) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- EnableTrigger
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Enables or disables DMA MUX channel triggering.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param Channel DMA channel number. This parameter is of index type.
|
||||
* @param State Parameter specifying if DMA MUX channel triggering will be
|
||||
* enabled or disabled. This parameter is of "Global enumeration used for
|
||||
* specifying general enable/disable states (PDD_DISABLE and PDD_ENABLE defined
|
||||
* in PDD_Types.h)" type.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: CHCFG[Channel].
|
||||
* @par Example:
|
||||
* @code
|
||||
* DMAMUX_PDD_EnableTrigger(<peripheral>_BASE_PTR, periphID, PDD_DISABLE);
|
||||
* @endcode
|
||||
*/
|
||||
#define DMAMUX_PDD_EnableTrigger(PeripheralBase, Channel, State) ( \
|
||||
DMAMUX_CHCFG_REG(PeripheralBase,(Channel)) = \
|
||||
(uint8)(( \
|
||||
(uint8)(( \
|
||||
DMAMUX_CHCFG_REG(PeripheralBase,(Channel))) & ( \
|
||||
(uint8)(~(uint8)DMAMUX_CHCFG_TRIG_MASK)))) | ( \
|
||||
(uint8)((uint8)(State) << DMAMUX_CHCFG_TRIG_SHIFT))) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- GetTriggerEnabled
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Returns DMA MUX channel triggering state.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param Channel DMA channel number. This parameter is of index type.
|
||||
* @return Returns a 8-bit value.
|
||||
* @remarks The macro accesses the following registers: CHCFG[Channel].
|
||||
* @par Example:
|
||||
* @code
|
||||
* uint8 result = DMAMUX_PDD_GetTriggerEnabled(<peripheral>_BASE_PTR,
|
||||
* periphID);
|
||||
* @endcode
|
||||
*/
|
||||
#define DMAMUX_PDD_GetTriggerEnabled(PeripheralBase, Channel) ( \
|
||||
(uint8)(DMAMUX_CHCFG_REG(PeripheralBase,(Channel)) & DMAMUX_CHCFG_TRIG_MASK) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- SetChannelSource
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Sets DMA channels source.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param Channel DMA channel number. This parameter is of index type.
|
||||
* @param ChannelSource DMA channel source number. This parameter is a 6-bit
|
||||
* value.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: CHCFG[Channel].
|
||||
* @par Example:
|
||||
* @code
|
||||
* DMAMUX_PDD_SetChannelSource(<peripheral>_BASE_PTR, periphID, 1);
|
||||
* @endcode
|
||||
*/
|
||||
#define DMAMUX_PDD_SetChannelSource(PeripheralBase, Channel, ChannelSource) ( \
|
||||
DMAMUX_CHCFG_REG(PeripheralBase,(Channel)) = \
|
||||
(uint8)(( \
|
||||
(uint8)(( \
|
||||
DMAMUX_CHCFG_REG(PeripheralBase,(Channel))) & ( \
|
||||
(uint8)(~(uint8)DMAMUX_CHCFG_SOURCE_MASK)))) | ( \
|
||||
(uint8)(ChannelSource))) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- GetChannelSource
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Returns mask of enabled DMA channels requests.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param Channel DMA channel number. This parameter is of index type.
|
||||
* @return Returns a 6-bit value. The value is cast to "uint8".
|
||||
* @remarks The macro accesses the following registers: CHCFG[Channel].
|
||||
* @par Example:
|
||||
* @code
|
||||
* uint8 result = DMAMUX_PDD_GetChannelSource(<peripheral>_BASE_PTR,
|
||||
* periphID);
|
||||
* @endcode
|
||||
*/
|
||||
#define DMAMUX_PDD_GetChannelSource(PeripheralBase, Channel) ( \
|
||||
(uint8)(DMAMUX_CHCFG_REG(PeripheralBase,(Channel)) & DMAMUX_CHCFG_SOURCE_MASK) \
|
||||
)
|
||||
#endif /* #if defined(DMAMUX_PDD_H_) */
|
||||
|
||||
/* DMAMUX_PDD.h, eof. */
|
||||
7966
Clean_TMC2209/lib/tmc/hal/Landungsbruecke/freescale/PDD/DMA_PDD.h
Normal file
7966
Clean_TMC2209/lib/tmc/hal/Landungsbruecke/freescale/PDD/DMA_PDD.h
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,490 @@
|
||||
/*
|
||||
PDD layer implementation for peripheral type EWM
|
||||
(C) 2013 Freescale, Inc. All rights reserved.
|
||||
|
||||
This file is static and it is generated from API-Factory
|
||||
*/
|
||||
|
||||
#if !defined(EWM_PDD_H_)
|
||||
#define EWM_PDD_H_
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- Test if supported MCU is active
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
#if !defined(MCU_ACTIVE)
|
||||
// No MCU is active
|
||||
#error EWM PDD library: No derivative is active. Place proper #include with PDD memory map before including PDD library.
|
||||
#elif \
|
||||
!defined(MCU_MK10D10) /* EWM */ && \
|
||||
!defined(MCU_MK10D5) /* EWM */ && \
|
||||
!defined(MCU_MK10D7) /* EWM */ && \
|
||||
!defined(MCU_MK10F12) /* EWM */ && \
|
||||
!defined(MCU_MK10DZ10) /* EWM */ && \
|
||||
!defined(MCU_MK11D5) /* EWM */ && \
|
||||
!defined(MCU_MK11D5WS) /* EWM */ && \
|
||||
!defined(MCU_MK12D5) /* EWM */ && \
|
||||
!defined(MCU_MK20D10) /* EWM */ && \
|
||||
!defined(MCU_MK20D5) /* EWM */ && \
|
||||
!defined(MCU_MK20D7) /* EWM */ && \
|
||||
!defined(MCU_MK20F12) /* EWM */ && \
|
||||
!defined(MCU_MK20DZ10) /* EWM */ && \
|
||||
!defined(MCU_MK21D5) /* EWM */ && \
|
||||
!defined(MCU_MK21D5WS) /* EWM */ && \
|
||||
!defined(MCU_MK21F12) /* EWM */ && \
|
||||
!defined(MCU_MK21F12WS) /* EWM */ && \
|
||||
!defined(MCU_MK22D5) /* EWM */ && \
|
||||
!defined(MCU_MK22F12810) /* EWM */ && \
|
||||
!defined(MCU_MK22F12) /* EWM */ && \
|
||||
!defined(MCU_MK22F25612) /* EWM */ && \
|
||||
!defined(MCU_MK22F51212) /* EWM */ && \
|
||||
!defined(MCU_MK24F12) /* EWM */ && \
|
||||
!defined(MCU_MK30D10) /* EWM */ && \
|
||||
!defined(MCU_MK30D7) /* EWM */ && \
|
||||
!defined(MCU_MK30DZ10) /* EWM */ && \
|
||||
!defined(MCU_MK40D10) /* EWM */ && \
|
||||
!defined(MCU_MK40D7) /* EWM */ && \
|
||||
!defined(MCU_MK40DZ10) /* EWM */ && \
|
||||
!defined(MCU_MK40X256VMD100) /* EWM */ && \
|
||||
!defined(MCU_MK50D10) /* EWM */ && \
|
||||
!defined(MCU_MK50D7) /* EWM */ && \
|
||||
!defined(MCU_MK50DZ10) /* EWM */ && \
|
||||
!defined(MCU_MK51D10) /* EWM */ && \
|
||||
!defined(MCU_MK51D7) /* EWM */ && \
|
||||
!defined(MCU_MK51DZ10) /* EWM */ && \
|
||||
!defined(MCU_MK52D10) /* EWM */ && \
|
||||
!defined(MCU_MK52DZ10) /* EWM */ && \
|
||||
!defined(MCU_MK53D10) /* EWM */ && \
|
||||
!defined(MCU_MK53DZ10) /* EWM */ && \
|
||||
!defined(MCU_MK60D10) /* EWM */ && \
|
||||
!defined(MCU_MK60F12) /* EWM */ && \
|
||||
!defined(MCU_MK60F15) /* EWM */ && \
|
||||
!defined(MCU_MK60DZ10) /* EWM */ && \
|
||||
!defined(MCU_MK60N512VMD100) /* EWM */ && \
|
||||
!defined(MCU_MK61F12) /* EWM */ && \
|
||||
!defined(MCU_MK61F15) /* EWM */ && \
|
||||
!defined(MCU_MK61F12WS) /* EWM */ && \
|
||||
!defined(MCU_MK61F15WS) /* EWM */ && \
|
||||
!defined(MCU_MK63F12) /* EWM */ && \
|
||||
!defined(MCU_MK63F12WS) /* EWM */ && \
|
||||
!defined(MCU_MK64F12) /* EWM */ && \
|
||||
!defined(MCU_MK65F18) /* EWM */ && \
|
||||
!defined(MCU_MK65F18WS) /* EWM */ && \
|
||||
!defined(MCU_MK66F18) /* EWM */ && \
|
||||
!defined(MCU_MK70F12) /* EWM */ && \
|
||||
!defined(MCU_MK70F15) /* EWM */ && \
|
||||
!defined(MCU_MK70F12WS) /* EWM */ && \
|
||||
!defined(MCU_MK70F15WS) /* EWM */ && \
|
||||
!defined(MCU_MKV10Z7) /* EWM */ && \
|
||||
!defined(MCU_MKV31F12810) /* EWM */ && \
|
||||
!defined(MCU_MKV31F25612) /* EWM */ && \
|
||||
!defined(MCU_MKV31F51212) /* EWM */ && \
|
||||
!defined(MCU_MKW21D5) /* EWM */ && \
|
||||
!defined(MCU_MKW21D5WS) /* EWM */ && \
|
||||
!defined(MCU_MKW22D5) /* EWM */ && \
|
||||
!defined(MCU_MKW22D5WS) /* EWM */ && \
|
||||
!defined(MCU_MKW24D5) /* EWM */ && \
|
||||
!defined(MCU_MKW24D5WS) /* EWM */ && \
|
||||
!defined(MCU_PCK20L4) /* EWM */
|
||||
// Unsupported MCU is active
|
||||
#error EWM PDD library: Unsupported derivative is active.
|
||||
#endif
|
||||
|
||||
#include "PDD_Types.h"
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- Method symbol definitions
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/* Service constants */
|
||||
#define EWM_PDD_KEY_1 0xB4U /**< First key */
|
||||
#define EWM_PDD_KEY_2 0x2CU /**< Second key */
|
||||
|
||||
/* Clock source constants. */
|
||||
#define EWM_PDD_SOURCE_ROSC_8M 0U /**< Relaxation oscillator clock */
|
||||
#define EWM_PDD_SOURCE_XTAL_OSC 0x1U /**< Crystal oscillator clock */
|
||||
#define EWM_PDD_SOURCE_BUS_CLK 0x2U /**< IP bus clock */
|
||||
#define EWM_PDD_SOURCE_ROSC_200K 0x3U /**< Low speed oscillator clock */
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- WriteControlReg
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Writes value to the control register.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param Value New content of the control register. This parameter is a 8-bit
|
||||
* value.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: EWM_CTRL.
|
||||
* @par Example:
|
||||
* @code
|
||||
* EWM_PDD_WriteControlReg(<peripheral>_BASE_PTR, 1);
|
||||
* @endcode
|
||||
*/
|
||||
#define EWM_PDD_WriteControlReg(PeripheralBase, Value) ( \
|
||||
EWM_CTRL_REG(PeripheralBase) = \
|
||||
(uint8)(Value) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- GetEnableDeviceStatus
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Returns current state of EWM device.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a 8-bit value.
|
||||
* @remarks The macro accesses the following registers: EWM_CTRL.
|
||||
* @par Example:
|
||||
* @code
|
||||
* uint8 result = EWM_PDD_GetEnableDeviceStatus(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define EWM_PDD_GetEnableDeviceStatus(PeripheralBase) ( \
|
||||
(uint8)(EWM_CTRL_REG(PeripheralBase) & EWM_CTRL_EWMEN_MASK) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- WriteCompareLowReg
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Writes value to the compare low register.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param Value New content of the compare low register. This parameter is a
|
||||
* 8-bit value.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: EWM_CMPL.
|
||||
* @par Example:
|
||||
* @code
|
||||
* EWM_PDD_WriteCompareLowReg(<peripheral>_BASE_PTR, 1);
|
||||
* @endcode
|
||||
*/
|
||||
#define EWM_PDD_WriteCompareLowReg(PeripheralBase, Value) ( \
|
||||
EWM_CMPL_REG(PeripheralBase) = \
|
||||
(uint8)(Value) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- ReadCompareLowReg
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Returns the content of the compare low register.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a 8-bit value.
|
||||
* @remarks The macro accesses the following registers: EWM_CMPL.
|
||||
* @par Example:
|
||||
* @code
|
||||
* uint8 result = EWM_PDD_ReadCompareLowReg(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define EWM_PDD_ReadCompareLowReg(PeripheralBase) ( \
|
||||
EWM_CMPL_REG(PeripheralBase) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- WriteCompareHighReg
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Writes value to the compare high register.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param Value New content of the compare high register. This parameter is a
|
||||
* 8-bit value.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: EWM_CMPH.
|
||||
* @par Example:
|
||||
* @code
|
||||
* EWM_PDD_WriteCompareHighReg(<peripheral>_BASE_PTR, 1);
|
||||
* @endcode
|
||||
*/
|
||||
#define EWM_PDD_WriteCompareHighReg(PeripheralBase, Value) ( \
|
||||
EWM_CMPH_REG(PeripheralBase) = \
|
||||
(uint8)(Value) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- ReadCompareHighReg
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Returns the content of the compare high register.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a 8-bit value.
|
||||
* @remarks The macro accesses the following registers: EWM_CMPH.
|
||||
* @par Example:
|
||||
* @code
|
||||
* uint8 result = EWM_PDD_ReadCompareHighReg(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define EWM_PDD_ReadCompareHighReg(PeripheralBase) ( \
|
||||
EWM_CMPH_REG(PeripheralBase) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- WriteServiceReg
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Writes value to the service register.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param Value Service constant. This parameter is a 8-bit value.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: EWM_SERV.
|
||||
* @par Example:
|
||||
* @code
|
||||
* EWM_PDD_WriteServiceReg(<peripheral>_BASE_PTR, 1);
|
||||
* @endcode
|
||||
*/
|
||||
#define EWM_PDD_WriteServiceReg(PeripheralBase, Value) ( \
|
||||
EWM_SERV_REG(PeripheralBase) = \
|
||||
(uint8)(Value) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- DisableInterrupt
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Disables the EWM interrupt.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: EWM_CTRL.
|
||||
* @par Example:
|
||||
* @code
|
||||
* EWM_PDD_DisableInterrupt(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define EWM_PDD_DisableInterrupt(PeripheralBase) ( \
|
||||
EWM_CTRL_REG(PeripheralBase) &= \
|
||||
(uint8)(~(uint8)EWM_CTRL_INTEN_MASK) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- EnableInterrupt
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Enables the EWM interrupt.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: EWM_CTRL.
|
||||
* @par Example:
|
||||
* @code
|
||||
* EWM_PDD_EnableInterrupt(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define EWM_PDD_EnableInterrupt(PeripheralBase) ( \
|
||||
EWM_CTRL_REG(PeripheralBase) |= \
|
||||
EWM_CTRL_INTEN_MASK \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- SelectClockSource
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Selects clock source.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param Source New value of the source. This parameter is of "Clock source
|
||||
* constants." type.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: EWM_CLKCTRL.
|
||||
* @par Example:
|
||||
* @code
|
||||
* EWM_PDD_SelectClockSource(<peripheral>_BASE_PTR,
|
||||
* EWM_PDD_SOURCE_ROSC_8M);
|
||||
* @endcode
|
||||
*/
|
||||
#define EWM_PDD_SelectClockSource(PeripheralBase, Source) ( \
|
||||
EWM_CLKCTRL_REG(PeripheralBase) = \
|
||||
(uint8)(( \
|
||||
(uint8)(EWM_CLKCTRL_REG(PeripheralBase) & (uint8)(~(uint8)EWM_CLKCTRL_CLKSEL_MASK))) | ( \
|
||||
(uint8)(Source))) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- SetPrescaler
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Sets prescale value.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param Value New value of the prescaler. This parameter is a 8-bit value.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: EWM_CLKPRESCALER.
|
||||
* @par Example:
|
||||
* @code
|
||||
* EWM_PDD_SetPrescaler(<peripheral>_BASE_PTR, 1);
|
||||
* @endcode
|
||||
*/
|
||||
#define EWM_PDD_SetPrescaler(PeripheralBase, Value) ( \
|
||||
EWM_CLKPRESCALER_REG(PeripheralBase) = \
|
||||
(uint8)(Value) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- ReadControlReg
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Returns the content of the control register.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a 8-bit value.
|
||||
* @remarks The macro accesses the following registers: EWM_CTRL.
|
||||
* @par Example:
|
||||
* @code
|
||||
* uint8 result = EWM_PDD_ReadControlReg(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define EWM_PDD_ReadControlReg(PeripheralBase) ( \
|
||||
EWM_CTRL_REG(PeripheralBase) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- WriteClockControlReg
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Writes value to the clock control register.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param Value New content of the clock control register. This parameter is a
|
||||
* 8-bit value.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: EWM_CLKCTRL.
|
||||
* @par Example:
|
||||
* @code
|
||||
* EWM_PDD_WriteClockControlReg(<peripheral>_BASE_PTR, 1);
|
||||
* @endcode
|
||||
*/
|
||||
#define EWM_PDD_WriteClockControlReg(PeripheralBase, Value) ( \
|
||||
EWM_CLKCTRL_REG(PeripheralBase) = \
|
||||
(uint8)(Value) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- ReadClockControlReg
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Returns the content of the clock control register.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a 8-bit value.
|
||||
* @remarks The macro accesses the following registers: EWM_CLKCTRL.
|
||||
* @par Example:
|
||||
* @code
|
||||
* uint8 result = EWM_PDD_ReadClockControlReg(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define EWM_PDD_ReadClockControlReg(PeripheralBase) ( \
|
||||
EWM_CLKCTRL_REG(PeripheralBase) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- WriteClockPrescalerReg
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Writes value to the clock prescaler register.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param Value New content of the clock prescaler register. This parameter is a
|
||||
* 8-bit value.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: EWM_CLKPRESCALER.
|
||||
* @par Example:
|
||||
* @code
|
||||
* EWM_PDD_WriteClockPrescalerReg(<peripheral>_BASE_PTR, 1);
|
||||
* @endcode
|
||||
*/
|
||||
#define EWM_PDD_WriteClockPrescalerReg(PeripheralBase, Value) ( \
|
||||
EWM_CLKPRESCALER_REG(PeripheralBase) = \
|
||||
(uint8)(Value) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- ReadClockPrescalerReg
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Returns the content of the clock prescaler register.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a 8-bit value.
|
||||
* @remarks The macro accesses the following registers: EWM_CLKPRESCALER.
|
||||
* @par Example:
|
||||
* @code
|
||||
* uint8 result = EWM_PDD_ReadClockPrescalerReg(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define EWM_PDD_ReadClockPrescalerReg(PeripheralBase) ( \
|
||||
EWM_CLKPRESCALER_REG(PeripheralBase) \
|
||||
)
|
||||
#endif /* #if defined(EWM_PDD_H_) */
|
||||
|
||||
/* EWM_PDD.h, eof. */
|
||||
1244
Clean_TMC2209/lib/tmc/hal/Landungsbruecke/freescale/PDD/FMC_PDD.h
Normal file
1244
Clean_TMC2209/lib/tmc/hal/Landungsbruecke/freescale/PDD/FMC_PDD.h
Normal file
File diff suppressed because it is too large
Load Diff
3215
Clean_TMC2209/lib/tmc/hal/Landungsbruecke/freescale/PDD/FTFL_PDD.h
Normal file
3215
Clean_TMC2209/lib/tmc/hal/Landungsbruecke/freescale/PDD/FTFL_PDD.h
Normal file
File diff suppressed because it is too large
Load Diff
5072
Clean_TMC2209/lib/tmc/hal/Landungsbruecke/freescale/PDD/FTM_PDD.h
Normal file
5072
Clean_TMC2209/lib/tmc/hal/Landungsbruecke/freescale/PDD/FTM_PDD.h
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,516 @@
|
||||
/*
|
||||
PDD layer implementation for peripheral type GPIO
|
||||
(C) 2013 Freescale, Inc. All rights reserved.
|
||||
|
||||
This file is static and it is generated from API-Factory
|
||||
*/
|
||||
|
||||
#if !defined(GPIO_PDD_H_)
|
||||
#define GPIO_PDD_H_
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- Test if supported MCU is active
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
#if !defined(MCU_ACTIVE)
|
||||
// No MCU is active
|
||||
#error GPIO PDD library: No derivative is active. Place proper #include with PDD memory map before including PDD library.
|
||||
#elif \
|
||||
!defined(MCU_MK10D10) /* PTA, PTB, PTC, PTD, PTE */ && \
|
||||
!defined(MCU_MK10D5) /* PTA, PTB, PTC, PTD, PTE */ && \
|
||||
!defined(MCU_MK10D7) /* PTA, PTB, PTC, PTD, PTE */ && \
|
||||
!defined(MCU_MK10F12) /* PTA, PTB, PTC, PTD, PTE, PTF */ && \
|
||||
!defined(MCU_MK10DZ10) /* PTA, PTB, PTC, PTD, PTE */ && \
|
||||
!defined(MCU_MK11D5) /* PTA, PTB, PTC, PTD, PTE */ && \
|
||||
!defined(MCU_MK11D5WS) /* PTA, PTB, PTC, PTD, PTE */ && \
|
||||
!defined(MCU_MK12D5) /* PTA, PTB, PTC, PTD, PTE */ && \
|
||||
!defined(MCU_MK20D10) /* PTA, PTB, PTC, PTD, PTE */ && \
|
||||
!defined(MCU_MK20D5) /* PTA, PTB, PTC, PTD, PTE */ && \
|
||||
!defined(MCU_MK20D7) /* PTA, PTB, PTC, PTD, PTE */ && \
|
||||
!defined(MCU_MK20F12) /* PTA, PTB, PTC, PTD, PTE, PTF */ && \
|
||||
!defined(MCU_MK20DZ10) /* PTA, PTB, PTC, PTD, PTE */ && \
|
||||
!defined(MCU_MK21D5) /* PTA, PTB, PTC, PTD, PTE */ && \
|
||||
!defined(MCU_MK21D5WS) /* PTA, PTB, PTC, PTD, PTE */ && \
|
||||
!defined(MCU_MK21F12) /* PTA, PTB, PTC, PTD, PTE */ && \
|
||||
!defined(MCU_MK21F12WS) /* PTA, PTB, PTC, PTD, PTE */ && \
|
||||
!defined(MCU_MK22D5) /* PTA, PTB, PTC, PTD, PTE */ && \
|
||||
!defined(MCU_MK22F12810) /* PTA, PTB, PTC, PTD, PTE */ && \
|
||||
!defined(MCU_MK22F12) /* PTA, PTB, PTC, PTD, PTE */ && \
|
||||
!defined(MCU_MK22F25612) /* PTA, PTB, PTC, PTD, PTE */ && \
|
||||
!defined(MCU_MK22F51212) /* PTA, PTB, PTC, PTD, PTE */ && \
|
||||
!defined(MCU_MK24F12) /* PTA, PTB, PTC, PTD, PTE */ && \
|
||||
!defined(MCU_MK30D10) /* PTA, PTB, PTC, PTD, PTE */ && \
|
||||
!defined(MCU_MK30D7) /* PTA, PTB, PTC, PTD, PTE */ && \
|
||||
!defined(MCU_MK30DZ10) /* PTA, PTB, PTC, PTD, PTE */ && \
|
||||
!defined(MCU_MK40D10) /* PTA, PTB, PTC, PTD, PTE */ && \
|
||||
!defined(MCU_MK40D7) /* PTA, PTB, PTC, PTD, PTE */ && \
|
||||
!defined(MCU_MK40DZ10) /* PTA, PTB, PTC, PTD, PTE */ && \
|
||||
!defined(MCU_MK40X256VMD100) /* PTA, PTB, PTC, PTD, PTE */ && \
|
||||
!defined(MCU_MK50D10) /* PTA, PTB, PTC, PTD, PTE */ && \
|
||||
!defined(MCU_MK50D7) /* PTA, PTB, PTC, PTD, PTE */ && \
|
||||
!defined(MCU_MK50DZ10) /* PTA, PTB, PTC, PTD, PTE */ && \
|
||||
!defined(MCU_MK51D10) /* PTA, PTB, PTC, PTD, PTE */ && \
|
||||
!defined(MCU_MK51D7) /* PTA, PTB, PTC, PTD, PTE */ && \
|
||||
!defined(MCU_MK51DZ10) /* PTA, PTB, PTC, PTD, PTE */ && \
|
||||
!defined(MCU_MK52D10) /* PTA, PTB, PTC, PTD, PTE */ && \
|
||||
!defined(MCU_MK52DZ10) /* PTA, PTB, PTC, PTD, PTE */ && \
|
||||
!defined(MCU_MK53D10) /* PTA, PTB, PTC, PTD, PTE */ && \
|
||||
!defined(MCU_MK53DZ10) /* PTA, PTB, PTC, PTD, PTE */ && \
|
||||
!defined(MCU_MK60D10) /* PTA, PTB, PTC, PTD, PTE */ && \
|
||||
!defined(MCU_MK60F12) /* PTA, PTB, PTC, PTD, PTE, PTF */ && \
|
||||
!defined(MCU_MK60F15) /* PTA, PTB, PTC, PTD, PTE, PTF */ && \
|
||||
!defined(MCU_MK60DZ10) /* PTA, PTB, PTC, PTD, PTE */ && \
|
||||
!defined(MCU_MK60N512VMD100) /* PTA, PTB, PTC, PTD, PTE */ && \
|
||||
!defined(MCU_MK61F12) /* PTA, PTB, PTC, PTD, PTE, PTF */ && \
|
||||
!defined(MCU_MK61F15) /* PTA, PTB, PTC, PTD, PTE, PTF */ && \
|
||||
!defined(MCU_MK61F12WS) /* PTA, PTB, PTC, PTD, PTE, PTF */ && \
|
||||
!defined(MCU_MK61F15WS) /* PTA, PTB, PTC, PTD, PTE, PTF */ && \
|
||||
!defined(MCU_MK63F12) /* PTA, PTB, PTC, PTD, PTE */ && \
|
||||
!defined(MCU_MK63F12WS) /* PTA, PTB, PTC, PTD, PTE */ && \
|
||||
!defined(MCU_MK64F12) /* PTA, PTB, PTC, PTD, PTE */ && \
|
||||
!defined(MCU_MK65F18) /* PTA, PTB, PTC, PTD, PTE */ && \
|
||||
!defined(MCU_MK65F18WS) /* PTA, PTB, PTC, PTD, PTE */ && \
|
||||
!defined(MCU_MK66F18) /* PTA, PTB, PTC, PTD, PTE */ && \
|
||||
!defined(MCU_MK70F12) /* PTA, PTB, PTC, PTD, PTE, PTF */ && \
|
||||
!defined(MCU_MK70F15) /* PTA, PTB, PTC, PTD, PTE, PTF */ && \
|
||||
!defined(MCU_MK70F12WS) /* PTA, PTB, PTC, PTD, PTE, PTF */ && \
|
||||
!defined(MCU_MK70F15WS) /* PTA, PTB, PTC, PTD, PTE, PTF */ && \
|
||||
!defined(MCU_MKE02Z2) /* GPIOA, GPIOB */ && \
|
||||
!defined(MCU_MKE02Z4) /* GPIOA, GPIOB */ && \
|
||||
!defined(MCU_SKEAZN642) /* GPIOA, GPIOB */ && \
|
||||
!defined(MCU_MKE04Z1284) /* GPIOA, GPIOB, GPIOC */ && \
|
||||
!defined(MCU_MKE04Z4) /* GPIOA */ && \
|
||||
!defined(MCU_SKEAZN84) /* GPIOA */ && \
|
||||
!defined(MCU_MKE06Z4) /* GPIOA, GPIOB, GPIOC */ && \
|
||||
!defined(MCU_MKL02Z4) /* PTA, PTB */ && \
|
||||
!defined(MCU_MKL03Z4) /* PTA, PTB */ && \
|
||||
!defined(MCU_MKL04Z4) /* PTA, PTB */ && \
|
||||
!defined(MCU_MKL05Z4) /* PTA, PTB */ && \
|
||||
!defined(MCU_MKL14Z4) /* PTA, PTB, PTC, PTD, PTE */ && \
|
||||
!defined(MCU_MKL15Z4) /* PTA, PTB, PTC, PTD, PTE */ && \
|
||||
!defined(MCU_MKL16Z4) /* PTA, PTB, PTC, PTD, PTE */ && \
|
||||
!defined(MCU_MKL24Z4) /* PTA, PTB, PTC, PTD, PTE */ && \
|
||||
!defined(MCU_MKL25Z4) /* PTA, PTB, PTC, PTD, PTE */ && \
|
||||
!defined(MCU_MKL26Z4) /* PTA, PTB, PTC, PTD, PTE */ && \
|
||||
!defined(MCU_MKL34Z4) /* PTA, PTB, PTC, PTD, PTE */ && \
|
||||
!defined(MCU_MKL36Z4) /* PTA, PTB, PTC, PTD, PTE */ && \
|
||||
!defined(MCU_MKL46Z4) /* PTA, PTB, PTC, PTD, PTE */ && \
|
||||
!defined(MCU_MKV10Z7) /* GPIOA, GPIOB, GPIOC, GPIOD, GPIOE */ && \
|
||||
!defined(MCU_MKV31F12810) /* PTA, PTB, PTC, PTD, PTE */ && \
|
||||
!defined(MCU_MKV31F25612) /* PTA, PTB, PTC, PTD, PTE */ && \
|
||||
!defined(MCU_MKV31F51212) /* PTA, PTB, PTC, PTD, PTE */ && \
|
||||
!defined(MCU_MKW01Z4) /* GPIOA, GPIOB, GPIOC, GPIOD, GPIOE */ && \
|
||||
!defined(MCU_MKW21D5) /* GPIOA, GPIOB, GPIOC, GPIOD, GPIOE */ && \
|
||||
!defined(MCU_MKW21D5WS) /* GPIOA, GPIOB, GPIOC, GPIOD, GPIOE */ && \
|
||||
!defined(MCU_MKW22D5) /* GPIOA, GPIOB, GPIOC, GPIOD, GPIOE */ && \
|
||||
!defined(MCU_MKW22D5WS) /* GPIOA, GPIOB, GPIOC, GPIOD, GPIOE */ && \
|
||||
!defined(MCU_MKW24D5) /* GPIOA, GPIOB, GPIOC, GPIOD, GPIOE */ && \
|
||||
!defined(MCU_MKW24D5WS) /* GPIOA, GPIOB, GPIOC, GPIOD, GPIOE */ && \
|
||||
!defined(MCU_PCK20L4) /* PTA, PTB, PTC, PTD, PTE */ && \
|
||||
!defined(MCU_SKEAZ1284) /* GPIOA, GPIOB, GPIOC */
|
||||
// Unsupported MCU is active
|
||||
#error GPIO PDD library: Unsupported derivative is active.
|
||||
#endif
|
||||
|
||||
//#include "PDD_Types.h"
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- Method symbol definitions
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/* Pin masks */
|
||||
#define GPIO_PDD_PIN_0 0x1U /**< Pin 0 mask */
|
||||
#define GPIO_PDD_PIN_1 0x2U /**< Pin 1 mask */
|
||||
#define GPIO_PDD_PIN_2 0x4U /**< Pin 2 mask */
|
||||
#define GPIO_PDD_PIN_3 0x8U /**< Pin 3 mask */
|
||||
#define GPIO_PDD_PIN_4 0x10U /**< Pin 4 mask */
|
||||
#define GPIO_PDD_PIN_5 0x20U /**< Pin 5 mask */
|
||||
#define GPIO_PDD_PIN_6 0x40U /**< Pin 6 mask */
|
||||
#define GPIO_PDD_PIN_7 0x80U /**< Pin 7 mask */
|
||||
#define GPIO_PDD_PIN_8 0x100U /**< Pin 8 mask */
|
||||
#define GPIO_PDD_PIN_9 0x200U /**< Pin 9 mask */
|
||||
#define GPIO_PDD_PIN_10 0x400U /**< Pin 10 mask */
|
||||
#define GPIO_PDD_PIN_11 0x800U /**< Pin 11 mask */
|
||||
#define GPIO_PDD_PIN_12 0x1000U /**< Pin 12 mask */
|
||||
#define GPIO_PDD_PIN_13 0x2000U /**< Pin 13 mask */
|
||||
#define GPIO_PDD_PIN_14 0x4000U /**< Pin 14 mask */
|
||||
#define GPIO_PDD_PIN_15 0x8000U /**< Pin 15 mask */
|
||||
#define GPIO_PDD_PIN_16 0x10000U /**< Pin 16 mask */
|
||||
#define GPIO_PDD_PIN_17 0x20000U /**< Pin 17 mask */
|
||||
#define GPIO_PDD_PIN_18 0x40000U /**< Pin 18 mask */
|
||||
#define GPIO_PDD_PIN_19 0x80000U /**< Pin 19 mask */
|
||||
#define GPIO_PDD_PIN_20 0x100000U /**< Pin 20 mask */
|
||||
#define GPIO_PDD_PIN_21 0x200000U /**< Pin 21 mask */
|
||||
#define GPIO_PDD_PIN_22 0x400000U /**< Pin 22 mask */
|
||||
#define GPIO_PDD_PIN_23 0x800000U /**< Pin 23 mask */
|
||||
#define GPIO_PDD_PIN_24 0x1000000U /**< Pin 24 mask */
|
||||
#define GPIO_PDD_PIN_25 0x2000000U /**< Pin 25 mask */
|
||||
#define GPIO_PDD_PIN_26 0x4000000U /**< Pin 26 mask */
|
||||
#define GPIO_PDD_PIN_27 0x8000000U /**< Pin 27 mask */
|
||||
#define GPIO_PDD_PIN_28 0x10000000U /**< Pin 28 mask */
|
||||
#define GPIO_PDD_PIN_29 0x20000000U /**< Pin 29 mask */
|
||||
#define GPIO_PDD_PIN_30 0x40000000U /**< Pin 30 mask */
|
||||
#define GPIO_PDD_PIN_31 0x80000000U /**< Pin 31 mask */
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- GetPortDataInput
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Gets port data input independently of current direction setting nor
|
||||
* pin usage. It returns zeros for pins which are not configured for a digital
|
||||
* function.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a 32-bit value.
|
||||
* @remarks The macro accesses the following registers: GPIOA_PDIR, GPIOB_PDIR,
|
||||
* GPIOC_PDIR, GPIOD_PDIR, GPIOE_PDIR, GPIOF_PDIR (depending on the
|
||||
* peripheral).
|
||||
* @par Example:
|
||||
* @code
|
||||
* uint32 result = GPIO_PDD_GetPortDataInput(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define GPIO_PDD_GetPortDataInput(PeripheralBase) ( \
|
||||
(uint32)GPIO_PDIR_REG(PeripheralBase) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- SetPortDataOutput
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Sets port data output. The value is driven out to the corresponding
|
||||
* pin if direction of the pin is set to output.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param Value Parameter specifying new data output value. This parameter is a
|
||||
* 32-bit value.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: GPIOA_PDOR, GPIOB_PDOR,
|
||||
* GPIOC_PDOR, GPIOD_PDOR, GPIOE_PDOR, GPIOF_PDOR (depending on the
|
||||
* peripheral).
|
||||
* @par Example:
|
||||
* @code
|
||||
* GPIO_PDD_SetPortDataOutput(<peripheral>_BASE_PTR, 1);
|
||||
* @endcode
|
||||
*/
|
||||
#define GPIO_PDD_SetPortDataOutput(PeripheralBase, Value) ( \
|
||||
GPIO_PDOR_REG(PeripheralBase) = \
|
||||
(uint32)(Value) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- GetPortDataOutput
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Gets port data output independently of current direction setting.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a 32-bit value.
|
||||
* @remarks The macro accesses the following registers: GPIOA_PDOR, GPIOB_PDOR,
|
||||
* GPIOC_PDOR, GPIOD_PDOR, GPIOE_PDOR, GPIOF_PDOR (depending on the
|
||||
* peripheral).
|
||||
* @par Example:
|
||||
* @code
|
||||
* uint32 result = GPIO_PDD_GetPortDataOutput(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define GPIO_PDD_GetPortDataOutput(PeripheralBase) ( \
|
||||
(uint32)GPIO_PDOR_REG(PeripheralBase) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- ClearPortDataOutputMask
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Clears required bits of port data output.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param Mask Parameter specifying port pins which should be cleared. Use
|
||||
* constants from group "Pin masks". This parameter is 32 bits wide.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: GPIOA_PCOR, GPIOB_PCOR,
|
||||
* GPIOC_PCOR, GPIOD_PCOR, GPIOE_PCOR, GPIOF_PCOR (depending on the
|
||||
* peripheral).
|
||||
* @par Example:
|
||||
* @code
|
||||
* GPIO_PDD_ClearPortDataOutputMask(<peripheral>_BASE_PTR, GPIO_PDD_PIN_0);
|
||||
* @endcode
|
||||
*/
|
||||
#define GPIO_PDD_ClearPortDataOutputMask(PeripheralBase, Mask) ( \
|
||||
GPIO_PCOR_REG(PeripheralBase) = \
|
||||
(uint32)(Mask) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- SetPortDataOutputMask
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Sets required bits of port data output.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param Mask Parameter specifying port pins which should be set. Use constants
|
||||
* from group "Pin masks". This parameter is 32 bits wide.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: GPIOA_PSOR, GPIOB_PSOR,
|
||||
* GPIOC_PSOR, GPIOD_PSOR, GPIOE_PSOR, GPIOF_PSOR (depending on the
|
||||
* peripheral).
|
||||
* @par Example:
|
||||
* @code
|
||||
* GPIO_PDD_SetPortDataOutputMask(<peripheral>_BASE_PTR, GPIO_PDD_PIN_0);
|
||||
* @endcode
|
||||
*/
|
||||
#define GPIO_PDD_SetPortDataOutputMask(PeripheralBase, Mask) ( \
|
||||
GPIO_PSOR_REG(PeripheralBase) = \
|
||||
(uint32)(Mask) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- TogglePortDataOutputMask
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Toggles required bits of port data output.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param Mask Parameter specifying port pins which should be inverted. Use
|
||||
* constants from group "Pin masks". This parameter is 32 bits wide.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: GPIOA_PTOR, GPIOB_PTOR,
|
||||
* GPIOC_PTOR, GPIOD_PTOR, GPIOE_PTOR, GPIOF_PTOR (depending on the
|
||||
* peripheral).
|
||||
* @par Example:
|
||||
* @code
|
||||
* GPIO_PDD_TogglePortDataOutputMask(<peripheral>_BASE_PTR,
|
||||
* GPIO_PDD_PIN_0);
|
||||
* @endcode
|
||||
*/
|
||||
#define GPIO_PDD_TogglePortDataOutputMask(PeripheralBase, Mask) ( \
|
||||
GPIO_PTOR_REG(PeripheralBase) = \
|
||||
(uint32)(Mask) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- SetPortInputDirectionMask
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
#if ((defined(MCU_MKE02Z2)) || (defined(MCU_MKE02Z4)) || (defined(MCU_MKE04Z1284)) || (defined(MCU_MKE04Z4)) || (defined(MCU_MKE06Z4)) || (defined(MCU_SKEAZ1284)) || (defined(MCU_SKEAZN642)) || (defined(MCU_SKEAZN84)))
|
||||
/**
|
||||
* @brief Sets required pins as input.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param Mask Parameter specifying port pins which should be set as input. Use
|
||||
* constants from group "Pin masks". This parameter is 32 bits wide.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: GPIOA_PDDR, GPIOB_PDDR,
|
||||
* GPIOC_PDDR, GPIOD_PDDR, GPIOE_PDDR, GPIOF_PDDR, GPIOA_PIDR,
|
||||
* GPIOB_PIDR, GPIOC_PIDR (depending on the peripheral).
|
||||
* @par Example:
|
||||
* @code
|
||||
* GPIO_PDD_SetPortInputDirectionMask(<peripheral>_BASE_PTR,
|
||||
* GPIO_PDD_PIN_0);
|
||||
* @endcode
|
||||
*/
|
||||
#define GPIO_PDD_SetPortInputDirectionMask(PeripheralBase, Mask) ( \
|
||||
(GPIO_PDDR_REG(PeripheralBase) &= \
|
||||
(uint32)(~(uint32)(Mask))), \
|
||||
(GPIO_PIDR_REG(PeripheralBase) &= \
|
||||
(uint32)(~(uint32)(Mask))) \
|
||||
)
|
||||
#else /* (defined(MCU_MK10D10)) || (defined(MCU_MK10D5)) || (defined(MCU_MK10D7)) || (defined(MCU_MK10DZ10)) || (defined(MCU_MK10F12)) || (defined(MCU_MK11D5)) || (defined(MCU_MK11D5WS)) || (defined(MCU_MK12D5)) || (defined(MCU_MK20D10)) || (defined(MCU_MK20D5)) || (defined(MCU_MK20D7)) || (defined(MCU_MK20DZ10)) || (defined(MCU_MK20F12)) || (defined(MCU_MK21D5)) || (defined(MCU_MK21D5WS)) || (defined(MCU_MK21F12)) || (defined(MCU_MK21F12WS)) || (defined(MCU_MK22D5)) || (defined(MCU_MK22F12)) || (defined(MCU_MK22F12810)) || (defined(MCU_MK22F25612)) || (defined(MCU_MK22F51212)) || (defined(MCU_MK24F12)) || (defined(MCU_MK30D10)) || (defined(MCU_MK30D7)) || (defined(MCU_MK30DZ10)) || (defined(MCU_MK40D10)) || (defined(MCU_MK40D7)) || (defined(MCU_MK40DZ10)) || (defined(MCU_MK40X256VMD100)) || (defined(MCU_MK50D10)) || (defined(MCU_MK50D7)) || (defined(MCU_MK50DZ10)) || (defined(MCU_MK51D10)) || (defined(MCU_MK51D7)) || (defined(MCU_MK51DZ10)) || (defined(MCU_MK52D10)) || (defined(MCU_MK52DZ10)) || (defined(MCU_MK53D10)) || (defined(MCU_MK53DZ10)) || (defined(MCU_MK60D10)) || (defined(MCU_MK60DZ10)) || (defined(MCU_MK60F12)) || (defined(MCU_MK60F15)) || (defined(MCU_MK60N512VMD100)) || (defined(MCU_MK61F12)) || (defined(MCU_MK61F12WS)) || (defined(MCU_MK61F15)) || (defined(MCU_MK61F15WS)) || (defined(MCU_MK63F12)) || (defined(MCU_MK63F12WS)) || (defined(MCU_MK64F12)) || (defined(MCU_MK65F18)) || (defined(MCU_MK65F18WS)) || (defined(MCU_MK66F18)) || (defined(MCU_MK70F12)) || (defined(MCU_MK70F12WS)) || (defined(MCU_MK70F15)) || (defined(MCU_MK70F15WS)) || (defined(MCU_MKL02Z4)) || (defined(MCU_MKL03Z4)) || (defined(MCU_MKL04Z4)) || (defined(MCU_MKL05Z4)) || (defined(MCU_MKL14Z4)) || (defined(MCU_MKL15Z4)) || (defined(MCU_MKL16Z4)) || (defined(MCU_MKL24Z4)) || (defined(MCU_MKL25Z4)) || (defined(MCU_MKL26Z4)) || (defined(MCU_MKL34Z4)) || (defined(MCU_MKL36Z4)) || (defined(MCU_MKL46Z4)) || (defined(MCU_MKV10Z7)) || (defined(MCU_MKV31F12810)) || (defined(MCU_MKV31F25612)) || (defined(MCU_MKV31F51212)) || (defined(MCU_MKW01Z4)) || (defined(MCU_MKW21D5)) || (defined(MCU_MKW21D5WS)) || (defined(MCU_MKW22D5)) || (defined(MCU_MKW22D5WS)) || (defined(MCU_MKW24D5)) || (defined(MCU_MKW24D5WS)) || (defined(MCU_PCK20L4)) */
|
||||
/**
|
||||
* @brief Sets required pins as input.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param Mask Parameter specifying port pins which should be set as input. Use
|
||||
* constants from group "Pin masks". This parameter is 32 bits wide.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: GPIOA_PDDR, GPIOB_PDDR,
|
||||
* GPIOC_PDDR, GPIOD_PDDR, GPIOE_PDDR, GPIOF_PDDR, GPIOA_PIDR,
|
||||
* GPIOB_PIDR, GPIOC_PIDR (depending on the peripheral).
|
||||
* @par Example:
|
||||
* @code
|
||||
* GPIO_PDD_SetPortInputDirectionMask(<peripheral>_BASE_PTR,
|
||||
* GPIO_PDD_PIN_0);
|
||||
* @endcode
|
||||
*/
|
||||
#define GPIO_PDD_SetPortInputDirectionMask(PeripheralBase, Mask) ( \
|
||||
GPIO_PDDR_REG(PeripheralBase) &= \
|
||||
(uint32)(~(uint32)(Mask)) \
|
||||
)
|
||||
#endif /* (defined(MCU_MK10D10)) || (defined(MCU_MK10D5)) || (defined(MCU_MK10D7)) || (defined(MCU_MK10DZ10)) || (defined(MCU_MK10F12)) || (defined(MCU_MK11D5)) || (defined(MCU_MK11D5WS)) || (defined(MCU_MK12D5)) || (defined(MCU_MK20D10)) || (defined(MCU_MK20D5)) || (defined(MCU_MK20D7)) || (defined(MCU_MK20DZ10)) || (defined(MCU_MK20F12)) || (defined(MCU_MK21D5)) || (defined(MCU_MK21D5WS)) || (defined(MCU_MK21F12)) || (defined(MCU_MK21F12WS)) || (defined(MCU_MK22D5)) || (defined(MCU_MK22F12)) || (defined(MCU_MK22F12810)) || (defined(MCU_MK22F25612)) || (defined(MCU_MK22F51212)) || (defined(MCU_MK24F12)) || (defined(MCU_MK30D10)) || (defined(MCU_MK30D7)) || (defined(MCU_MK30DZ10)) || (defined(MCU_MK40D10)) || (defined(MCU_MK40D7)) || (defined(MCU_MK40DZ10)) || (defined(MCU_MK40X256VMD100)) || (defined(MCU_MK50D10)) || (defined(MCU_MK50D7)) || (defined(MCU_MK50DZ10)) || (defined(MCU_MK51D10)) || (defined(MCU_MK51D7)) || (defined(MCU_MK51DZ10)) || (defined(MCU_MK52D10)) || (defined(MCU_MK52DZ10)) || (defined(MCU_MK53D10)) || (defined(MCU_MK53DZ10)) || (defined(MCU_MK60D10)) || (defined(MCU_MK60DZ10)) || (defined(MCU_MK60F12)) || (defined(MCU_MK60F15)) || (defined(MCU_MK60N512VMD100)) || (defined(MCU_MK61F12)) || (defined(MCU_MK61F12WS)) || (defined(MCU_MK61F15)) || (defined(MCU_MK61F15WS)) || (defined(MCU_MK63F12)) || (defined(MCU_MK63F12WS)) || (defined(MCU_MK64F12)) || (defined(MCU_MK65F18)) || (defined(MCU_MK65F18WS)) || (defined(MCU_MK66F18)) || (defined(MCU_MK70F12)) || (defined(MCU_MK70F12WS)) || (defined(MCU_MK70F15)) || (defined(MCU_MK70F15WS)) || (defined(MCU_MKL02Z4)) || (defined(MCU_MKL03Z4)) || (defined(MCU_MKL04Z4)) || (defined(MCU_MKL05Z4)) || (defined(MCU_MKL14Z4)) || (defined(MCU_MKL15Z4)) || (defined(MCU_MKL16Z4)) || (defined(MCU_MKL24Z4)) || (defined(MCU_MKL25Z4)) || (defined(MCU_MKL26Z4)) || (defined(MCU_MKL34Z4)) || (defined(MCU_MKL36Z4)) || (defined(MCU_MKL46Z4)) || (defined(MCU_MKV10Z7)) || (defined(MCU_MKV31F12810)) || (defined(MCU_MKV31F25612)) || (defined(MCU_MKV31F51212)) || (defined(MCU_MKW01Z4)) || (defined(MCU_MKW21D5)) || (defined(MCU_MKW21D5WS)) || (defined(MCU_MKW22D5)) || (defined(MCU_MKW22D5WS)) || (defined(MCU_MKW24D5)) || (defined(MCU_MKW24D5WS)) || (defined(MCU_PCK20L4)) */
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- SetPortOutputDirectionMask
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Sets required pins as output.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param Mask Parameter specifying port pins which should be set as output. Use
|
||||
* constants from group "Pin masks". This parameter is 32 bits wide.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: GPIOA_PDDR, GPIOB_PDDR,
|
||||
* GPIOC_PDDR, GPIOD_PDDR, GPIOE_PDDR, GPIOF_PDDR (depending on the
|
||||
* peripheral).
|
||||
* @par Example:
|
||||
* @code
|
||||
* GPIO_PDD_SetPortOutputDirectionMask(<peripheral>_BASE_PTR,
|
||||
* GPIO_PDD_PIN_0);
|
||||
* @endcode
|
||||
*/
|
||||
#define GPIO_PDD_SetPortOutputDirectionMask(PeripheralBase, Mask) ( \
|
||||
GPIO_PDDR_REG(PeripheralBase) |= \
|
||||
(uint32)(Mask) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- SetPortDirectionMask
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
#if ((defined(MCU_MKE02Z2)) || (defined(MCU_MKE02Z4)) || (defined(MCU_MKE04Z1284)) || (defined(MCU_MKE04Z4)) || (defined(MCU_MKE06Z4)) || (defined(MCU_SKEAZ1284)) || (defined(MCU_SKEAZN642)) || (defined(MCU_SKEAZN84)))
|
||||
/**
|
||||
* @brief Sets direction on pins specified by mask parameters.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param InputMask Mask of port pins defining which should be set as input. Use
|
||||
* constants from group "Pin masks". This parameter is 32 bits wide.
|
||||
* @param OutputMask Mask of port pins defining which should be set as output.
|
||||
* Use constants from group "Pin masks". This parameter is 32 bits wide.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: GPIOA_PDDR, GPIOB_PDDR,
|
||||
* GPIOC_PDDR, GPIOD_PDDR, GPIOE_PDDR, GPIOF_PDDR, GPIOA_PIDR,
|
||||
* GPIOB_PIDR, GPIOC_PIDR (depending on the peripheral).
|
||||
* @par Example:
|
||||
* @code
|
||||
* GPIO_PDD_SetPortDirectionMask(<peripheral>_BASE_PTR, GPIO_PDD_PIN_0,
|
||||
* GPIO_PDD_PIN_0);
|
||||
* @endcode
|
||||
*/
|
||||
#define GPIO_PDD_SetPortDirectionMask(PeripheralBase, InputMask, OutputMask) ( \
|
||||
(GPIO_PDDR_REG(PeripheralBase) = \
|
||||
(uint32)(( \
|
||||
(uint32)(GPIO_PDDR_REG(PeripheralBase) & (uint32)(~(uint32)(InputMask)))) | ( \
|
||||
(uint32)(OutputMask)))), \
|
||||
(GPIO_PIDR_REG(PeripheralBase) &= \
|
||||
(uint32)(~(uint32)(InputMask))) \
|
||||
)
|
||||
#else /* (defined(MCU_MK10D10)) || (defined(MCU_MK10D5)) || (defined(MCU_MK10D7)) || (defined(MCU_MK10DZ10)) || (defined(MCU_MK10F12)) || (defined(MCU_MK11D5)) || (defined(MCU_MK11D5WS)) || (defined(MCU_MK12D5)) || (defined(MCU_MK20D10)) || (defined(MCU_MK20D5)) || (defined(MCU_MK20D7)) || (defined(MCU_MK20DZ10)) || (defined(MCU_MK20F12)) || (defined(MCU_MK21D5)) || (defined(MCU_MK21D5WS)) || (defined(MCU_MK21F12)) || (defined(MCU_MK21F12WS)) || (defined(MCU_MK22D5)) || (defined(MCU_MK22F12)) || (defined(MCU_MK22F12810)) || (defined(MCU_MK22F25612)) || (defined(MCU_MK22F51212)) || (defined(MCU_MK24F12)) || (defined(MCU_MK30D10)) || (defined(MCU_MK30D7)) || (defined(MCU_MK30DZ10)) || (defined(MCU_MK40D10)) || (defined(MCU_MK40D7)) || (defined(MCU_MK40DZ10)) || (defined(MCU_MK40X256VMD100)) || (defined(MCU_MK50D10)) || (defined(MCU_MK50D7)) || (defined(MCU_MK50DZ10)) || (defined(MCU_MK51D10)) || (defined(MCU_MK51D7)) || (defined(MCU_MK51DZ10)) || (defined(MCU_MK52D10)) || (defined(MCU_MK52DZ10)) || (defined(MCU_MK53D10)) || (defined(MCU_MK53DZ10)) || (defined(MCU_MK60D10)) || (defined(MCU_MK60DZ10)) || (defined(MCU_MK60F12)) || (defined(MCU_MK60F15)) || (defined(MCU_MK60N512VMD100)) || (defined(MCU_MK61F12)) || (defined(MCU_MK61F12WS)) || (defined(MCU_MK61F15)) || (defined(MCU_MK61F15WS)) || (defined(MCU_MK63F12)) || (defined(MCU_MK63F12WS)) || (defined(MCU_MK64F12)) || (defined(MCU_MK65F18)) || (defined(MCU_MK65F18WS)) || (defined(MCU_MK66F18)) || (defined(MCU_MK70F12)) || (defined(MCU_MK70F12WS)) || (defined(MCU_MK70F15)) || (defined(MCU_MK70F15WS)) || (defined(MCU_MKL02Z4)) || (defined(MCU_MKL03Z4)) || (defined(MCU_MKL04Z4)) || (defined(MCU_MKL05Z4)) || (defined(MCU_MKL14Z4)) || (defined(MCU_MKL15Z4)) || (defined(MCU_MKL16Z4)) || (defined(MCU_MKL24Z4)) || (defined(MCU_MKL25Z4)) || (defined(MCU_MKL26Z4)) || (defined(MCU_MKL34Z4)) || (defined(MCU_MKL36Z4)) || (defined(MCU_MKL46Z4)) || (defined(MCU_MKV10Z7)) || (defined(MCU_MKV31F12810)) || (defined(MCU_MKV31F25612)) || (defined(MCU_MKV31F51212)) || (defined(MCU_MKW01Z4)) || (defined(MCU_MKW21D5)) || (defined(MCU_MKW21D5WS)) || (defined(MCU_MKW22D5)) || (defined(MCU_MKW22D5WS)) || (defined(MCU_MKW24D5)) || (defined(MCU_MKW24D5WS)) || (defined(MCU_PCK20L4)) */
|
||||
/**
|
||||
* @brief Sets direction on pins specified by mask parameters.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param InputMask Mask of port pins defining which should be set as input. Use
|
||||
* constants from group "Pin masks". This parameter is 32 bits wide.
|
||||
* @param OutputMask Mask of port pins defining which should be set as output.
|
||||
* Use constants from group "Pin masks". This parameter is 32 bits wide.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: GPIOA_PDDR, GPIOB_PDDR,
|
||||
* GPIOC_PDDR, GPIOD_PDDR, GPIOE_PDDR, GPIOF_PDDR, GPIOA_PIDR,
|
||||
* GPIOB_PIDR, GPIOC_PIDR (depending on the peripheral).
|
||||
* @par Example:
|
||||
* @code
|
||||
* GPIO_PDD_SetPortDirectionMask(<peripheral>_BASE_PTR, GPIO_PDD_PIN_0,
|
||||
* GPIO_PDD_PIN_0);
|
||||
* @endcode
|
||||
*/
|
||||
#define GPIO_PDD_SetPortDirectionMask(PeripheralBase, InputMask, OutputMask) ( \
|
||||
GPIO_PDDR_REG(PeripheralBase) = \
|
||||
(uint32)(( \
|
||||
(uint32)(GPIO_PDDR_REG(PeripheralBase) & (uint32)(~(uint32)(InputMask)))) | ( \
|
||||
(uint32)(OutputMask))) \
|
||||
)
|
||||
#endif /* (defined(MCU_MK10D10)) || (defined(MCU_MK10D5)) || (defined(MCU_MK10D7)) || (defined(MCU_MK10DZ10)) || (defined(MCU_MK10F12)) || (defined(MCU_MK11D5)) || (defined(MCU_MK11D5WS)) || (defined(MCU_MK12D5)) || (defined(MCU_MK20D10)) || (defined(MCU_MK20D5)) || (defined(MCU_MK20D7)) || (defined(MCU_MK20DZ10)) || (defined(MCU_MK20F12)) || (defined(MCU_MK21D5)) || (defined(MCU_MK21D5WS)) || (defined(MCU_MK21F12)) || (defined(MCU_MK21F12WS)) || (defined(MCU_MK22D5)) || (defined(MCU_MK22F12)) || (defined(MCU_MK22F12810)) || (defined(MCU_MK22F25612)) || (defined(MCU_MK22F51212)) || (defined(MCU_MK24F12)) || (defined(MCU_MK30D10)) || (defined(MCU_MK30D7)) || (defined(MCU_MK30DZ10)) || (defined(MCU_MK40D10)) || (defined(MCU_MK40D7)) || (defined(MCU_MK40DZ10)) || (defined(MCU_MK40X256VMD100)) || (defined(MCU_MK50D10)) || (defined(MCU_MK50D7)) || (defined(MCU_MK50DZ10)) || (defined(MCU_MK51D10)) || (defined(MCU_MK51D7)) || (defined(MCU_MK51DZ10)) || (defined(MCU_MK52D10)) || (defined(MCU_MK52DZ10)) || (defined(MCU_MK53D10)) || (defined(MCU_MK53DZ10)) || (defined(MCU_MK60D10)) || (defined(MCU_MK60DZ10)) || (defined(MCU_MK60F12)) || (defined(MCU_MK60F15)) || (defined(MCU_MK60N512VMD100)) || (defined(MCU_MK61F12)) || (defined(MCU_MK61F12WS)) || (defined(MCU_MK61F15)) || (defined(MCU_MK61F15WS)) || (defined(MCU_MK63F12)) || (defined(MCU_MK63F12WS)) || (defined(MCU_MK64F12)) || (defined(MCU_MK65F18)) || (defined(MCU_MK65F18WS)) || (defined(MCU_MK66F18)) || (defined(MCU_MK70F12)) || (defined(MCU_MK70F12WS)) || (defined(MCU_MK70F15)) || (defined(MCU_MK70F15WS)) || (defined(MCU_MKL02Z4)) || (defined(MCU_MKL03Z4)) || (defined(MCU_MKL04Z4)) || (defined(MCU_MKL05Z4)) || (defined(MCU_MKL14Z4)) || (defined(MCU_MKL15Z4)) || (defined(MCU_MKL16Z4)) || (defined(MCU_MKL24Z4)) || (defined(MCU_MKL25Z4)) || (defined(MCU_MKL26Z4)) || (defined(MCU_MKL34Z4)) || (defined(MCU_MKL36Z4)) || (defined(MCU_MKL46Z4)) || (defined(MCU_MKV10Z7)) || (defined(MCU_MKV31F12810)) || (defined(MCU_MKV31F25612)) || (defined(MCU_MKV31F51212)) || (defined(MCU_MKW01Z4)) || (defined(MCU_MKW21D5)) || (defined(MCU_MKW21D5WS)) || (defined(MCU_MKW22D5)) || (defined(MCU_MKW22D5WS)) || (defined(MCU_MKW24D5)) || (defined(MCU_MKW24D5WS)) || (defined(MCU_PCK20L4)) */
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- SetPortDirection
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Sets direction of every pin in the port.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param Value Parameter specifying new direction for port pins. This parameter
|
||||
* is a 32-bit value.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: GPIOA_PDDR, GPIOB_PDDR,
|
||||
* GPIOC_PDDR, GPIOD_PDDR, GPIOE_PDDR, GPIOF_PDDR (depending on the
|
||||
* peripheral).
|
||||
* @par Example:
|
||||
* @code
|
||||
* GPIO_PDD_SetPortDirection(<peripheral>_BASE_PTR, 1);
|
||||
* @endcode
|
||||
*/
|
||||
#define GPIO_PDD_SetPortDirection(PeripheralBase, Value) ( \
|
||||
GPIO_PDDR_REG(PeripheralBase) = \
|
||||
(uint32)(Value) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- GetPortDirection
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Gets direction of every pin in the port.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a 32-bit value.
|
||||
* @remarks The macro accesses the following registers: GPIOA_PDDR, GPIOB_PDDR,
|
||||
* GPIOC_PDDR, GPIOD_PDDR, GPIOE_PDDR, GPIOF_PDDR (depending on the
|
||||
* peripheral).
|
||||
* @par Example:
|
||||
* @code
|
||||
* uint32 result = GPIO_PDD_GetPortDirection(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define GPIO_PDD_GetPortDirection(PeripheralBase) ( \
|
||||
(uint32)GPIO_PDDR_REG(PeripheralBase) \
|
||||
)
|
||||
#endif /* #if defined(GPIO_PDD_H_) */
|
||||
|
||||
/* GPIO_PDD.h, eof. */
|
||||
2150
Clean_TMC2209/lib/tmc/hal/Landungsbruecke/freescale/PDD/I2C_PDD.h
Normal file
2150
Clean_TMC2209/lib/tmc/hal/Landungsbruecke/freescale/PDD/I2C_PDD.h
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,788 @@
|
||||
/*
|
||||
PDD layer implementation for peripheral type LPTMR
|
||||
(C) 2013 Freescale, Inc. All rights reserved.
|
||||
|
||||
This file is static and it is generated from API-Factory
|
||||
*/
|
||||
|
||||
#if !defined(LPTMR_PDD_H_)
|
||||
#define LPTMR_PDD_H_
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- Test if supported MCU is active
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
#if !defined(MCU_ACTIVE)
|
||||
// No MCU is active
|
||||
#error LPTMR PDD library: No derivative is active. Place proper #include with PDD memory map before including PDD library.
|
||||
#elif \
|
||||
!defined(MCU_MK10D10) /* LPTMR0 */ && \
|
||||
!defined(MCU_MK10D5) /* LPTMR0 */ && \
|
||||
!defined(MCU_MK10D7) /* LPTMR0 */ && \
|
||||
!defined(MCU_MK10F12) /* LPTMR0 */ && \
|
||||
!defined(MCU_MK10DZ10) /* LPTMR0 */ && \
|
||||
!defined(MCU_MK11D5) /* LPTMR0 */ && \
|
||||
!defined(MCU_MK11D5WS) /* LPTMR0 */ && \
|
||||
!defined(MCU_MK12D5) /* LPTMR0 */ && \
|
||||
!defined(MCU_MK20D10) /* LPTMR0 */ && \
|
||||
!defined(MCU_MK20D5) /* LPTMR0 */ && \
|
||||
!defined(MCU_MK20D7) /* LPTMR0 */ && \
|
||||
!defined(MCU_MK20F12) /* LPTMR0 */ && \
|
||||
!defined(MCU_MK20DZ10) /* LPTMR0 */ && \
|
||||
!defined(MCU_MK21D5) /* LPTMR0 */ && \
|
||||
!defined(MCU_MK21D5WS) /* LPTMR0 */ && \
|
||||
!defined(MCU_MK21F12) /* LPTMR0 */ && \
|
||||
!defined(MCU_MK21F12WS) /* LPTMR0 */ && \
|
||||
!defined(MCU_MK22D5) /* LPTMR0 */ && \
|
||||
!defined(MCU_MK22F12810) /* LPTMR0 */ && \
|
||||
!defined(MCU_MK22F12) /* LPTMR0 */ && \
|
||||
!defined(MCU_MK22F25612) /* LPTMR0 */ && \
|
||||
!defined(MCU_MK22F51212) /* LPTMR0 */ && \
|
||||
!defined(MCU_MK24F12) /* LPTMR0 */ && \
|
||||
!defined(MCU_MK30D10) /* LPTMR0 */ && \
|
||||
!defined(MCU_MK30D7) /* LPTMR0 */ && \
|
||||
!defined(MCU_MK30DZ10) /* LPTMR0 */ && \
|
||||
!defined(MCU_MK40D10) /* LPTMR0 */ && \
|
||||
!defined(MCU_MK40D7) /* LPTMR0 */ && \
|
||||
!defined(MCU_MK40DZ10) /* LPTMR0 */ && \
|
||||
!defined(MCU_MK40X256VMD100) /* LPTMR0 */ && \
|
||||
!defined(MCU_MK50D10) /* LPTMR0 */ && \
|
||||
!defined(MCU_MK50D7) /* LPTMR0 */ && \
|
||||
!defined(MCU_MK50DZ10) /* LPTMR0 */ && \
|
||||
!defined(MCU_MK51D10) /* LPTMR0 */ && \
|
||||
!defined(MCU_MK51D7) /* LPTMR0 */ && \
|
||||
!defined(MCU_MK51DZ10) /* LPTMR0 */ && \
|
||||
!defined(MCU_MK52D10) /* LPTMR0 */ && \
|
||||
!defined(MCU_MK52DZ10) /* LPTMR0 */ && \
|
||||
!defined(MCU_MK53D10) /* LPTMR0 */ && \
|
||||
!defined(MCU_MK53DZ10) /* LPTMR0 */ && \
|
||||
!defined(MCU_MK60D10) /* LPTMR0 */ && \
|
||||
!defined(MCU_MK60F12) /* LPTMR0 */ && \
|
||||
!defined(MCU_MK60F15) /* LPTMR0 */ && \
|
||||
!defined(MCU_MK60DZ10) /* LPTMR0 */ && \
|
||||
!defined(MCU_MK60N512VMD100) /* LPTMR0 */ && \
|
||||
!defined(MCU_MK61F12) /* LPTMR0 */ && \
|
||||
!defined(MCU_MK61F15) /* LPTMR0 */ && \
|
||||
!defined(MCU_MK61F12WS) /* LPTMR0 */ && \
|
||||
!defined(MCU_MK61F15WS) /* LPTMR0 */ && \
|
||||
!defined(MCU_MK63F12) /* LPTMR0 */ && \
|
||||
!defined(MCU_MK63F12WS) /* LPTMR0 */ && \
|
||||
!defined(MCU_MK64F12) /* LPTMR0 */ && \
|
||||
!defined(MCU_MK65F18) /* LPTMR0 */ && \
|
||||
!defined(MCU_MK65F18WS) /* LPTMR0 */ && \
|
||||
!defined(MCU_MK66F18) /* LPTMR0 */ && \
|
||||
!defined(MCU_MK70F12) /* LPTMR0 */ && \
|
||||
!defined(MCU_MK70F15) /* LPTMR0 */ && \
|
||||
!defined(MCU_MK70F12WS) /* LPTMR0 */ && \
|
||||
!defined(MCU_MK70F15WS) /* LPTMR0 */ && \
|
||||
!defined(MCU_MKL02Z4) /* LPTMR0 */ && \
|
||||
!defined(MCU_MKL03Z4) /* LPTMR0 */ && \
|
||||
!defined(MCU_MKL04Z4) /* LPTMR0 */ && \
|
||||
!defined(MCU_MKL05Z4) /* LPTMR0 */ && \
|
||||
!defined(MCU_MKL14Z4) /* LPTMR0 */ && \
|
||||
!defined(MCU_MKL15Z4) /* LPTMR0 */ && \
|
||||
!defined(MCU_MKL16Z4) /* LPTMR0 */ && \
|
||||
!defined(MCU_MKL24Z4) /* LPTMR0 */ && \
|
||||
!defined(MCU_MKL25Z4) /* LPTMR0 */ && \
|
||||
!defined(MCU_MKL26Z4) /* LPTMR0 */ && \
|
||||
!defined(MCU_MKL34Z4) /* LPTMR0 */ && \
|
||||
!defined(MCU_MKL36Z4) /* LPTMR0 */ && \
|
||||
!defined(MCU_MKL46Z4) /* LPTMR0 */ && \
|
||||
!defined(MCU_MKV10Z7) /* LPTMR0 */ && \
|
||||
!defined(MCU_MKV31F12810) /* LPTMR0 */ && \
|
||||
!defined(MCU_MKV31F25612) /* LPTMR0 */ && \
|
||||
!defined(MCU_MKV31F51212) /* LPTMR0 */ && \
|
||||
!defined(MCU_MKW01Z4) /* LPTMR0 */ && \
|
||||
!defined(MCU_MKW21D5) /* LPTMR0 */ && \
|
||||
!defined(MCU_MKW21D5WS) /* LPTMR0 */ && \
|
||||
!defined(MCU_MKW22D5) /* LPTMR0 */ && \
|
||||
!defined(MCU_MKW22D5WS) /* LPTMR0 */ && \
|
||||
!defined(MCU_MKW24D5) /* LPTMR0 */ && \
|
||||
!defined(MCU_MKW24D5WS) /* LPTMR0 */ && \
|
||||
!defined(MCU_PCK20L4) /* LPTMR0 */
|
||||
// Unsupported MCU is active
|
||||
#error LPTMR PDD library: Unsupported derivative is active.
|
||||
#endif
|
||||
|
||||
#include "PDD_Types.h"
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- Method symbol definitions
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/* Enable freerun constants */
|
||||
#define LPTMR_PDD_RESTART_ENABLED 0U /**< Enabled */
|
||||
#define LPTMR_PDD_RESTART_DISABLED LPTMR_CSR_TFC_MASK /**< Disabled */
|
||||
|
||||
/* Timer mode constants */
|
||||
#define LPTMR_PDD_SOURCE_INTERNAL 0U /**< Internal */
|
||||
#define LPTMR_PDD_SOURCE_EXTERNAL LPTMR_CSR_TMS_MASK /**< External */
|
||||
|
||||
/* Prescaler/Filter constants */
|
||||
#define LPTMR_PDD_PRESCALER_2 0U /**< 2 */
|
||||
#define LPTMR_PDD_PRESCALER_4 0x1U /**< 4 */
|
||||
#define LPTMR_PDD_PRESCALER_8 0x2U /**< 8 */
|
||||
#define LPTMR_PDD_PRESCALER_16 0x3U /**< 16 */
|
||||
#define LPTMR_PDD_PRESCALER_32 0x4U /**< 32 */
|
||||
#define LPTMR_PDD_PRESCALER_64 0x5U /**< 64 */
|
||||
#define LPTMR_PDD_PRESCALER_128 0x6U /**< 128 */
|
||||
#define LPTMR_PDD_PRESCALER_256 0x7U /**< 256 */
|
||||
#define LPTMR_PDD_PRESCALER_512 0x8U /**< 512 */
|
||||
#define LPTMR_PDD_PRESCALER_1024 0x9U /**< 1024 */
|
||||
#define LPTMR_PDD_PRESCALER_2048 0xAU /**< 2048 */
|
||||
#define LPTMR_PDD_PRESCALER_4096 0xBU /**< 4096 */
|
||||
#define LPTMR_PDD_PRESCALER_8192 0xCU /**< 8192 */
|
||||
#define LPTMR_PDD_PRESCALER_16384 0xDU /**< 16384 */
|
||||
#define LPTMR_PDD_PRESCALER_32768 0xEU /**< 32768 */
|
||||
#define LPTMR_PDD_PRESCALER_65536 0xFU /**< 65536 */
|
||||
#define LPTMR_PDD_FILTER_2 0x1U /**< 2 */
|
||||
#define LPTMR_PDD_FILTER_4 0x2U /**< 4 */
|
||||
#define LPTMR_PDD_FILTER_8 0x3U /**< 8 */
|
||||
#define LPTMR_PDD_FILTER_16 0x4U /**< 16 */
|
||||
#define LPTMR_PDD_FILTER_32 0x5U /**< 32 */
|
||||
#define LPTMR_PDD_FILTER_64 0x6U /**< 64 */
|
||||
#define LPTMR_PDD_FILTER_128 0x7U /**< 128 */
|
||||
#define LPTMR_PDD_FILTER_256 0x8U /**< 256 */
|
||||
#define LPTMR_PDD_FILTER_512 0x9U /**< 512 */
|
||||
#define LPTMR_PDD_FILTER_1024 0xAU /**< 1024 */
|
||||
#define LPTMR_PDD_FILTER_2048 0xBU /**< 2048 */
|
||||
#define LPTMR_PDD_FILTER_4096 0xCU /**< 4096 */
|
||||
#define LPTMR_PDD_FILTER_8192 0xDU /**< 8192 */
|
||||
#define LPTMR_PDD_FILTER_16384 0xEU /**< 16384 */
|
||||
#define LPTMR_PDD_FILTER_32768 0xFU /**< 32768 */
|
||||
|
||||
/* Divider constants */
|
||||
#define LPTMR_PDD_DIVIDER_1 0x1U /**< 1 */
|
||||
#define LPTMR_PDD_DIVIDER_2 0U /**< 2 */
|
||||
#define LPTMR_PDD_DIVIDER_4 0x2U /**< 4 */
|
||||
#define LPTMR_PDD_DIVIDER_8 0x4U /**< 8 */
|
||||
#define LPTMR_PDD_DIVIDER_16 0x6U /**< 16 */
|
||||
#define LPTMR_PDD_DIVIDER_32 0x8U /**< 32 */
|
||||
#define LPTMR_PDD_DIVIDER_64 0xAU /**< 64 */
|
||||
#define LPTMR_PDD_DIVIDER_128 0xCU /**< 128 */
|
||||
#define LPTMR_PDD_DIVIDER_256 0xEU /**< 256 */
|
||||
#define LPTMR_PDD_DIVIDER_512 0x10U /**< 512 */
|
||||
#define LPTMR_PDD_DIVIDER_1024 0x12U /**< 1024 */
|
||||
#define LPTMR_PDD_DIVIDER_2048 0x14U /**< 2048 */
|
||||
#define LPTMR_PDD_DIVIDER_4096 0x16U /**< 4096 */
|
||||
#define LPTMR_PDD_DIVIDER_8192 0x18U /**< 8192 */
|
||||
#define LPTMR_PDD_DIVIDER_16384 0x1AU /**< 16384 */
|
||||
#define LPTMR_PDD_DIVIDER_32768 0x1CU /**< 32768 */
|
||||
#define LPTMR_PDD_DIVIDER_65536 0x1EU /**< 65536 */
|
||||
|
||||
/* Timer Pin Select constants. */
|
||||
#define LPTMR_PDD_HSCMP 0U /**< Alt 0 */
|
||||
#define LPTMR_PDD_PIN_1 0x10U /**< Alt 1 */
|
||||
#define LPTMR_PDD_PIN_2 0x20U /**< Alt 2 */
|
||||
#define LPTMR_PDD_PIN_3 0x30U /**< Alt 3 */
|
||||
|
||||
/* Timer Pin Polarity constants. */
|
||||
#define LPTMR_PDD_POLARITY_RISING 0U /**< Rising */
|
||||
#define LPTMR_PDD_POLARITY_FALLING 0x8U /**< Falling */
|
||||
|
||||
/* Prescaler bypass constants. */
|
||||
#define LPTMR_PDD_BYPASS_DISABLED 0U /**< Disabled */
|
||||
#define LPTMR_PDD_BYPASS_ENABLED 0x4U /**< Enabled */
|
||||
|
||||
/* Clock source constants. */
|
||||
#define LPTMR_PDD_SOURCE_INTREF 0U /**< Internal reference clock */
|
||||
#define LPTMR_PDD_SOURCE_LPO1KHZ 0x1U /**< Low power oscillator clock */
|
||||
#define LPTMR_PDD_SOURCE_EXT32KHZ 0x2U /**< External 32 kHz clock */
|
||||
#define LPTMR_PDD_SOURCE_EXTREF 0x3U /**< External reference clock */
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- GetInterruptMask
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Returns interrupt mask.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a 32-bit value.
|
||||
* @remarks The macro accesses the following registers: LPTMR0_CSR.
|
||||
* @par Example:
|
||||
* @code
|
||||
* uint32 result = LPTMR_PDD_GetInterruptMask(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define LPTMR_PDD_GetInterruptMask(PeripheralBase) ( \
|
||||
(uint32)(LPTMR_CSR_REG(PeripheralBase) & LPTMR_CSR_TIE_MASK) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- GetInterruptFlag
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Returns interrupt flag bit.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a 32-bit value.
|
||||
* @remarks The macro accesses the following registers: LPTMR0_CSR.
|
||||
* @par Example:
|
||||
* @code
|
||||
* uint32 result = LPTMR_PDD_GetInterruptFlag(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define LPTMR_PDD_GetInterruptFlag(PeripheralBase) ( \
|
||||
(uint32)(LPTMR_CSR_REG(PeripheralBase) & LPTMR_CSR_TCF_MASK) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- EnableInterrupt
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Enables the LPT interrupt.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: LPTMR0_CSR.
|
||||
* @par Example:
|
||||
* @code
|
||||
* LPTMR_PDD_EnableInterrupt(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define LPTMR_PDD_EnableInterrupt(PeripheralBase) ( \
|
||||
LPTMR_CSR_REG(PeripheralBase) = \
|
||||
(uint32)(( \
|
||||
(uint32)(LPTMR_CSR_REG(PeripheralBase) | LPTMR_CSR_TIE_MASK)) & ( \
|
||||
(uint32)(~(uint32)LPTMR_CSR_TCF_MASK))) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- DisableInterrupt
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Disables the LPT interrupt.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: LPTMR0_CSR.
|
||||
* @par Example:
|
||||
* @code
|
||||
* LPTMR_PDD_DisableInterrupt(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define LPTMR_PDD_DisableInterrupt(PeripheralBase) ( \
|
||||
LPTMR_CSR_REG(PeripheralBase) &= \
|
||||
(uint32)(( \
|
||||
(uint32)(~(uint32)LPTMR_CSR_TIE_MASK)) & ( \
|
||||
(uint32)(~(uint32)LPTMR_CSR_TCF_MASK))) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- ClearInterruptFlag
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Clears LPT interrupt flag.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: LPTMR0_CSR.
|
||||
* @par Example:
|
||||
* @code
|
||||
* LPTMR_PDD_ClearInterruptFlag(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define LPTMR_PDD_ClearInterruptFlag(PeripheralBase) ( \
|
||||
LPTMR_CSR_REG(PeripheralBase) |= \
|
||||
LPTMR_CSR_TCF_MASK \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- SelectPin
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Sets Timer Pin Select bits.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param TPS_val New value of the TPS. This parameter is of "Timer Pin Select
|
||||
* constants." type.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: LPTMR0_CSR.
|
||||
* @par Example:
|
||||
* @code
|
||||
* LPTMR_PDD_SelectPin(<peripheral>_BASE_PTR, LPTMR_PDD_HSCMP);
|
||||
* @endcode
|
||||
*/
|
||||
#define LPTMR_PDD_SelectPin(PeripheralBase, TPS_val) ( \
|
||||
LPTMR_CSR_REG(PeripheralBase) = \
|
||||
(uint32)(( \
|
||||
(uint32)(( \
|
||||
LPTMR_CSR_REG(PeripheralBase)) & (( \
|
||||
(uint32)(~(uint32)LPTMR_CSR_TPS_MASK)) & ( \
|
||||
(uint32)(~(uint32)LPTMR_CSR_TCF_MASK))))) | ( \
|
||||
(uint32)(TPS_val))) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- SetPinPolarity
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Configures the polarity of the input source.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param Edge New value of the polarity. This parameter is of "Timer Pin
|
||||
* Polarity constants." type.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: LPTMR0_CSR.
|
||||
* @par Example:
|
||||
* @code
|
||||
* LPTMR_PDD_SetPinPolarity(<peripheral>_BASE_PTR,
|
||||
* LPTMR_PDD_POLARITY_RISING);
|
||||
* @endcode
|
||||
*/
|
||||
#define LPTMR_PDD_SetPinPolarity(PeripheralBase, Edge) ( \
|
||||
LPTMR_CSR_REG(PeripheralBase) = \
|
||||
(uint32)(( \
|
||||
(uint32)(( \
|
||||
LPTMR_CSR_REG(PeripheralBase)) & (( \
|
||||
(uint32)(~(uint32)LPTMR_CSR_TPP_MASK)) & ( \
|
||||
(uint32)(~(uint32)LPTMR_CSR_TCF_MASK))))) | ( \
|
||||
(uint32)(Edge))) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- EnableFreerun
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Configures the freerun mode.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param Restart New value of the restart. Use constants from group "Enable
|
||||
* freerun constants". This parameter is 32 bits wide.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: LPTMR0_CSR.
|
||||
* @par Example:
|
||||
* @code
|
||||
* LPTMR_PDD_EnableFreerun(<peripheral>_BASE_PTR,
|
||||
* LPTMR_PDD_RESTART_ENABLED);
|
||||
* @endcode
|
||||
*/
|
||||
#define LPTMR_PDD_EnableFreerun(PeripheralBase, Restart) ( \
|
||||
LPTMR_CSR_REG(PeripheralBase) = \
|
||||
(uint32)(( \
|
||||
(uint32)(( \
|
||||
LPTMR_CSR_REG(PeripheralBase)) & (( \
|
||||
(uint32)(~(uint32)LPTMR_CSR_TFC_MASK)) & ( \
|
||||
(uint32)(~(uint32)LPTMR_CSR_TCF_MASK))))) | ( \
|
||||
(uint32)(Restart))) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- SetTimerMode
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Selects timer mode.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param Source New value of the source. Use constants from group "Timer mode
|
||||
* constants". This parameter is 32 bits wide.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: LPTMR0_CSR.
|
||||
* @par Example:
|
||||
* @code
|
||||
* LPTMR_PDD_SetTimerMode(<peripheral>_BASE_PTR,
|
||||
* LPTMR_PDD_SOURCE_INTERNAL);
|
||||
* @endcode
|
||||
*/
|
||||
#define LPTMR_PDD_SetTimerMode(PeripheralBase, Source) ( \
|
||||
LPTMR_CSR_REG(PeripheralBase) = \
|
||||
(uint32)(( \
|
||||
(uint32)(( \
|
||||
LPTMR_CSR_REG(PeripheralBase)) & (( \
|
||||
(uint32)(~(uint32)LPTMR_CSR_TMS_MASK)) & ( \
|
||||
(uint32)(~(uint32)LPTMR_CSR_TCF_MASK))))) | ( \
|
||||
(uint32)(Source))) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- EnableDevice
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Enables the LPT device.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param State Requested state of LPT device. This parameter is of "Global
|
||||
* enumeration used for specifying general enable/disable states (PDD_DISABLE
|
||||
* and PDD_ENABLE defined in PDD_Types.h)" type.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: LPTMR0_CSR.
|
||||
* @par Example:
|
||||
* @code
|
||||
* LPTMR_PDD_EnableDevice(<peripheral>_BASE_PTR, PDD_DISABLE);
|
||||
* @endcode
|
||||
*/
|
||||
#define LPTMR_PDD_EnableDevice(PeripheralBase, State) ( \
|
||||
LPTMR_CSR_REG(PeripheralBase) = \
|
||||
(uint32)(( \
|
||||
(uint32)(( \
|
||||
LPTMR_CSR_REG(PeripheralBase)) & (( \
|
||||
(uint32)(~(uint32)LPTMR_CSR_TEN_MASK)) & ( \
|
||||
(uint32)(~(uint32)LPTMR_CSR_TCF_MASK))))) | ( \
|
||||
(uint32)(State))) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- GetEnableDeviceStatus
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Returns current state of LPT device.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a 32-bit value.
|
||||
* @remarks The macro accesses the following registers: LPTMR0_CSR.
|
||||
* @par Example:
|
||||
* @code
|
||||
* uint32 result =
|
||||
* LPTMR_PDD_GetEnableDeviceStatus(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define LPTMR_PDD_GetEnableDeviceStatus(PeripheralBase) ( \
|
||||
(uint32)(LPTMR_CSR_REG(PeripheralBase) & LPTMR_CSR_TEN_MASK) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- SetPrescaler
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Sets prescale value.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param Prescaler New value of the prescaler. Use constants from group
|
||||
* "Prescaler/Filter constants". This parameter is 4 bits wide.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: LPTMR0_PSR.
|
||||
* @par Example:
|
||||
* @code
|
||||
* LPTMR_PDD_SetPrescaler(<peripheral>_BASE_PTR, LPTMR_PDD_PRESCALER_2);
|
||||
* @endcode
|
||||
*/
|
||||
#define LPTMR_PDD_SetPrescaler(PeripheralBase, Prescaler) ( \
|
||||
LPTMR_PSR_REG(PeripheralBase) = \
|
||||
(uint32)(( \
|
||||
(uint32)(LPTMR_PSR_REG(PeripheralBase) & (uint32)(~(uint32)LPTMR_PSR_PRESCALE_MASK))) | ( \
|
||||
(uint32)((uint32)(Prescaler) << LPTMR_PSR_PRESCALE_SHIFT))) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- EnablePrescalerBypass
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Sets prescaler bypass.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param Bypass New value of the bypass. This parameter is of "Prescaler bypass
|
||||
* constants." type.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: LPTMR0_PSR.
|
||||
* @par Example:
|
||||
* @code
|
||||
* LPTMR_PDD_EnablePrescalerBypass(<peripheral>_BASE_PTR,
|
||||
* LPTMR_PDD_BYPASS_DISABLED);
|
||||
* @endcode
|
||||
*/
|
||||
#define LPTMR_PDD_EnablePrescalerBypass(PeripheralBase, Bypass) ( \
|
||||
LPTMR_PSR_REG(PeripheralBase) = \
|
||||
(uint32)(( \
|
||||
(uint32)(LPTMR_PSR_REG(PeripheralBase) & (uint32)(~(uint32)LPTMR_PSR_PBYP_MASK))) | ( \
|
||||
(uint32)(Bypass))) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- SetDivider
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Sets both prescale value and bypass value.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param Divider New value of the divider. Use constants from group "Divider
|
||||
* constants". This parameter is 5 bits wide.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: LPTMR0_PSR.
|
||||
* @par Example:
|
||||
* @code
|
||||
* LPTMR_PDD_SetDivider(<peripheral>_BASE_PTR, LPTMR_PDD_DIVIDER_1);
|
||||
* @endcode
|
||||
*/
|
||||
#define LPTMR_PDD_SetDivider(PeripheralBase, Divider) ( \
|
||||
LPTMR_PSR_REG(PeripheralBase) = \
|
||||
(uint32)(( \
|
||||
(uint32)(( \
|
||||
LPTMR_PSR_REG(PeripheralBase)) & (( \
|
||||
(uint32)(~(uint32)LPTMR_PSR_PRESCALE_MASK)) & ( \
|
||||
(uint32)(~(uint32)LPTMR_PSR_PBYP_MASK))))) | (( \
|
||||
(uint32)((uint32)((uint32)(Divider) >> 1U) << LPTMR_PSR_PRESCALE_SHIFT)) | ( \
|
||||
(uint32)((uint32)((uint32)(Divider) & 0x1U) << LPTMR_PSR_PBYP_SHIFT)))) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- SelectPrescalerSource
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Selects clock source.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param Source New value of the source. This parameter is of "Clock source
|
||||
* constants." type.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: LPTMR0_PSR.
|
||||
* @par Example:
|
||||
* @code
|
||||
* LPTMR_PDD_SelectPrescalerSource(<peripheral>_BASE_PTR,
|
||||
* LPTMR_PDD_SOURCE_INTREF);
|
||||
* @endcode
|
||||
*/
|
||||
#define LPTMR_PDD_SelectPrescalerSource(PeripheralBase, Source) ( \
|
||||
LPTMR_PSR_REG(PeripheralBase) = \
|
||||
(uint32)(( \
|
||||
(uint32)(LPTMR_PSR_REG(PeripheralBase) & (uint32)(~(uint32)LPTMR_PSR_PCS_MASK))) | ( \
|
||||
(uint32)(Source))) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- WriteCompareReg
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Writes value to the compare register.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param Value New content of the compare register. This parameter is a 32-bit
|
||||
* value.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: LPTMR0_CMR.
|
||||
* @par Example:
|
||||
* @code
|
||||
* LPTMR_PDD_WriteCompareReg(<peripheral>_BASE_PTR, 1);
|
||||
* @endcode
|
||||
*/
|
||||
#define LPTMR_PDD_WriteCompareReg(PeripheralBase, Value) ( \
|
||||
LPTMR_CMR_REG(PeripheralBase) = \
|
||||
(uint32)(Value) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- ReadCompareReg
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Returns the content of the compare register.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a 32-bit value.
|
||||
* @remarks The macro accesses the following registers: LPTMR0_CMR.
|
||||
* @par Example:
|
||||
* @code
|
||||
* uint32 result = LPTMR_PDD_ReadCompareReg(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define LPTMR_PDD_ReadCompareReg(PeripheralBase) ( \
|
||||
LPTMR_CMR_REG(PeripheralBase) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- ReadCounterReg
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
#if ((defined(MCU_MK10DZ10)) || (defined(MCU_MK20DZ10)) || (defined(MCU_MK30DZ10)) || (defined(MCU_MK40DZ10)) || (defined(MCU_MK40X256VMD100)) || (defined(MCU_MK50DZ10)) || (defined(MCU_MK51DZ10)) || (defined(MCU_MK52DZ10)) || (defined(MCU_MK53DZ10)) || (defined(MCU_MK60DZ10)) || (defined(MCU_MK60N512VMD100)))
|
||||
/**
|
||||
* @brief Returns the content of the counter register.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a 32-bit value.
|
||||
* @remarks The macro accesses the following registers: LPTMR0_CNR.
|
||||
* @par Example:
|
||||
* @code
|
||||
* uint32 result = LPTMR_PDD_ReadCounterReg(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define LPTMR_PDD_ReadCounterReg(PeripheralBase) ( \
|
||||
LPTMR_CNR_REG(PeripheralBase) \
|
||||
)
|
||||
#else /* (defined(MCU_MK10D10)) || (defined(MCU_MK10D5)) || (defined(MCU_MK10D7)) || (defined(MCU_MK10F12)) || (defined(MCU_MK11D5)) || (defined(MCU_MK11D5WS)) || (defined(MCU_MK12D5)) || (defined(MCU_MK20D10)) || (defined(MCU_MK20D5)) || (defined(MCU_MK20D7)) || (defined(MCU_MK20F12)) || (defined(MCU_MK21D5)) || (defined(MCU_MK21D5WS)) || (defined(MCU_MK21F12)) || (defined(MCU_MK21F12WS)) || (defined(MCU_MK22D5)) || (defined(MCU_MK22F12)) || (defined(MCU_MK22F12810)) || (defined(MCU_MK22F25612)) || (defined(MCU_MK22F51212)) || (defined(MCU_MK24F12)) || (defined(MCU_MK30D10)) || (defined(MCU_MK30D7)) || (defined(MCU_MK40D10)) || (defined(MCU_MK40D7)) || (defined(MCU_MK50D10)) || (defined(MCU_MK50D7)) || (defined(MCU_MK51D10)) || (defined(MCU_MK51D7)) || (defined(MCU_MK52D10)) || (defined(MCU_MK53D10)) || (defined(MCU_MK60D10)) || (defined(MCU_MK60F12)) || (defined(MCU_MK60F15)) || (defined(MCU_MK61F12)) || (defined(MCU_MK61F12WS)) || (defined(MCU_MK61F15)) || (defined(MCU_MK61F15WS)) || (defined(MCU_MK63F12)) || (defined(MCU_MK63F12WS)) || (defined(MCU_MK64F12)) || (defined(MCU_MK65F18)) || (defined(MCU_MK65F18WS)) || (defined(MCU_MK66F18)) || (defined(MCU_MK70F12)) || (defined(MCU_MK70F12WS)) || (defined(MCU_MK70F15)) || (defined(MCU_MK70F15WS)) || (defined(MCU_MKL02Z4)) || (defined(MCU_MKL03Z4)) || (defined(MCU_MKL04Z4)) || (defined(MCU_MKL05Z4)) || (defined(MCU_MKL14Z4)) || (defined(MCU_MKL15Z4)) || (defined(MCU_MKL16Z4)) || (defined(MCU_MKL24Z4)) || (defined(MCU_MKL25Z4)) || (defined(MCU_MKL26Z4)) || (defined(MCU_MKL34Z4)) || (defined(MCU_MKL36Z4)) || (defined(MCU_MKL46Z4)) || (defined(MCU_MKV10Z7)) || (defined(MCU_MKV31F12810)) || (defined(MCU_MKV31F25612)) || (defined(MCU_MKV31F51212)) || (defined(MCU_MKW01Z4)) || (defined(MCU_MKW21D5)) || (defined(MCU_MKW21D5WS)) || (defined(MCU_MKW22D5)) || (defined(MCU_MKW22D5WS)) || (defined(MCU_MKW24D5)) || (defined(MCU_MKW24D5WS)) || (defined(MCU_PCK20L4)) */
|
||||
/**
|
||||
* @brief Returns the content of the counter register.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a 32-bit value.
|
||||
* @remarks The macro accesses the following registers: LPTMR0_CNR.
|
||||
* @par Example:
|
||||
* @code
|
||||
* uint32 result = LPTMR_PDD_ReadCounterReg(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define LPTMR_PDD_ReadCounterReg(PeripheralBase) ( \
|
||||
(LPTMR_CNR_REG(PeripheralBase) = \
|
||||
0U), \
|
||||
LPTMR_CNR_REG(PeripheralBase) \
|
||||
)
|
||||
#endif /* (defined(MCU_MK10D10)) || (defined(MCU_MK10D5)) || (defined(MCU_MK10D7)) || (defined(MCU_MK10F12)) || (defined(MCU_MK11D5)) || (defined(MCU_MK11D5WS)) || (defined(MCU_MK12D5)) || (defined(MCU_MK20D10)) || (defined(MCU_MK20D5)) || (defined(MCU_MK20D7)) || (defined(MCU_MK20F12)) || (defined(MCU_MK21D5)) || (defined(MCU_MK21D5WS)) || (defined(MCU_MK21F12)) || (defined(MCU_MK21F12WS)) || (defined(MCU_MK22D5)) || (defined(MCU_MK22F12)) || (defined(MCU_MK22F12810)) || (defined(MCU_MK22F25612)) || (defined(MCU_MK22F51212)) || (defined(MCU_MK24F12)) || (defined(MCU_MK30D10)) || (defined(MCU_MK30D7)) || (defined(MCU_MK40D10)) || (defined(MCU_MK40D7)) || (defined(MCU_MK50D10)) || (defined(MCU_MK50D7)) || (defined(MCU_MK51D10)) || (defined(MCU_MK51D7)) || (defined(MCU_MK52D10)) || (defined(MCU_MK53D10)) || (defined(MCU_MK60D10)) || (defined(MCU_MK60F12)) || (defined(MCU_MK60F15)) || (defined(MCU_MK61F12)) || (defined(MCU_MK61F12WS)) || (defined(MCU_MK61F15)) || (defined(MCU_MK61F15WS)) || (defined(MCU_MK63F12)) || (defined(MCU_MK63F12WS)) || (defined(MCU_MK64F12)) || (defined(MCU_MK65F18)) || (defined(MCU_MK65F18WS)) || (defined(MCU_MK66F18)) || (defined(MCU_MK70F12)) || (defined(MCU_MK70F12WS)) || (defined(MCU_MK70F15)) || (defined(MCU_MK70F15WS)) || (defined(MCU_MKL02Z4)) || (defined(MCU_MKL03Z4)) || (defined(MCU_MKL04Z4)) || (defined(MCU_MKL05Z4)) || (defined(MCU_MKL14Z4)) || (defined(MCU_MKL15Z4)) || (defined(MCU_MKL16Z4)) || (defined(MCU_MKL24Z4)) || (defined(MCU_MKL25Z4)) || (defined(MCU_MKL26Z4)) || (defined(MCU_MKL34Z4)) || (defined(MCU_MKL36Z4)) || (defined(MCU_MKL46Z4)) || (defined(MCU_MKV10Z7)) || (defined(MCU_MKV31F12810)) || (defined(MCU_MKV31F25612)) || (defined(MCU_MKV31F51212)) || (defined(MCU_MKW01Z4)) || (defined(MCU_MKW21D5)) || (defined(MCU_MKW21D5WS)) || (defined(MCU_MKW22D5)) || (defined(MCU_MKW22D5WS)) || (defined(MCU_MKW24D5)) || (defined(MCU_MKW24D5WS)) || (defined(MCU_PCK20L4)) */
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- WriteControlStatusReg
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Writes value to the control status register.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param Value New content of the control status register. This parameter is a
|
||||
* 32-bit value.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: LPTMR0_CSR.
|
||||
* @par Example:
|
||||
* @code
|
||||
* LPTMR_PDD_WriteControlStatusReg(<peripheral>_BASE_PTR, 1);
|
||||
* @endcode
|
||||
*/
|
||||
#define LPTMR_PDD_WriteControlStatusReg(PeripheralBase, Value) ( \
|
||||
LPTMR_CSR_REG(PeripheralBase) = \
|
||||
(uint32)(Value) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- ReadControlStatusReg
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Returns the content of the control status register.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a 32-bit value.
|
||||
* @remarks The macro accesses the following registers: LPTMR0_CSR.
|
||||
* @par Example:
|
||||
* @code
|
||||
* uint32 result = LPTMR_PDD_ReadControlStatusReg(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define LPTMR_PDD_ReadControlStatusReg(PeripheralBase) ( \
|
||||
LPTMR_CSR_REG(PeripheralBase) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- WritePrescaleReg
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Writes value to the prescale register.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param Value New content of the prescale register. This parameter is a 32-bit
|
||||
* value.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: LPTMR0_PSR.
|
||||
* @par Example:
|
||||
* @code
|
||||
* LPTMR_PDD_WritePrescaleReg(<peripheral>_BASE_PTR, 1);
|
||||
* @endcode
|
||||
*/
|
||||
#define LPTMR_PDD_WritePrescaleReg(PeripheralBase, Value) ( \
|
||||
LPTMR_PSR_REG(PeripheralBase) = \
|
||||
(uint32)(Value) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- ReadPrescaleReg
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Returns the content of the prescale register.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a 32-bit value.
|
||||
* @remarks The macro accesses the following registers: LPTMR0_PSR.
|
||||
* @par Example:
|
||||
* @code
|
||||
* uint32 result = LPTMR_PDD_ReadPrescaleReg(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define LPTMR_PDD_ReadPrescaleReg(PeripheralBase) ( \
|
||||
LPTMR_PSR_REG(PeripheralBase) \
|
||||
)
|
||||
#endif /* #if defined(LPTMR_PDD_H_) */
|
||||
|
||||
/* LPTMR_PDD.h, eof. */
|
||||
@@ -0,0 +1,787 @@
|
||||
/*
|
||||
PDD layer implementation for peripheral type MCM
|
||||
(C) 2013 Freescale, Inc. All rights reserved.
|
||||
|
||||
This file is static and it is generated from API-Factory
|
||||
*/
|
||||
|
||||
#if !defined(MCM_PDD_H_)
|
||||
#define MCM_PDD_H_
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- Test if supported MCU is active
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
#if !defined(MCU_ACTIVE)
|
||||
// No MCU is active
|
||||
#error MCM PDD library: No derivative is active. Place proper #include with PDD memory map before including PDD library.
|
||||
#elif \
|
||||
!defined(MCU_MK10D10) /* MCM */ && \
|
||||
!defined(MCU_MK10D7) /* MCM */ && \
|
||||
!defined(MCU_MK10F12) /* MCM */ && \
|
||||
!defined(MCU_MK10DZ10) /* MCM */ && \
|
||||
!defined(MCU_MK11D5) /* MCM */ && \
|
||||
!defined(MCU_MK11D5WS) /* MCM */ && \
|
||||
!defined(MCU_MK12D5) /* MCM */ && \
|
||||
!defined(MCU_MK20D10) /* MCM */ && \
|
||||
!defined(MCU_MK20D7) /* MCM */ && \
|
||||
!defined(MCU_MK20F12) /* MCM */ && \
|
||||
!defined(MCU_MK20DZ10) /* MCM */ && \
|
||||
!defined(MCU_MK21D5) /* MCM */ && \
|
||||
!defined(MCU_MK21D5WS) /* MCM */ && \
|
||||
!defined(MCU_MK21F12) /* MCM */ && \
|
||||
!defined(MCU_MK21F12WS) /* MCM */ && \
|
||||
!defined(MCU_MK22D5) /* MCM */ && \
|
||||
!defined(MCU_MK22F12810) /* MCM */ && \
|
||||
!defined(MCU_MK22F12) /* MCM */ && \
|
||||
!defined(MCU_MK22F25612) /* MCM */ && \
|
||||
!defined(MCU_MK22F51212) /* MCM */ && \
|
||||
!defined(MCU_MK24F12) /* MCM */ && \
|
||||
!defined(MCU_MK30D10) /* MCM */ && \
|
||||
!defined(MCU_MK30D7) /* MCM */ && \
|
||||
!defined(MCU_MK30DZ10) /* MCM */ && \
|
||||
!defined(MCU_MK40D10) /* MCM */ && \
|
||||
!defined(MCU_MK40D7) /* MCM */ && \
|
||||
!defined(MCU_MK40DZ10) /* MCM */ && \
|
||||
!defined(MCU_MK40X256VMD100) /* MCM */ && \
|
||||
!defined(MCU_MK50D10) /* MCM */ && \
|
||||
!defined(MCU_MK50D7) /* MCM */ && \
|
||||
!defined(MCU_MK50DZ10) /* MCM */ && \
|
||||
!defined(MCU_MK51D10) /* MCM */ && \
|
||||
!defined(MCU_MK51D7) /* MCM */ && \
|
||||
!defined(MCU_MK51DZ10) /* MCM */ && \
|
||||
!defined(MCU_MK52D10) /* MCM */ && \
|
||||
!defined(MCU_MK52DZ10) /* MCM */ && \
|
||||
!defined(MCU_MK53D10) /* MCM */ && \
|
||||
!defined(MCU_MK53DZ10) /* MCM */ && \
|
||||
!defined(MCU_MK60D10) /* MCM */ && \
|
||||
!defined(MCU_MK60F12) /* MCM */ && \
|
||||
!defined(MCU_MK60F15) /* MCM */ && \
|
||||
!defined(MCU_MK60DZ10) /* MCM */ && \
|
||||
!defined(MCU_MK60N512VMD100) /* MCM */ && \
|
||||
!defined(MCU_MK61F12) /* MCM */ && \
|
||||
!defined(MCU_MK61F15) /* MCM */ && \
|
||||
!defined(MCU_MK61F12WS) /* MCM */ && \
|
||||
!defined(MCU_MK61F15WS) /* MCM */ && \
|
||||
!defined(MCU_MK63F12) /* MCM */ && \
|
||||
!defined(MCU_MK63F12WS) /* MCM */ && \
|
||||
!defined(MCU_MK64F12) /* MCM */ && \
|
||||
!defined(MCU_MK65F18) /* MCM */ && \
|
||||
!defined(MCU_MK65F18WS) /* MCM */ && \
|
||||
!defined(MCU_MK66F18) /* MCM */ && \
|
||||
!defined(MCU_MK70F12) /* MCM */ && \
|
||||
!defined(MCU_MK70F15) /* MCM */ && \
|
||||
!defined(MCU_MK70F12WS) /* MCM */ && \
|
||||
!defined(MCU_MK70F15WS) /* MCM */ && \
|
||||
!defined(MCU_MKE02Z2) /* MCM */ && \
|
||||
!defined(MCU_MKE02Z4) /* MCM */ && \
|
||||
!defined(MCU_SKEAZN642) /* MCM */ && \
|
||||
!defined(MCU_MKE04Z1284) /* MCM */ && \
|
||||
!defined(MCU_MKE04Z4) /* MCM */ && \
|
||||
!defined(MCU_SKEAZN84) /* MCM */ && \
|
||||
!defined(MCU_MKE06Z4) /* MCM */ && \
|
||||
!defined(MCU_MKL02Z4) /* MCM */ && \
|
||||
!defined(MCU_MKL03Z4) /* MCM */ && \
|
||||
!defined(MCU_MKL04Z4) /* MCM */ && \
|
||||
!defined(MCU_MKL05Z4) /* MCM */ && \
|
||||
!defined(MCU_MKL14Z4) /* MCM */ && \
|
||||
!defined(MCU_MKL15Z4) /* MCM */ && \
|
||||
!defined(MCU_MKL16Z4) /* MCM */ && \
|
||||
!defined(MCU_MKL24Z4) /* MCM */ && \
|
||||
!defined(MCU_MKL25Z4) /* MCM */ && \
|
||||
!defined(MCU_MKL26Z4) /* MCM */ && \
|
||||
!defined(MCU_MKL34Z4) /* MCM */ && \
|
||||
!defined(MCU_MKL36Z4) /* MCM */ && \
|
||||
!defined(MCU_MKL46Z4) /* MCM */ && \
|
||||
!defined(MCU_MKV10Z7) /* MCM */ && \
|
||||
!defined(MCU_MKV31F12810) /* MCM */ && \
|
||||
!defined(MCU_MKV31F25612) /* MCM */ && \
|
||||
!defined(MCU_MKV31F51212) /* MCM */ && \
|
||||
!defined(MCU_MKW01Z4) /* MCM */ && \
|
||||
!defined(MCU_MKW21D5) /* MCM */ && \
|
||||
!defined(MCU_MKW21D5WS) /* MCM */ && \
|
||||
!defined(MCU_MKW22D5) /* MCM */ && \
|
||||
!defined(MCU_MKW22D5WS) /* MCM */ && \
|
||||
!defined(MCU_MKW24D5) /* MCM */ && \
|
||||
!defined(MCU_MKW24D5WS) /* MCM */ && \
|
||||
!defined(MCU_SKEAZ1284) /* MCM */
|
||||
// Unsupported MCU is active
|
||||
#error MCM PDD library: Unsupported derivative is active.
|
||||
#endif
|
||||
|
||||
#include "PDD_Types.h"
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- Method symbol definitions
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/* Slave bus connection to AXBS input port masks constants (for
|
||||
GetSlaveBusConnectionToAxbsInputPort macro). */
|
||||
#define MCM_PDD_SLAVE_BUS_CONNECTION_TO_AXBS_INPUT_PORT_0 0x1U /**< A bus slave connection to AXBS input port 0 is present */
|
||||
#define MCM_PDD_SLAVE_BUS_CONNECTION_TO_AXBS_INPUT_PORT_1 0x2U /**< A bus slave connection to AXBS input port 1 is present */
|
||||
#define MCM_PDD_SLAVE_BUS_CONNECTION_TO_AXBS_INPUT_PORT_2 0x4U /**< A bus slave connection to AXBS input port 2 is present */
|
||||
#define MCM_PDD_SLAVE_BUS_CONNECTION_TO_AXBS_INPUT_PORT_3 0x8U /**< A bus slave connection to AXBS input port 3 is present */
|
||||
#define MCM_PDD_SLAVE_BUS_CONNECTION_TO_AXBS_INPUT_PORT_4 0x10U /**< A bus slave connection to AXBS input port 4 is present */
|
||||
#define MCM_PDD_SLAVE_BUS_CONNECTION_TO_AXBS_INPUT_PORT_5 0x20U /**< A bus slave connection to AXBS input port 5 is present */
|
||||
#define MCM_PDD_SLAVE_BUS_CONNECTION_TO_AXBS_INPUT_PORT_6 0x40U /**< A bus slave connection to AXBS input port 6 is present */
|
||||
#define MCM_PDD_SLAVE_BUS_CONNECTION_TO_AXBS_INPUT_PORT_7 0x80U /**< A bus slave connection to AXBS input port 7 is present */
|
||||
|
||||
/* Master bus connection to AXBS input port masks constants (for
|
||||
GetMasterBusConnectionToAxbsInputPortMask macro). */
|
||||
#define MCM_PDD_MASTER_BUS_CONNECTION_TO_AXBS_INPUT_PORT_0 0x1U /**< A bus master connection to AXBS input port 0 is present */
|
||||
#define MCM_PDD_MASTER_BUS_CONNECTION_TO_AXBS_INPUT_PORT_1 0x2U /**< A bus master connection to AXBS input port 1 is present */
|
||||
#define MCM_PDD_MASTER_BUS_CONNECTION_TO_AXBS_INPUT_PORT_2 0x4U /**< A bus master connection to AXBS input port 2 is present */
|
||||
#define MCM_PDD_MASTER_BUS_CONNECTION_TO_AXBS_INPUT_PORT_3 0x8U /**< A bus master connection to AXBS input port 3 is present */
|
||||
#define MCM_PDD_MASTER_BUS_CONNECTION_TO_AXBS_INPUT_PORT_4 0x10U /**< A bus master connection to AXBS input port 4 is present */
|
||||
#define MCM_PDD_MASTER_BUS_CONNECTION_TO_AXBS_INPUT_PORT_5 0x20U /**< A bus master connection to AXBS input port 5 is present */
|
||||
#define MCM_PDD_MASTER_BUS_CONNECTION_TO_AXBS_INPUT_PORT_6 0x40U /**< A bus master connection to AXBS input port 6 is present */
|
||||
#define MCM_PDD_MASTER_BUS_CONNECTION_TO_AXBS_INPUT_PORT_7 0x80U /**< A bus master connection to AXBS input port 7 is present */
|
||||
|
||||
#if ((defined(MCU_MK11D5)) || (defined(MCU_MK11D5WS)) || (defined(MCU_MK12D5)) || (defined(MCU_MK21D5)) || (defined(MCU_MK21D5WS)) || (defined(MCU_MK21F12)) || (defined(MCU_MK21F12WS)) || (defined(MCU_MK22D5)) || (defined(MCU_MK22F12)) || (defined(MCU_MK22F12810)) || (defined(MCU_MK22F25612)) || (defined(MCU_MK22F51212)) || (defined(MCU_MKL02Z4)) || (defined(MCU_MKL04Z4)) || (defined(MCU_MKL05Z4)) || (defined(MCU_MKL14Z4)) || (defined(MCU_MKL15Z4)) || (defined(MCU_MKL16Z4)) || (defined(MCU_MKL24Z4)) || (defined(MCU_MKL25Z4)) || (defined(MCU_MKL26Z4)) || (defined(MCU_MKL34Z4)) || (defined(MCU_MKL36Z4)) || (defined(MCU_MKL46Z4)) || (defined(MCU_MKV10Z7)) || (defined(MCU_MKV31F12810)) || (defined(MCU_MKV31F25612)) || (defined(MCU_MKV31F51212)) || (defined(MCU_MKW01Z4)) || (defined(MCU_MKW21D5)) || (defined(MCU_MKW21D5WS)) || (defined(MCU_MKW22D5)) || (defined(MCU_MKW22D5WS)) || (defined(MCU_MKW24D5)) || (defined(MCU_MKW24D5WS)))
|
||||
/* Crossbar master arbitration type */
|
||||
#define MCM_PDD_FIXED_PRIORITY 0U /**< Fixed-priority arbitration for the crossbar masters */
|
||||
#define MCM_PDD_ROUND_ROBIN 0x200U /**< Round-robin arbitration for the crossbar masters */
|
||||
|
||||
#else /* (defined(MCU_MK10D10)) || (defined(MCU_MK10D7)) || (defined(MCU_MK10DZ10)) || (defined(MCU_MK10F12)) || (defined(MCU_MK20D10)) || (defined(MCU_MK20D7)) || (defined(MCU_MK20DZ10)) || (defined(MCU_MK20F12)) || (defined(MCU_MK24F12)) || (defined(MCU_MK30D10)) || (defined(MCU_MK30D7)) || (defined(MCU_MK30DZ10)) || (defined(MCU_MK40D10)) || (defined(MCU_MK40D7)) || (defined(MCU_MK40DZ10)) || (defined(MCU_MK40X256VMD100)) || (defined(MCU_MK50D10)) || (defined(MCU_MK50D7)) || (defined(MCU_MK50DZ10)) || (defined(MCU_MK51D10)) || (defined(MCU_MK51D7)) || (defined(MCU_MK51DZ10)) || (defined(MCU_MK52D10)) || (defined(MCU_MK52DZ10)) || (defined(MCU_MK53D10)) || (defined(MCU_MK53DZ10)) || (defined(MCU_MK60D10)) || (defined(MCU_MK60DZ10)) || (defined(MCU_MK60F12)) || (defined(MCU_MK60F15)) || (defined(MCU_MK60N512VMD100)) || (defined(MCU_MK61F12)) || (defined(MCU_MK61F12WS)) || (defined(MCU_MK61F15)) || (defined(MCU_MK61F15WS)) || (defined(MCU_MK63F12)) || (defined(MCU_MK63F12WS)) || (defined(MCU_MK64F12)) || (defined(MCU_MK65F18)) || (defined(MCU_MK65F18WS)) || (defined(MCU_MK66F18)) || (defined(MCU_MK70F12)) || (defined(MCU_MK70F12WS)) || (defined(MCU_MK70F15)) || (defined(MCU_MK70F15WS)) */
|
||||
/* Crossbar master arbitration type */
|
||||
#define MCM_PDD_FIXED_PRIORITY 0U /**< Fixed-priority arbitration for the crossbar masters */
|
||||
#define MCM_PDD_ROUND_ROBIN 0x1U /**< Round-robin arbitration for the crossbar masters */
|
||||
|
||||
#endif /* (defined(MCU_MK10D10)) || (defined(MCU_MK10D7)) || (defined(MCU_MK10DZ10)) || (defined(MCU_MK10F12)) || (defined(MCU_MK20D10)) || (defined(MCU_MK20D7)) || (defined(MCU_MK20DZ10)) || (defined(MCU_MK20F12)) || (defined(MCU_MK24F12)) || (defined(MCU_MK30D10)) || (defined(MCU_MK30D7)) || (defined(MCU_MK30DZ10)) || (defined(MCU_MK40D10)) || (defined(MCU_MK40D7)) || (defined(MCU_MK40DZ10)) || (defined(MCU_MK40X256VMD100)) || (defined(MCU_MK50D10)) || (defined(MCU_MK50D7)) || (defined(MCU_MK50DZ10)) || (defined(MCU_MK51D10)) || (defined(MCU_MK51D7)) || (defined(MCU_MK51DZ10)) || (defined(MCU_MK52D10)) || (defined(MCU_MK52DZ10)) || (defined(MCU_MK53D10)) || (defined(MCU_MK53DZ10)) || (defined(MCU_MK60D10)) || (defined(MCU_MK60DZ10)) || (defined(MCU_MK60F12)) || (defined(MCU_MK60F15)) || (defined(MCU_MK60N512VMD100)) || (defined(MCU_MK61F12)) || (defined(MCU_MK61F12WS)) || (defined(MCU_MK61F15)) || (defined(MCU_MK61F15WS)) || (defined(MCU_MK63F12)) || (defined(MCU_MK63F12WS)) || (defined(MCU_MK64F12)) || (defined(MCU_MK65F18)) || (defined(MCU_MK65F18WS)) || (defined(MCU_MK66F18)) || (defined(MCU_MK70F12)) || (defined(MCU_MK70F12WS)) || (defined(MCU_MK70F15)) || (defined(MCU_MK70F15WS)) */
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- GetSlaveBusConnectionToAxbsInputPortMask
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Returns present mask value of a corresponding connection to the
|
||||
* crossbar switch's slave input port.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a 8-bit value.
|
||||
* @remarks The macro accesses the following registers: MCM_PLASC.
|
||||
* @par Example:
|
||||
* @code
|
||||
* uint8 result =
|
||||
* MCM_PDD_GetSlaveBusConnectionToAxbsInputPortMask(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define MCM_PDD_GetSlaveBusConnectionToAxbsInputPortMask(PeripheralBase) ( \
|
||||
(uint8)(MCM_PLASC_REG(PeripheralBase) & MCM_PLASC_ASC_MASK) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- ReadCrossbarSwitchSlaveConfigurationReg
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Reads crossbar switch (AXBS) slave configuration register.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a 16-bit value.
|
||||
* @remarks The macro accesses the following registers: MCM_PLASC.
|
||||
* @par Example:
|
||||
* @code
|
||||
* uint16 result =
|
||||
* MCM_PDD_ReadCrossbarSwitchSlaveConfigurationReg(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define MCM_PDD_ReadCrossbarSwitchSlaveConfigurationReg(PeripheralBase) ( \
|
||||
MCM_PLASC_REG(PeripheralBase) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- GetMasterBusConnectionToAxbsInputPortMask
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Returns present mask value of a corresponding connection to the
|
||||
* crossbar switch's master input port.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a 8-bit value.
|
||||
* @remarks The macro accesses the following registers: MCM_PLAMC.
|
||||
* @par Example:
|
||||
* @code
|
||||
* uint8 result =
|
||||
* MCM_PDD_GetMasterBusConnectionToAxbsInputPortMask(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define MCM_PDD_GetMasterBusConnectionToAxbsInputPortMask(PeripheralBase) ( \
|
||||
(uint8)(MCM_PLAMC_REG(PeripheralBase) & MCM_PLAMC_AMC_MASK) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- ReadCrossbarSwitchMasterConfigurationReg
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Reads crossbar switch (AXBS) master configuration register.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a 16-bit value.
|
||||
* @remarks The macro accesses the following registers: MCM_PLAMC.
|
||||
* @par Example:
|
||||
* @code
|
||||
* uint16 result =
|
||||
* MCM_PDD_ReadCrossbarSwitchMasterConfigurationReg(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define MCM_PDD_ReadCrossbarSwitchMasterConfigurationReg(PeripheralBase) ( \
|
||||
MCM_PLAMC_REG(PeripheralBase) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- SetCrossbarMastersArbitrationType
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Selects arbitration type for crossbar masters.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param State Crossbar masters arbitration type. This parameter is of
|
||||
* "Crossbar master arbitration type" type.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: MCM_PLACR.
|
||||
* @par Example:
|
||||
* @code
|
||||
* MCM_PDD_SetCrossbarMastersArbitrationType(<peripheral>_BASE_PTR,
|
||||
* MCM_PDD_FIXED_PRIORITY);
|
||||
* @endcode
|
||||
*/
|
||||
#define MCM_PDD_SetCrossbarMastersArbitrationType(PeripheralBase, State) ( \
|
||||
MCM_PLACR_REG(PeripheralBase) = \
|
||||
(uint32)(( \
|
||||
(uint32)(MCM_PLACR_REG(PeripheralBase) & (uint32)(~(uint32)MCM_PLACR_ARB_MASK))) | ( \
|
||||
(uint32)(State))) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- ReadPlatformControlReg
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Reads platform control register.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a 32-bit value.
|
||||
* @remarks The macro accesses the following registers: MCM_PLACR.
|
||||
* @par Example:
|
||||
* @code
|
||||
* uint32 result = MCM_PDD_ReadPlatformControlReg(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define MCM_PDD_ReadPlatformControlReg(PeripheralBase) ( \
|
||||
MCM_PLACR_REG(PeripheralBase) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- WritePlatformControlReg
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Writes data specified by the Value parameter into platform control
|
||||
* register.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param Value Value to be written to the platform control register. This
|
||||
* parameter is a 32-bit value.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: MCM_PLACR.
|
||||
* @par Example:
|
||||
* @code
|
||||
* MCM_PDD_WritePlatformControlReg(<peripheral>_BASE_PTR, 1);
|
||||
* @endcode
|
||||
*/
|
||||
#define MCM_PDD_WritePlatformControlReg(PeripheralBase, Value) ( \
|
||||
MCM_PLACR_REG(PeripheralBase) = \
|
||||
(uint32)(Value) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- DisableStallingFlashController
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Disable stalling flash controller.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: MCM_PLACR.
|
||||
* @par Example:
|
||||
* @code
|
||||
* MCM_PDD_DisableStallingFlashController(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define MCM_PDD_DisableStallingFlashController(PeripheralBase) ( \
|
||||
MCM_PLACR_REG(PeripheralBase) &= \
|
||||
(uint32)(~(uint32)MCM_PLACR_ESFC_MASK) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- EnableStallingFlashController
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Enable stalling flash controller.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: MCM_PLACR.
|
||||
* @par Example:
|
||||
* @code
|
||||
* MCM_PDD_EnableStallingFlashController(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define MCM_PDD_EnableStallingFlashController(PeripheralBase) ( \
|
||||
MCM_PLACR_REG(PeripheralBase) |= \
|
||||
MCM_PLACR_ESFC_MASK \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- DisableFlashControllerSpeculation
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Disable flash controller speculation.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: MCM_PLACR.
|
||||
* @par Example:
|
||||
* @code
|
||||
* MCM_PDD_DisableFlashControllerSpeculation(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define MCM_PDD_DisableFlashControllerSpeculation(PeripheralBase) ( \
|
||||
MCM_PLACR_REG(PeripheralBase) |= \
|
||||
MCM_PLACR_DFCS_MASK \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- EnableFlashControllerSpeculation
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Enable flash controller speculation.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: MCM_PLACR.
|
||||
* @par Example:
|
||||
* @code
|
||||
* MCM_PDD_EnableFlashControllerSpeculation(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define MCM_PDD_EnableFlashControllerSpeculation(PeripheralBase) ( \
|
||||
MCM_PLACR_REG(PeripheralBase) &= \
|
||||
(uint32)(~(uint32)MCM_PLACR_DFCS_MASK) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- DisableFlashDataSpeculation
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Disable flash data speculation.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: MCM_PLACR.
|
||||
* @par Example:
|
||||
* @code
|
||||
* MCM_PDD_DisableFlashDataSpeculation(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define MCM_PDD_DisableFlashDataSpeculation(PeripheralBase) ( \
|
||||
MCM_PLACR_REG(PeripheralBase) &= \
|
||||
(uint32)(~(uint32)MCM_PLACR_EFDS_MASK) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- EnableFlashDataSpeculation
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Enable flash data speculation.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: MCM_PLACR.
|
||||
* @par Example:
|
||||
* @code
|
||||
* MCM_PDD_EnableFlashDataSpeculation(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define MCM_PDD_EnableFlashDataSpeculation(PeripheralBase) ( \
|
||||
MCM_PLACR_REG(PeripheralBase) |= \
|
||||
MCM_PLACR_EFDS_MASK \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- EnableFlashControllerCache
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Enable flash controllerCache.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: MCM_PLACR.
|
||||
* @par Example:
|
||||
* @code
|
||||
* MCM_PDD_EnableFlashControllerCache(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define MCM_PDD_EnableFlashControllerCache(PeripheralBase) ( \
|
||||
MCM_PLACR_REG(PeripheralBase) &= \
|
||||
(uint32)(~(uint32)MCM_PLACR_DFCC_MASK) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- DisableFlashControllerCache
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Disable flash controllerCache.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: MCM_PLACR.
|
||||
* @par Example:
|
||||
* @code
|
||||
* MCM_PDD_DisableFlashControllerCache(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define MCM_PDD_DisableFlashControllerCache(PeripheralBase) ( \
|
||||
MCM_PLACR_REG(PeripheralBase) |= \
|
||||
MCM_PLACR_DFCC_MASK \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- EnableFlashControllerInstructionCaching
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Enable flash controller instruction caching.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: MCM_PLACR.
|
||||
* @par Example:
|
||||
* @code
|
||||
* MCM_PDD_EnableFlashControllerInstructionCaching(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define MCM_PDD_EnableFlashControllerInstructionCaching(PeripheralBase) ( \
|
||||
MCM_PLACR_REG(PeripheralBase) &= \
|
||||
(uint32)(~(uint32)MCM_PLACR_DFCIC_MASK) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- DisableFlashControllerInstructionCaching
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Disable flash controller instruction caching.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: MCM_PLACR.
|
||||
* @par Example:
|
||||
* @code
|
||||
* MCM_PDD_DisableFlashControllerInstructionCaching(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define MCM_PDD_DisableFlashControllerInstructionCaching(PeripheralBase) ( \
|
||||
MCM_PLACR_REG(PeripheralBase) |= \
|
||||
MCM_PLACR_DFCIC_MASK \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- EnableFlashControllerDataCaching
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Enable flash controller data caching.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: MCM_PLACR.
|
||||
* @par Example:
|
||||
* @code
|
||||
* MCM_PDD_EnableFlashControllerDataCaching(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define MCM_PDD_EnableFlashControllerDataCaching(PeripheralBase) ( \
|
||||
MCM_PLACR_REG(PeripheralBase) &= \
|
||||
(uint32)(~(uint32)MCM_PLACR_DFCDA_MASK) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- DisableFlashControllerDataCaching
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Disable flash controller data caching.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: MCM_PLACR.
|
||||
* @par Example:
|
||||
* @code
|
||||
* MCM_PDD_DisableFlashControllerDataCaching(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define MCM_PDD_DisableFlashControllerDataCaching(PeripheralBase) ( \
|
||||
MCM_PLACR_REG(PeripheralBase) |= \
|
||||
MCM_PLACR_DFCDA_MASK \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- InvalidateFlashCache
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Invalidates flash cache.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: MCM_PLACR.
|
||||
* @par Example:
|
||||
* @code
|
||||
* MCM_PDD_InvalidateFlashCache(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define MCM_PDD_InvalidateFlashCache(PeripheralBase) ( \
|
||||
MCM_PLACR_REG(PeripheralBase) |= \
|
||||
MCM_PLACR_CFCC_MASK \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- EnableComputeOperationWakeupOnInterrupt
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Enable compute operation wakeup on interrupt.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: MCM_CPO.
|
||||
* @par Example:
|
||||
* @code
|
||||
* MCM_PDD_EnableComputeOperationWakeupOnInterrupt(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define MCM_PDD_EnableComputeOperationWakeupOnInterrupt(PeripheralBase) ( \
|
||||
MCM_CPO_REG(PeripheralBase) |= \
|
||||
MCM_CPO_CPOWOI_MASK \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- GetComputeOperationState
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Returns non zero value if compute operation entry has completed or
|
||||
* compute operation exit has not completed.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a 32-bit value.
|
||||
* @remarks The macro accesses the following registers: MCM_CPO.
|
||||
* @par Example:
|
||||
* @code
|
||||
* uint32 result =
|
||||
* MCM_PDD_GetComputeOperationState(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define MCM_PDD_GetComputeOperationState(PeripheralBase) ( \
|
||||
(uint32)(MCM_CPO_REG(PeripheralBase) & MCM_CPO_CPOACK_MASK) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- GetComputeOperationRequest
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Returns non zero value if compute operation request is active.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a 32-bit value.
|
||||
* @remarks The macro accesses the following registers: MCM_CPO.
|
||||
* @par Example:
|
||||
* @code
|
||||
* uint32 result =
|
||||
* MCM_PDD_GetComputeOperationRequest(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define MCM_PDD_GetComputeOperationRequest(PeripheralBase) ( \
|
||||
(uint32)(MCM_CPO_REG(PeripheralBase) & MCM_CPO_CPOREQ_MASK) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- SetComputeOperationRequest
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Set compute operation request.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: MCM_CPO.
|
||||
* @par Example:
|
||||
* @code
|
||||
* MCM_PDD_SetComputeOperationRequest(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define MCM_PDD_SetComputeOperationRequest(PeripheralBase) ( \
|
||||
MCM_CPO_REG(PeripheralBase) |= \
|
||||
MCM_CPO_CPOREQ_MASK \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- ClearComputeOperationRequest
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Clear compute operation request.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: MCM_CPO.
|
||||
* @par Example:
|
||||
* @code
|
||||
* MCM_PDD_ClearComputeOperationRequest(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define MCM_PDD_ClearComputeOperationRequest(PeripheralBase) ( \
|
||||
MCM_CPO_REG(PeripheralBase) &= \
|
||||
(uint32)(~(uint32)MCM_CPO_CPOREQ_MASK) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- ReadComputeOperationControlReg
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Reads compute operation control register.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a 32-bit value.
|
||||
* @remarks The macro accesses the following registers: MCM_CPO.
|
||||
* @par Example:
|
||||
* @code
|
||||
* uint32 result =
|
||||
* MCM_PDD_ReadComputeOperationControlReg(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define MCM_PDD_ReadComputeOperationControlReg(PeripheralBase) ( \
|
||||
MCM_CPO_REG(PeripheralBase) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- WriteComputeOperationControlReg
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Writes data specified by the Value parameter into compute operation
|
||||
* control register.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param Value Value to be written to the compute operation control register.
|
||||
* This parameter is a 32-bit value.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: MCM_CPO.
|
||||
* @par Example:
|
||||
* @code
|
||||
* MCM_PDD_WriteComputeOperationControlReg(<peripheral>_BASE_PTR, 1);
|
||||
* @endcode
|
||||
*/
|
||||
#define MCM_PDD_WriteComputeOperationControlReg(PeripheralBase, Value) ( \
|
||||
MCM_CPO_REG(PeripheralBase) = \
|
||||
(uint32)(Value) \
|
||||
)
|
||||
#endif /* #if defined(MCM_PDD_H_) */
|
||||
|
||||
/* MCM_PDD.h, eof. */
|
||||
1716
Clean_TMC2209/lib/tmc/hal/Landungsbruecke/freescale/PDD/PDB_PDD.h
Normal file
1716
Clean_TMC2209/lib/tmc/hal/Landungsbruecke/freescale/PDD/PDB_PDD.h
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,69 @@
|
||||
/* Common type declarations for PDD layer */
|
||||
/* This file is static and it is generated from API-Factory */
|
||||
|
||||
#ifndef PDD_TYPES_H_
|
||||
#define PDD_TYPES_H_
|
||||
|
||||
/* --------------------------------------------------------------- */
|
||||
/* --------- PDD_TBool */
|
||||
/* --------------------------------------------------------------- */
|
||||
|
||||
/* Implementation note for boolean type: */
|
||||
/* Native "bool" type should be used for boolean values */
|
||||
/* because the compiler provides optimization and best type representation. */
|
||||
/* If the compiler does not support native "bool" type, common "Bool" */
|
||||
/* at each place there should be used the most suitable integer type */
|
||||
/* and no explicit conversion to 0 and 1 values should be used. */
|
||||
/* Common "TBool" typedef could have possible performance issue */
|
||||
/* (there is a problem how wide type to select). It is good to avoid using */
|
||||
/* explicit "!= 0" because of performance penalty, but without such */
|
||||
/* explicit conversion to 0/1 the resulting type may be too wide. */
|
||||
/* Every bool type (native or replaced by integer value) should be always */
|
||||
/* treated as zero-equal or non-zero (see below for examples). */
|
||||
|
||||
/* E.g.: This compiler supports boolean type only in C++ mode. */
|
||||
/* Out of the C++ mode the boolean type must be simulated. */
|
||||
|
||||
#ifndef __cplusplus
|
||||
typedef uint16 PDD_TBool;
|
||||
#else
|
||||
typedef bool PDD_TBool;
|
||||
#endif
|
||||
|
||||
/* ============================================================================
|
||||
================== General PDD macros ======================================
|
||||
============================================================================ */
|
||||
|
||||
#define PDD_DISABLE 0u
|
||||
#define PDD_ENABLE 1u
|
||||
|
||||
/* ============================================================================
|
||||
================== General register manipulating routines ==================
|
||||
============================================================================ */
|
||||
|
||||
#define setReg8(Reg, val) ((Reg) = (uint8)(val))
|
||||
#define getReg8(Reg) (Reg)
|
||||
#define testReg8Bits(Reg, GetMask) ((Reg) & (uint8)(GetMask))
|
||||
#define clrReg8Bits(Reg, ClrMask) ((Reg) &= (uint8)((uint8)(~(uint8)(ClrMask))))
|
||||
#define setReg8Bits(Reg, SetMask) ((Reg) |= (uint8)(SetMask))
|
||||
#define invertReg8Bits(Reg, InvMask) ((Reg) ^= (uint8)(InvMask))
|
||||
#define clrSetReg8Bits(Reg, ClrMask, SetMask) ((Reg) = (uint8)(((Reg) & (uint8)(~(uint8)(ClrMask))) | (uint8)(SetMask)))
|
||||
|
||||
#define setReg16(Reg, val) ((Reg) = (uint16)(val))
|
||||
#define getReg16(Reg) (Reg)
|
||||
#define testReg16Bits(Reg, GetMask) ((Reg) & (uint16)(GetMask))
|
||||
#define clrReg16Bits(Reg, ClrMask) ((Reg) &= (uint16)(~(uint16)(ClrMask)))
|
||||
#define setReg16Bits(Reg, SetMask) ((Reg) |= (uint16)(SetMask))
|
||||
#define invertReg16Bits(Reg, InvMask) ((Reg) ^= (uint16)(InvMask))
|
||||
#define clrSetReg16Bits(Reg, ClrMask, SetMask) ((Reg) = (uint16)(((Reg) & (uint16)(~(uint16)(ClrMask))) | (uint16)(SetMask)))
|
||||
|
||||
#define setReg32(Reg, val) ((Reg) = (uint32)(val))
|
||||
#define getReg32(Reg) (Reg)
|
||||
#define testReg32Bits(Reg, GetMask) ((Reg) & (uint32)(GetMask))
|
||||
#define clrReg32Bits(Reg, ClrMask) ((Reg) &= (uint32)(~(uint32)(ClrMask)))
|
||||
#define setReg32Bits(Reg, SetMask) ((Reg) |= (uint32)(SetMask))
|
||||
#define invertReg32Bits(Reg, InvMask) ((Reg) ^= (uint32)(InvMask))
|
||||
#define clrSetReg32Bits(Reg, ClrMask, SetMask) ((Reg) = (uint32)(((Reg) & (uint32)(~(uint32)(ClrMask))) | (uint32)(SetMask)))
|
||||
|
||||
|
||||
#endif /* #if !defined(PDD_TYPES_H_) */
|
||||
@@ -0,0 +1,602 @@
|
||||
/*
|
||||
PDD layer implementation for peripheral type PIT
|
||||
(C) 2013 Freescale, Inc. All rights reserved.
|
||||
|
||||
This file is static and it is generated from API-Factory
|
||||
*/
|
||||
|
||||
#if !defined(PIT_PDD_H_)
|
||||
#define PIT_PDD_H_
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- Test if supported MCU is active
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
#if !defined(MCU_ACTIVE)
|
||||
// No MCU is active
|
||||
#error PIT PDD library: No derivative is active. Place proper #include with PDD memory map before including PDD library.
|
||||
#elif \
|
||||
!defined(MCU_MK10D10) /* PIT */ && \
|
||||
!defined(MCU_MK10D5) /* PIT */ && \
|
||||
!defined(MCU_MK10D7) /* PIT */ && \
|
||||
!defined(MCU_MK10F12) /* PIT */ && \
|
||||
!defined(MCU_MK10DZ10) /* PIT */ && \
|
||||
!defined(MCU_MK11D5) /* PIT */ && \
|
||||
!defined(MCU_MK11D5WS) /* PIT */ && \
|
||||
!defined(MCU_MK12D5) /* PIT */ && \
|
||||
!defined(MCU_MK20D10) /* PIT */ && \
|
||||
!defined(MCU_MK20D5) /* PIT */ && \
|
||||
!defined(MCU_MK20D7) /* PIT */ && \
|
||||
!defined(MCU_MK20F12) /* PIT */ && \
|
||||
!defined(MCU_MK20DZ10) /* PIT */ && \
|
||||
!defined(MCU_MK21D5) /* PIT */ && \
|
||||
!defined(MCU_MK21D5WS) /* PIT */ && \
|
||||
!defined(MCU_MK21F12) /* PIT */ && \
|
||||
!defined(MCU_MK21F12WS) /* PIT */ && \
|
||||
!defined(MCU_MK22D5) /* PIT */ && \
|
||||
!defined(MCU_MK22F12810) /* PIT */ && \
|
||||
!defined(MCU_MK22F12) /* PIT */ && \
|
||||
!defined(MCU_MK22F25612) /* PIT */ && \
|
||||
!defined(MCU_MK22F51212) /* PIT */ && \
|
||||
!defined(MCU_MK24F12) /* PIT */ && \
|
||||
!defined(MCU_MK30D10) /* PIT */ && \
|
||||
!defined(MCU_MK30D7) /* PIT */ && \
|
||||
!defined(MCU_MK30DZ10) /* PIT */ && \
|
||||
!defined(MCU_MK40D10) /* PIT */ && \
|
||||
!defined(MCU_MK40D7) /* PIT */ && \
|
||||
!defined(MCU_MK40DZ10) /* PIT */ && \
|
||||
!defined(MCU_MK40X256VMD100) /* PIT */ && \
|
||||
!defined(MCU_MK50D10) /* PIT */ && \
|
||||
!defined(MCU_MK50D7) /* PIT */ && \
|
||||
!defined(MCU_MK50DZ10) /* PIT */ && \
|
||||
!defined(MCU_MK51D10) /* PIT */ && \
|
||||
!defined(MCU_MK51D7) /* PIT */ && \
|
||||
!defined(MCU_MK51DZ10) /* PIT */ && \
|
||||
!defined(MCU_MK52D10) /* PIT */ && \
|
||||
!defined(MCU_MK52DZ10) /* PIT */ && \
|
||||
!defined(MCU_MK53D10) /* PIT */ && \
|
||||
!defined(MCU_MK53DZ10) /* PIT */ && \
|
||||
!defined(MCU_MK60D10) /* PIT */ && \
|
||||
!defined(MCU_MK60F12) /* PIT */ && \
|
||||
!defined(MCU_MK60F15) /* PIT */ && \
|
||||
!defined(MCU_MK60DZ10) /* PIT */ && \
|
||||
!defined(MCU_MK60N512VMD100) /* PIT */ && \
|
||||
!defined(MCU_MK61F12) /* PIT */ && \
|
||||
!defined(MCU_MK61F15) /* PIT */ && \
|
||||
!defined(MCU_MK61F12WS) /* PIT */ && \
|
||||
!defined(MCU_MK61F15WS) /* PIT */ && \
|
||||
!defined(MCU_MK63F12) /* PIT */ && \
|
||||
!defined(MCU_MK63F12WS) /* PIT */ && \
|
||||
!defined(MCU_MK64F12) /* PIT */ && \
|
||||
!defined(MCU_MK65F18) /* PIT */ && \
|
||||
!defined(MCU_MK65F18WS) /* PIT */ && \
|
||||
!defined(MCU_MK66F18) /* PIT */ && \
|
||||
!defined(MCU_MK70F12) /* PIT */ && \
|
||||
!defined(MCU_MK70F15) /* PIT */ && \
|
||||
!defined(MCU_MK70F12WS) /* PIT */ && \
|
||||
!defined(MCU_MK70F15WS) /* PIT */ && \
|
||||
!defined(MCU_MKE02Z2) /* PIT */ && \
|
||||
!defined(MCU_MKE02Z4) /* PIT */ && \
|
||||
!defined(MCU_SKEAZN642) /* PIT */ && \
|
||||
!defined(MCU_MKE04Z1284) /* PIT */ && \
|
||||
!defined(MCU_MKE04Z4) /* PIT */ && \
|
||||
!defined(MCU_SKEAZN84) /* PIT */ && \
|
||||
!defined(MCU_MKE06Z4) /* PIT */ && \
|
||||
!defined(MCU_MKL04Z4) /* PIT */ && \
|
||||
!defined(MCU_MKL05Z4) /* PIT */ && \
|
||||
!defined(MCU_MKL14Z4) /* PIT */ && \
|
||||
!defined(MCU_MKL15Z4) /* PIT */ && \
|
||||
!defined(MCU_MKL16Z4) /* PIT */ && \
|
||||
!defined(MCU_MKL24Z4) /* PIT */ && \
|
||||
!defined(MCU_MKL25Z4) /* PIT */ && \
|
||||
!defined(MCU_MKL26Z4) /* PIT */ && \
|
||||
!defined(MCU_MKL34Z4) /* PIT */ && \
|
||||
!defined(MCU_MKL36Z4) /* PIT */ && \
|
||||
!defined(MCU_MKL46Z4) /* PIT */ && \
|
||||
!defined(MCU_MKV31F12810) /* PIT */ && \
|
||||
!defined(MCU_MKV31F25612) /* PIT */ && \
|
||||
!defined(MCU_MKV31F51212) /* PIT */ && \
|
||||
!defined(MCU_MKW01Z4) /* PIT */ && \
|
||||
!defined(MCU_MKW21D5) /* PIT */ && \
|
||||
!defined(MCU_MKW21D5WS) /* PIT */ && \
|
||||
!defined(MCU_MKW22D5) /* PIT */ && \
|
||||
!defined(MCU_MKW22D5WS) /* PIT */ && \
|
||||
!defined(MCU_MKW24D5) /* PIT */ && \
|
||||
!defined(MCU_MKW24D5WS) /* PIT */ && \
|
||||
!defined(MCU_PCK20L4) /* PIT */ && \
|
||||
!defined(MCU_SKEAZ1284) /* PIT */
|
||||
// Unsupported MCU is active
|
||||
#error PIT PDD library: Unsupported derivative is active.
|
||||
#endif
|
||||
|
||||
#include "PDD_Types.h"
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- Method symbol definitions
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/* PIT channel constants */
|
||||
#define PIT_PDD_CHANNEL_0 0U /**< 0 */
|
||||
#define PIT_PDD_CHANNEL_1 0x1U /**< 1 */
|
||||
#define PIT_PDD_CHANNEL_2 0x2U /**< 2 */
|
||||
#define PIT_PDD_CHANNEL_3 0x3U /**< 3 */
|
||||
|
||||
/* Module clock constants */
|
||||
#define PIT_PDD_CLOCK_ENABLED 0U /**< Enabled */
|
||||
#define PIT_PDD_CLOCK_DISABLED PIT_MCR_MDIS_MASK /**< Disabled */
|
||||
|
||||
/* Freeze constants */
|
||||
#define PIT_PDD_TIMERS_RUN 0U /**< Run */
|
||||
#define PIT_PDD_TIMERS_STOPPED PIT_MCR_FRZ_MASK /**< Stopped */
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- GetInterruptMask
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Returns interrupt mask.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param ChannelIdx PIT channel index. Use constants from group "PIT channel
|
||||
* constants". This parameter is 32 bits wide.
|
||||
* @return Returns a 32-bit value.
|
||||
* @remarks The macro accesses the following registers: TCTRL[ChannelIdx].
|
||||
* @par Example:
|
||||
* @code
|
||||
* uint32 result = PIT_PDD_GetInterruptMask(<peripheral>_BASE_PTR,
|
||||
* PIT_PDD_CHANNEL_0);
|
||||
* @endcode
|
||||
*/
|
||||
#define PIT_PDD_GetInterruptMask(PeripheralBase, ChannelIdx) ( \
|
||||
(uint32)(PIT_TCTRL_REG(PeripheralBase,(ChannelIdx)) & PIT_TCTRL_TIE_MASK) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- GetInterruptFlag
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Returns interrupt flag bit.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param ChannelIdx PIT channel index. Use constants from group "PIT channel
|
||||
* constants". This parameter is 32 bits wide.
|
||||
* @return Returns a 32-bit value.
|
||||
* @remarks The macro accesses the following registers: TFLG[ChannelIdx].
|
||||
* @par Example:
|
||||
* @code
|
||||
* uint32 result = PIT_PDD_GetInterruptFlag(<peripheral>_BASE_PTR,
|
||||
* PIT_PDD_CHANNEL_0);
|
||||
* @endcode
|
||||
*/
|
||||
#define PIT_PDD_GetInterruptFlag(PeripheralBase, ChannelIdx) ( \
|
||||
(uint32)(PIT_TFLG_REG(PeripheralBase,(ChannelIdx)) & PIT_TFLG_TIF_MASK) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- EnableInterrupt
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Enables the PIT interrupt.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param ChannelIdx PIT channel index. Use constants from group "PIT channel
|
||||
* constants". This parameter is 32 bits wide.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: TCTRL[ChannelIdx].
|
||||
* @par Example:
|
||||
* @code
|
||||
* PIT_PDD_EnableInterrupt(<peripheral>_BASE_PTR, PIT_PDD_CHANNEL_0);
|
||||
* @endcode
|
||||
*/
|
||||
#define PIT_PDD_EnableInterrupt(PeripheralBase, ChannelIdx) ( \
|
||||
PIT_TCTRL_REG(PeripheralBase,(ChannelIdx)) |= \
|
||||
PIT_TCTRL_TIE_MASK \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- DisableInterrupt
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Disables the PIT interrupt.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param ChannelIdx PIT channel index. Use constants from group "PIT channel
|
||||
* constants". This parameter is 32 bits wide.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: TCTRL[ChannelIdx].
|
||||
* @par Example:
|
||||
* @code
|
||||
* PIT_PDD_DisableInterrupt(<peripheral>_BASE_PTR, PIT_PDD_CHANNEL_0);
|
||||
* @endcode
|
||||
*/
|
||||
#define PIT_PDD_DisableInterrupt(PeripheralBase, ChannelIdx) ( \
|
||||
PIT_TCTRL_REG(PeripheralBase,(ChannelIdx)) &= \
|
||||
(uint32)(~(uint32)PIT_TCTRL_TIE_MASK) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- ClearInterruptFlag
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Clears PIT interrupt flag.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param ChannelIdx PIT channel index. Use constants from group "PIT channel
|
||||
* constants". This parameter is 32 bits wide.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: TFLG[ChannelIdx],
|
||||
* LDVAL[ChannelIdx] (depending on the peripheral).
|
||||
* @par Example:
|
||||
* @code
|
||||
* PIT_PDD_ClearInterruptFlag(<peripheral>_BASE_PTR, PIT_PDD_CHANNEL_0);
|
||||
* @endcode
|
||||
*/
|
||||
#define PIT_PDD_ClearInterruptFlag(PeripheralBase, ChannelIdx) ( \
|
||||
(PIT_TFLG_REG(PeripheralBase,(ChannelIdx)) = \
|
||||
PIT_TFLG_TIF_MASK), \
|
||||
(void)PIT_LDVAL_REG(PeripheralBase,(ChannelIdx)) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- ModuleClock
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Enables/disables PIT module clock.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param Clock New value of the clock. Use constants from group "Module clock
|
||||
* constants". This parameter is 32 bits wide.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: PIT_MCR.
|
||||
* @par Example:
|
||||
* @code
|
||||
* PIT_PDD_ModuleClock(<peripheral>_BASE_PTR, PIT_PDD_CLOCK_ENABLED);
|
||||
* @endcode
|
||||
*/
|
||||
#define PIT_PDD_ModuleClock(PeripheralBase, Clock) ( \
|
||||
PIT_MCR_REG(PeripheralBase) = \
|
||||
(uint32)(( \
|
||||
(uint32)(PIT_MCR_REG(PeripheralBase) & (uint32)(~(uint32)PIT_MCR_MDIS_MASK))) | ( \
|
||||
(uint32)(Clock))) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- ModuleFreeze
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Allows the timers to be stopped when the device enters debug mode.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param Freeze New value of the freeze. Use constants from group "Freeze
|
||||
* constants". This parameter is 32 bits wide.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: PIT_MCR.
|
||||
* @par Example:
|
||||
* @code
|
||||
* PIT_PDD_ModuleFreeze(<peripheral>_BASE_PTR, PIT_PDD_TIMERS_RUN);
|
||||
* @endcode
|
||||
*/
|
||||
#define PIT_PDD_ModuleFreeze(PeripheralBase, Freeze) ( \
|
||||
PIT_MCR_REG(PeripheralBase) = \
|
||||
(uint32)(( \
|
||||
(uint32)(PIT_MCR_REG(PeripheralBase) & (uint32)(~(uint32)PIT_MCR_FRZ_MASK))) | ( \
|
||||
(uint32)(Freeze))) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- WriteLoadReg
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Writes value to the load register.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param ChannelIdx PIT channel index. Use constants from group "PIT channel
|
||||
* constants". This parameter is 32 bits wide.
|
||||
* @param Value New content of the load register. This parameter is a 32-bit
|
||||
* value.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: LDVAL[ChannelIdx].
|
||||
* @par Example:
|
||||
* @code
|
||||
* PIT_PDD_WriteLoadReg(<peripheral>_BASE_PTR, PIT_PDD_CHANNEL_0, 1);
|
||||
* @endcode
|
||||
*/
|
||||
#define PIT_PDD_WriteLoadReg(PeripheralBase, ChannelIdx, Value) ( \
|
||||
PIT_LDVAL_REG(PeripheralBase,(ChannelIdx)) = \
|
||||
(uint32)(Value) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- ReadLoadReg
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Returns the content of the load register.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param ChannelIdx PIT channel index. Use constants from group "PIT channel
|
||||
* constants". This parameter is 32 bits wide.
|
||||
* @return Returns a 32-bit value.
|
||||
* @remarks The macro accesses the following registers: LDVAL[ChannelIdx].
|
||||
* @par Example:
|
||||
* @code
|
||||
* uint32 result = PIT_PDD_ReadLoadReg(<peripheral>_BASE_PTR,
|
||||
* PIT_PDD_CHANNEL_0);
|
||||
* @endcode
|
||||
*/
|
||||
#define PIT_PDD_ReadLoadReg(PeripheralBase, ChannelIdx) ( \
|
||||
PIT_LDVAL_REG(PeripheralBase,(ChannelIdx)) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- ReadTimerValueReg
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Returns the content of the current timer value register.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param ChannelIdx PIT channel index. Use constants from group "PIT channel
|
||||
* constants". This parameter is 32 bits wide.
|
||||
* @return Returns a 32-bit value.
|
||||
* @remarks The macro accesses the following registers: CVAL[ChannelIdx].
|
||||
* @par Example:
|
||||
* @code
|
||||
* uint32 result = PIT_PDD_ReadTimerValueReg(<peripheral>_BASE_PTR,
|
||||
* PIT_PDD_CHANNEL_0);
|
||||
* @endcode
|
||||
*/
|
||||
#define PIT_PDD_ReadTimerValueReg(PeripheralBase, ChannelIdx) ( \
|
||||
PIT_CVAL_REG(PeripheralBase,(ChannelIdx)) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- EnableDevice
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Enables the PIT channel device.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param ChannelIdx PIT channel index. Use constants from group "PIT channel
|
||||
* constants". This parameter is 32 bits wide.
|
||||
* @param State Requested state of PIT channel. This parameter is of "Global
|
||||
* enumeration used for specifying general enable/disable states (PDD_DISABLE
|
||||
* and PDD_ENABLE defined in PDD_Types.h)" type.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: TCTRL[ChannelIdx].
|
||||
* @par Example:
|
||||
* @code
|
||||
* PIT_PDD_EnableDevice(<peripheral>_BASE_PTR, PIT_PDD_CHANNEL_0,
|
||||
* PDD_DISABLE);
|
||||
* @endcode
|
||||
*/
|
||||
#define PIT_PDD_EnableDevice(PeripheralBase, ChannelIdx, State) ( \
|
||||
PIT_TCTRL_REG(PeripheralBase,(ChannelIdx)) = \
|
||||
(uint32)(( \
|
||||
(uint32)(( \
|
||||
PIT_TCTRL_REG(PeripheralBase,(ChannelIdx))) & ( \
|
||||
(uint32)(~(uint32)PIT_TCTRL_TEN_MASK)))) | ( \
|
||||
(uint32)(State))) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- GetEnableDeviceStatus
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Returns current state of PIT channel device.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param ChannelIdx PIT channel index. Use constants from group "PIT channel
|
||||
* constants". This parameter is 32 bits wide.
|
||||
* @return Returns a 32-bit value.
|
||||
* @remarks The macro accesses the following registers: TCTRL[ChannelIdx].
|
||||
* @par Example:
|
||||
* @code
|
||||
* uint32 result = PIT_PDD_GetEnableDeviceStatus(<peripheral>_BASE_PTR,
|
||||
* PIT_PDD_CHANNEL_0);
|
||||
* @endcode
|
||||
*/
|
||||
#define PIT_PDD_GetEnableDeviceStatus(PeripheralBase, ChannelIdx) ( \
|
||||
(uint32)(PIT_TCTRL_REG(PeripheralBase,(ChannelIdx)) & PIT_TCTRL_TEN_MASK) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- WriteModuleControlReg
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Writes value to the module control register.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param Value New content of the module control register. This parameter is a
|
||||
* 32-bit value.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: PIT_MCR.
|
||||
* @par Example:
|
||||
* @code
|
||||
* PIT_PDD_WriteModuleControlReg(<peripheral>_BASE_PTR, 1);
|
||||
* @endcode
|
||||
*/
|
||||
#define PIT_PDD_WriteModuleControlReg(PeripheralBase, Value) ( \
|
||||
PIT_MCR_REG(PeripheralBase) = \
|
||||
(uint32)(Value) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- ReadModuleControlReg
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Returns the content of the module control register.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a 32-bit value.
|
||||
* @remarks The macro accesses the following registers: PIT_MCR.
|
||||
* @par Example:
|
||||
* @code
|
||||
* uint32 result = PIT_PDD_ReadModuleControlReg(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define PIT_PDD_ReadModuleControlReg(PeripheralBase) ( \
|
||||
PIT_MCR_REG(PeripheralBase) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- WriteTimerControlReg
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Writes value to the timer control register.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param ChannelIdx PIT channel index. Use constants from group "PIT channel
|
||||
* constants". This parameter is 32 bits wide.
|
||||
* @param Value New content of the timer control register. This parameter is a
|
||||
* 32-bit value.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: TCTRL[ChannelIdx].
|
||||
* @par Example:
|
||||
* @code
|
||||
* PIT_PDD_WriteTimerControlReg(<peripheral>_BASE_PTR, PIT_PDD_CHANNEL_0,
|
||||
* 1);
|
||||
* @endcode
|
||||
*/
|
||||
#define PIT_PDD_WriteTimerControlReg(PeripheralBase, ChannelIdx, Value) ( \
|
||||
PIT_TCTRL_REG(PeripheralBase,(ChannelIdx)) = \
|
||||
(uint32)(Value) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- ReadTimerControlReg
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Returns the content of the timer control register.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param ChannelIdx PIT channel index. Use constants from group "PIT channel
|
||||
* constants". This parameter is 32 bits wide.
|
||||
* @return Returns a 32-bit value.
|
||||
* @remarks The macro accesses the following registers: TCTRL[ChannelIdx].
|
||||
* @par Example:
|
||||
* @code
|
||||
* uint32 result = PIT_PDD_ReadTimerControlReg(<peripheral>_BASE_PTR,
|
||||
* PIT_PDD_CHANNEL_0);
|
||||
* @endcode
|
||||
*/
|
||||
#define PIT_PDD_ReadTimerControlReg(PeripheralBase, ChannelIdx) ( \
|
||||
PIT_TCTRL_REG(PeripheralBase,(ChannelIdx)) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- WriteTimerFlagReg
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Writes value to the timer flag register.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param ChannelIdx PIT channel index. Use constants from group "PIT channel
|
||||
* constants". This parameter is 32 bits wide.
|
||||
* @param Value New content of the timer flag register. This parameter is a
|
||||
* 32-bit value.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: TFLG[ChannelIdx].
|
||||
* @par Example:
|
||||
* @code
|
||||
* PIT_PDD_WriteTimerFlagReg(<peripheral>_BASE_PTR, PIT_PDD_CHANNEL_0, 1);
|
||||
* @endcode
|
||||
*/
|
||||
#define PIT_PDD_WriteTimerFlagReg(PeripheralBase, ChannelIdx, Value) ( \
|
||||
PIT_TFLG_REG(PeripheralBase,(ChannelIdx)) = \
|
||||
(uint32)(Value) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- ReadTimerFlagReg
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Returns the content of the timer flag register.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param ChannelIdx PIT channel index. Use constants from group "PIT channel
|
||||
* constants". This parameter is 32 bits wide.
|
||||
* @return Returns a 32-bit value.
|
||||
* @remarks The macro accesses the following registers: TFLG[ChannelIdx].
|
||||
* @par Example:
|
||||
* @code
|
||||
* uint32 result = PIT_PDD_ReadTimerFlagReg(<peripheral>_BASE_PTR,
|
||||
* PIT_PDD_CHANNEL_0);
|
||||
* @endcode
|
||||
*/
|
||||
#define PIT_PDD_ReadTimerFlagReg(PeripheralBase, ChannelIdx) ( \
|
||||
PIT_TFLG_REG(PeripheralBase,(ChannelIdx)) \
|
||||
)
|
||||
#endif /* #if defined(PIT_PDD_H_) */
|
||||
|
||||
/* PIT_PDD.h, eof. */
|
||||
2375
Clean_TMC2209/lib/tmc/hal/Landungsbruecke/freescale/PDD/PORT_PDD.h
Normal file
2375
Clean_TMC2209/lib/tmc/hal/Landungsbruecke/freescale/PDD/PORT_PDD.h
Normal file
File diff suppressed because it is too large
Load Diff
3576
Clean_TMC2209/lib/tmc/hal/Landungsbruecke/freescale/PDD/RTC_PDD.h
Normal file
3576
Clean_TMC2209/lib/tmc/hal/Landungsbruecke/freescale/PDD/RTC_PDD.h
Normal file
File diff suppressed because it is too large
Load Diff
4409
Clean_TMC2209/lib/tmc/hal/Landungsbruecke/freescale/PDD/SAI_PDD.h
Normal file
4409
Clean_TMC2209/lib/tmc/hal/Landungsbruecke/freescale/PDD/SAI_PDD.h
Normal file
File diff suppressed because it is too large
Load Diff
2413
Clean_TMC2209/lib/tmc/hal/Landungsbruecke/freescale/PDD/SDHC_PDD.h
Normal file
2413
Clean_TMC2209/lib/tmc/hal/Landungsbruecke/freescale/PDD/SDHC_PDD.h
Normal file
File diff suppressed because it is too large
Load Diff
6806
Clean_TMC2209/lib/tmc/hal/Landungsbruecke/freescale/PDD/SIM_PDD.h
Normal file
6806
Clean_TMC2209/lib/tmc/hal/Landungsbruecke/freescale/PDD/SIM_PDD.h
Normal file
File diff suppressed because it is too large
Load Diff
3857
Clean_TMC2209/lib/tmc/hal/Landungsbruecke/freescale/PDD/SPI_PDD.h
Normal file
3857
Clean_TMC2209/lib/tmc/hal/Landungsbruecke/freescale/PDD/SPI_PDD.h
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,539 @@
|
||||
/*
|
||||
PDD layer implementation for peripheral type SysTick
|
||||
(C) 2013 Freescale, Inc. All rights reserved.
|
||||
|
||||
This file is static and it is generated from API-Factory
|
||||
*/
|
||||
|
||||
#if !defined(SysTick_PDD_H_)
|
||||
#define SysTick_PDD_H_
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- Test if supported MCU is active
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
#if !defined(MCU_ACTIVE)
|
||||
// No MCU is active
|
||||
#error SysTick PDD library: No derivative is active. Place proper #include with PDD memory map before including PDD library.
|
||||
#elif \
|
||||
!defined(MCU_MK10D10) /* SysTick */ && \
|
||||
!defined(MCU_MK10D5) /* SysTick */ && \
|
||||
!defined(MCU_MK10D7) /* SysTick */ && \
|
||||
!defined(MCU_MK10F12) /* SysTick */ && \
|
||||
!defined(MCU_MK10DZ10) /* SysTick */ && \
|
||||
!defined(MCU_MK11D5) /* SysTick */ && \
|
||||
!defined(MCU_MK11D5WS) /* SysTick */ && \
|
||||
!defined(MCU_MK12D5) /* SysTick */ && \
|
||||
!defined(MCU_MK20D10) /* SysTick */ && \
|
||||
!defined(MCU_MK20D5) /* SysTick */ && \
|
||||
!defined(MCU_MK20D7) /* SysTick */ && \
|
||||
!defined(MCU_MK20F12) /* SysTick */ && \
|
||||
!defined(MCU_MK20DZ10) /* SysTick */ && \
|
||||
!defined(MCU_MK21D5) /* SysTick */ && \
|
||||
!defined(MCU_MK21D5WS) /* SysTick */ && \
|
||||
!defined(MCU_MK21F12) /* SysTick */ && \
|
||||
!defined(MCU_MK21F12WS) /* SysTick */ && \
|
||||
!defined(MCU_MK22D5) /* SysTick */ && \
|
||||
!defined(MCU_MK22F12810) /* SysTick */ && \
|
||||
!defined(MCU_MK22F12) /* SysTick */ && \
|
||||
!defined(MCU_MK22F25612) /* SysTick */ && \
|
||||
!defined(MCU_MK22F51212) /* SysTick */ && \
|
||||
!defined(MCU_MK24F12) /* SysTick */ && \
|
||||
!defined(MCU_MK30D10) /* SysTick */ && \
|
||||
!defined(MCU_MK30D7) /* SysTick */ && \
|
||||
!defined(MCU_MK30DZ10) /* SysTick */ && \
|
||||
!defined(MCU_MK40D10) /* SysTick */ && \
|
||||
!defined(MCU_MK40D7) /* SysTick */ && \
|
||||
!defined(MCU_MK40DZ10) /* SysTick */ && \
|
||||
!defined(MCU_MK40X256VMD100) /* SysTick */ && \
|
||||
!defined(MCU_MK50D10) /* SysTick */ && \
|
||||
!defined(MCU_MK50D7) /* SysTick */ && \
|
||||
!defined(MCU_MK50DZ10) /* SysTick */ && \
|
||||
!defined(MCU_MK51D10) /* SysTick */ && \
|
||||
!defined(MCU_MK51D7) /* SysTick */ && \
|
||||
!defined(MCU_MK51DZ10) /* SysTick */ && \
|
||||
!defined(MCU_MK52D10) /* SysTick */ && \
|
||||
!defined(MCU_MK52DZ10) /* SysTick */ && \
|
||||
!defined(MCU_MK53D10) /* SysTick */ && \
|
||||
!defined(MCU_MK53DZ10) /* SysTick */ && \
|
||||
!defined(MCU_MK60D10) /* SysTick */ && \
|
||||
!defined(MCU_MK60F12) /* SysTick */ && \
|
||||
!defined(MCU_MK60F15) /* SysTick */ && \
|
||||
!defined(MCU_MK60DZ10) /* SysTick */ && \
|
||||
!defined(MCU_MK60N512VMD100) /* SysTick */ && \
|
||||
!defined(MCU_MK61F12) /* SysTick */ && \
|
||||
!defined(MCU_MK61F15) /* SysTick */ && \
|
||||
!defined(MCU_MK61F12WS) /* SysTick */ && \
|
||||
!defined(MCU_MK61F15WS) /* SysTick */ && \
|
||||
!defined(MCU_MK63F12) /* SysTick */ && \
|
||||
!defined(MCU_MK63F12WS) /* SysTick */ && \
|
||||
!defined(MCU_MK64F12) /* SysTick */ && \
|
||||
!defined(MCU_MK65F18) /* SysTick */ && \
|
||||
!defined(MCU_MK65F18WS) /* SysTick */ && \
|
||||
!defined(MCU_MK66F18) /* SysTick */ && \
|
||||
!defined(MCU_MK70F12) /* SysTick */ && \
|
||||
!defined(MCU_MK70F15) /* SysTick */ && \
|
||||
!defined(MCU_MK70F12WS) /* SysTick */ && \
|
||||
!defined(MCU_MK70F15WS) /* SysTick */ && \
|
||||
!defined(MCU_MKE02Z2) /* SysTick */ && \
|
||||
!defined(MCU_MKE02Z4) /* SysTick */ && \
|
||||
!defined(MCU_SKEAZN642) /* SysTick */ && \
|
||||
!defined(MCU_MKE04Z1284) /* SysTick */ && \
|
||||
!defined(MCU_MKE04Z4) /* SysTick */ && \
|
||||
!defined(MCU_SKEAZN84) /* SysTick */ && \
|
||||
!defined(MCU_MKE06Z4) /* SysTick */ && \
|
||||
!defined(MCU_MKL02Z4) /* SysTick */ && \
|
||||
!defined(MCU_MKL03Z4) /* SysTick */ && \
|
||||
!defined(MCU_MKL04Z4) /* SysTick */ && \
|
||||
!defined(MCU_MKL05Z4) /* SysTick */ && \
|
||||
!defined(MCU_MKL14Z4) /* SysTick */ && \
|
||||
!defined(MCU_MKL15Z4) /* SysTick */ && \
|
||||
!defined(MCU_MKL16Z4) /* SysTick */ && \
|
||||
!defined(MCU_MKL24Z4) /* SysTick */ && \
|
||||
!defined(MCU_MKL25Z4) /* SysTick */ && \
|
||||
!defined(MCU_MKL26Z4) /* SysTick */ && \
|
||||
!defined(MCU_MKL34Z4) /* SysTick */ && \
|
||||
!defined(MCU_MKL36Z4) /* SysTick */ && \
|
||||
!defined(MCU_MKL46Z4) /* SysTick */ && \
|
||||
!defined(MCU_MKV10Z7) /* SysTick */ && \
|
||||
!defined(MCU_MKV31F12810) /* SysTick */ && \
|
||||
!defined(MCU_MKV31F25612) /* SysTick */ && \
|
||||
!defined(MCU_MKV31F51212) /* SysTick */ && \
|
||||
!defined(MCU_MKW01Z4) /* SysTick */ && \
|
||||
!defined(MCU_MKW21D5) /* SysTick */ && \
|
||||
!defined(MCU_MKW21D5WS) /* SysTick */ && \
|
||||
!defined(MCU_MKW22D5) /* SysTick */ && \
|
||||
!defined(MCU_MKW22D5WS) /* SysTick */ && \
|
||||
!defined(MCU_MKW24D5) /* SysTick */ && \
|
||||
!defined(MCU_MKW24D5WS) /* SysTick */ && \
|
||||
!defined(MCU_PCK20L4) /* SysTick */ && \
|
||||
!defined(MCU_SKEAZ1284) /* SysTick */
|
||||
// Unsupported MCU is active
|
||||
#error SysTick PDD library: Unsupported derivative is active.
|
||||
#endif
|
||||
|
||||
#include "PDD_Types.h"
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- Method symbol definitions
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
#if ((defined(MCU_MKE02Z2)) || (defined(MCU_MKE02Z4)) || (defined(MCU_MKE04Z1284)) || (defined(MCU_MKE04Z4)) || (defined(MCU_MKE06Z4)) || (defined(MCU_MKL02Z4)) || (defined(MCU_MKL03Z4)) || (defined(MCU_MKL04Z4)) || (defined(MCU_MKL05Z4)) || (defined(MCU_MKL14Z4)) || (defined(MCU_MKL15Z4)) || (defined(MCU_MKL16Z4)) || (defined(MCU_MKL24Z4)) || (defined(MCU_MKL25Z4)) || (defined(MCU_MKL26Z4)) || (defined(MCU_MKL34Z4)) || (defined(MCU_MKL36Z4)) || (defined(MCU_MKL46Z4)) || (defined(MCU_MKV10Z7)) || (defined(MCU_MKW01Z4)) || (defined(MCU_SKEAZ1284)) || (defined(MCU_SKEAZN642)) || (defined(MCU_SKEAZN84)))
|
||||
/* Clock source constants. */
|
||||
#define SysTick_PDD_CORE_CLOCK 0x1U /**< 1 */
|
||||
#define SysTick_PDD_CORE_CLOCK_DIV16 0U /**< 1 */
|
||||
|
||||
#else /* (defined(MCU_MK10D10)) || (defined(MCU_MK10D5)) || (defined(MCU_MK10D7)) || (defined(MCU_MK10DZ10)) || (defined(MCU_MK10F12)) || (defined(MCU_MK11D5)) || (defined(MCU_MK11D5WS)) || (defined(MCU_MK12D5)) || (defined(MCU_MK20D10)) || (defined(MCU_MK20D5)) || (defined(MCU_MK20D7)) || (defined(MCU_MK20DZ10)) || (defined(MCU_MK20F12)) || (defined(MCU_MK21D5)) || (defined(MCU_MK21D5WS)) || (defined(MCU_MK21F12)) || (defined(MCU_MK21F12WS)) || (defined(MCU_MK22D5)) || (defined(MCU_MK22F12)) || (defined(MCU_MK22F12810)) || (defined(MCU_MK22F25612)) || (defined(MCU_MK22F51212)) || (defined(MCU_MK24F12)) || (defined(MCU_MK30D10)) || (defined(MCU_MK30D7)) || (defined(MCU_MK30DZ10)) || (defined(MCU_MK40D10)) || (defined(MCU_MK40D7)) || (defined(MCU_MK40DZ10)) || (defined(MCU_MK40X256VMD100)) || (defined(MCU_MK50D10)) || (defined(MCU_MK50D7)) || (defined(MCU_MK50DZ10)) || (defined(MCU_MK51D10)) || (defined(MCU_MK51D7)) || (defined(MCU_MK51DZ10)) || (defined(MCU_MK52D10)) || (defined(MCU_MK52DZ10)) || (defined(MCU_MK53D10)) || (defined(MCU_MK53DZ10)) || (defined(MCU_MK60D10)) || (defined(MCU_MK60DZ10)) || (defined(MCU_MK60F12)) || (defined(MCU_MK60F15)) || (defined(MCU_MK60N512VMD100)) || (defined(MCU_MK61F12)) || (defined(MCU_MK61F12WS)) || (defined(MCU_MK61F15)) || (defined(MCU_MK61F15WS)) || (defined(MCU_MK63F12)) || (defined(MCU_MK63F12WS)) || (defined(MCU_MK64F12)) || (defined(MCU_MK65F18)) || (defined(MCU_MK65F18WS)) || (defined(MCU_MK66F18)) || (defined(MCU_MK70F12)) || (defined(MCU_MK70F12WS)) || (defined(MCU_MK70F15)) || (defined(MCU_MK70F15WS)) || (defined(MCU_MKV31F12810)) || (defined(MCU_MKV31F25612)) || (defined(MCU_MKV31F51212)) || (defined(MCU_MKW21D5)) || (defined(MCU_MKW21D5WS)) || (defined(MCU_MKW22D5)) || (defined(MCU_MKW22D5WS)) || (defined(MCU_MKW24D5)) || (defined(MCU_MKW24D5WS)) || (defined(MCU_PCK20L4)) */
|
||||
/* Clock source constants. */
|
||||
#define SysTick_PDD_CORE_CLOCK 0x1U /**< 1 */
|
||||
|
||||
#endif /* (defined(MCU_MK10D10)) || (defined(MCU_MK10D5)) || (defined(MCU_MK10D7)) || (defined(MCU_MK10DZ10)) || (defined(MCU_MK10F12)) || (defined(MCU_MK11D5)) || (defined(MCU_MK11D5WS)) || (defined(MCU_MK12D5)) || (defined(MCU_MK20D10)) || (defined(MCU_MK20D5)) || (defined(MCU_MK20D7)) || (defined(MCU_MK20DZ10)) || (defined(MCU_MK20F12)) || (defined(MCU_MK21D5)) || (defined(MCU_MK21D5WS)) || (defined(MCU_MK21F12)) || (defined(MCU_MK21F12WS)) || (defined(MCU_MK22D5)) || (defined(MCU_MK22F12)) || (defined(MCU_MK22F12810)) || (defined(MCU_MK22F25612)) || (defined(MCU_MK22F51212)) || (defined(MCU_MK24F12)) || (defined(MCU_MK30D10)) || (defined(MCU_MK30D7)) || (defined(MCU_MK30DZ10)) || (defined(MCU_MK40D10)) || (defined(MCU_MK40D7)) || (defined(MCU_MK40DZ10)) || (defined(MCU_MK40X256VMD100)) || (defined(MCU_MK50D10)) || (defined(MCU_MK50D7)) || (defined(MCU_MK50DZ10)) || (defined(MCU_MK51D10)) || (defined(MCU_MK51D7)) || (defined(MCU_MK51DZ10)) || (defined(MCU_MK52D10)) || (defined(MCU_MK52DZ10)) || (defined(MCU_MK53D10)) || (defined(MCU_MK53DZ10)) || (defined(MCU_MK60D10)) || (defined(MCU_MK60DZ10)) || (defined(MCU_MK60F12)) || (defined(MCU_MK60F15)) || (defined(MCU_MK60N512VMD100)) || (defined(MCU_MK61F12)) || (defined(MCU_MK61F12WS)) || (defined(MCU_MK61F15)) || (defined(MCU_MK61F15WS)) || (defined(MCU_MK63F12)) || (defined(MCU_MK63F12WS)) || (defined(MCU_MK64F12)) || (defined(MCU_MK65F18)) || (defined(MCU_MK65F18WS)) || (defined(MCU_MK66F18)) || (defined(MCU_MK70F12)) || (defined(MCU_MK70F12WS)) || (defined(MCU_MK70F15)) || (defined(MCU_MK70F15WS)) || (defined(MCU_MKV31F12810)) || (defined(MCU_MKV31F25612)) || (defined(MCU_MKV31F51212)) || (defined(MCU_MKW21D5)) || (defined(MCU_MKW21D5WS)) || (defined(MCU_MKW22D5)) || (defined(MCU_MKW22D5WS)) || (defined(MCU_MKW24D5)) || (defined(MCU_MKW24D5WS)) || (defined(MCU_PCK20L4)) */
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- GetInterruptMask
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Returns interrupt mask.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a 32-bit value.
|
||||
* @remarks The macro accesses the following registers: SYST_CSR.
|
||||
* @par Example:
|
||||
* @code
|
||||
* uint32 result = SysTick_PDD_GetInterruptMask(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define SysTick_PDD_GetInterruptMask(PeripheralBase) ( \
|
||||
(uint32)(SysTick_CSR_REG(PeripheralBase) & SysTick_CSR_TICKINT_MASK) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- GetInterruptFlag
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Returns interrupt flag bit.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a 32-bit value.
|
||||
* @remarks The macro accesses the following registers: SYST_CSR.
|
||||
* @par Example:
|
||||
* @code
|
||||
* uint32 result = SysTick_PDD_GetInterruptFlag(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define SysTick_PDD_GetInterruptFlag(PeripheralBase) ( \
|
||||
(uint32)(SysTick_CSR_REG(PeripheralBase) & SysTick_CSR_COUNTFLAG_MASK) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- EnableInterrupt
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Enables the SysTick interrupt.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: SYST_CSR.
|
||||
* @par Example:
|
||||
* @code
|
||||
* SysTick_PDD_EnableInterrupt(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define SysTick_PDD_EnableInterrupt(PeripheralBase) ( \
|
||||
SysTick_CSR_REG(PeripheralBase) |= \
|
||||
SysTick_CSR_TICKINT_MASK \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- DisableInterrupt
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Disables the SysTick interrupt.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: SYST_CSR.
|
||||
* @par Example:
|
||||
* @code
|
||||
* SysTick_PDD_DisableInterrupt(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define SysTick_PDD_DisableInterrupt(PeripheralBase) ( \
|
||||
SysTick_CSR_REG(PeripheralBase) &= \
|
||||
(uint32)(~(uint32)SysTick_CSR_TICKINT_MASK) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- ClearInterruptFlag
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Clears SysTick interrupt flag.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: SYST_CSR.
|
||||
* @par Example:
|
||||
* @code
|
||||
* SysTick_PDD_ClearInterruptFlag(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define SysTick_PDD_ClearInterruptFlag(PeripheralBase) ( \
|
||||
SysTick_CSR_REG(PeripheralBase) &= \
|
||||
(uint32)(~(uint32)SysTick_CSR_COUNTFLAG_MASK) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- EnableDevice
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Enables the SysTick device.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param State Requested state of SysTick device. This parameter is of "Global
|
||||
* enumeration used for specifying general enable/disable states
|
||||
* (PDD_DISABLE and PDD_ENABLE defined in PDD_Types.h)" type.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: SYST_CSR.
|
||||
* @par Example:
|
||||
* @code
|
||||
* SysTick_PDD_EnableDevice(<peripheral>_BASE_PTR, PDD_DISABLE);
|
||||
* @endcode
|
||||
*/
|
||||
#define SysTick_PDD_EnableDevice(PeripheralBase, State) ( \
|
||||
SysTick_CSR_REG(PeripheralBase) = \
|
||||
(uint32)(( \
|
||||
(uint32)(( \
|
||||
SysTick_CSR_REG(PeripheralBase)) & ( \
|
||||
(uint32)(~(uint32)SysTick_CSR_ENABLE_MASK)))) | ( \
|
||||
(uint32)(State))) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- GetEnableDeviceStatus
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Returns current state of SysTick device.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a 32-bit value.
|
||||
* @remarks The macro accesses the following registers: SYST_CSR.
|
||||
* @par Example:
|
||||
* @code
|
||||
* uint32 result =
|
||||
* SysTick_PDD_GetEnableDeviceStatus(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define SysTick_PDD_GetEnableDeviceStatus(PeripheralBase) ( \
|
||||
(uint32)(SysTick_CSR_REG(PeripheralBase) & SysTick_CSR_ENABLE_MASK) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- SetClkSource
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Sets clock source.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param ClkSource New value of the clock source. Use constants from group
|
||||
* "Clock source constants.". This parameter is 1 bit wide.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: SYST_CSR.
|
||||
* @par Example:
|
||||
* @code
|
||||
* SysTick_PDD_SetClkSource(<peripheral>_BASE_PTR, SysTick_PDD_CORE_CLOCK);
|
||||
* @endcode
|
||||
*/
|
||||
#define SysTick_PDD_SetClkSource(PeripheralBase, ClkSource) ( \
|
||||
SysTick_CSR_REG(PeripheralBase) = \
|
||||
(uint32)(( \
|
||||
(uint32)(( \
|
||||
SysTick_CSR_REG(PeripheralBase)) & ( \
|
||||
(uint32)(~(uint32)SysTick_CSR_CLKSOURCE_MASK)))) | ( \
|
||||
(uint32)((uint32)(ClkSource) << SysTick_CSR_CLKSOURCE_SHIFT))) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- GetClkSource
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
#if ((defined(MCU_MKE02Z2)) || (defined(MCU_MKE02Z4)) || (defined(MCU_MKE04Z1284)) || (defined(MCU_MKE04Z4)) || (defined(MCU_MKE06Z4)) || (defined(MCU_MKL02Z4)) || (defined(MCU_MKL03Z4)) || (defined(MCU_MKL04Z4)) || (defined(MCU_MKL05Z4)) || (defined(MCU_MKL14Z4)) || (defined(MCU_MKL15Z4)) || (defined(MCU_MKL16Z4)) || (defined(MCU_MKL24Z4)) || (defined(MCU_MKL25Z4)) || (defined(MCU_MKL26Z4)) || (defined(MCU_MKL34Z4)) || (defined(MCU_MKL36Z4)) || (defined(MCU_MKL46Z4)) || (defined(MCU_MKV10Z7)) || (defined(MCU_MKW01Z4)) || (defined(MCU_SKEAZ1284)) || (defined(MCU_SKEAZN642)) || (defined(MCU_SKEAZN84)))
|
||||
/**
|
||||
* @brief Gets clock source.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Use constants from group "Clock source constants." for processing
|
||||
* return value. The value is cast to "uint8".
|
||||
* @remarks The macro accesses the following registers: SYST_CSR.
|
||||
* @par Example:
|
||||
* @code
|
||||
* uint8 result = SysTick_PDD_GetClkSource(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define SysTick_PDD_GetClkSource(PeripheralBase) ( \
|
||||
(uint8)(( \
|
||||
(uint32)(SysTick_CSR_REG(PeripheralBase) & SysTick_CSR_CLKSOURCE_MASK)) >> ( \
|
||||
SysTick_CSR_CLKSOURCE_SHIFT)) \
|
||||
)
|
||||
#else /* (defined(MCU_MK10D10)) || (defined(MCU_MK10D5)) || (defined(MCU_MK10D7)) || (defined(MCU_MK10DZ10)) || (defined(MCU_MK10F12)) || (defined(MCU_MK11D5)) || (defined(MCU_MK11D5WS)) || (defined(MCU_MK12D5)) || (defined(MCU_MK20D10)) || (defined(MCU_MK20D5)) || (defined(MCU_MK20D7)) || (defined(MCU_MK20DZ10)) || (defined(MCU_MK20F12)) || (defined(MCU_MK21D5)) || (defined(MCU_MK21D5WS)) || (defined(MCU_MK21F12)) || (defined(MCU_MK21F12WS)) || (defined(MCU_MK22D5)) || (defined(MCU_MK22F12)) || (defined(MCU_MK22F12810)) || (defined(MCU_MK22F25612)) || (defined(MCU_MK22F51212)) || (defined(MCU_MK24F12)) || (defined(MCU_MK30D10)) || (defined(MCU_MK30D7)) || (defined(MCU_MK30DZ10)) || (defined(MCU_MK40D10)) || (defined(MCU_MK40D7)) || (defined(MCU_MK40DZ10)) || (defined(MCU_MK40X256VMD100)) || (defined(MCU_MK50D10)) || (defined(MCU_MK50D7)) || (defined(MCU_MK50DZ10)) || (defined(MCU_MK51D10)) || (defined(MCU_MK51D7)) || (defined(MCU_MK51DZ10)) || (defined(MCU_MK52D10)) || (defined(MCU_MK52DZ10)) || (defined(MCU_MK53D10)) || (defined(MCU_MK53DZ10)) || (defined(MCU_MK60D10)) || (defined(MCU_MK60DZ10)) || (defined(MCU_MK60F12)) || (defined(MCU_MK60F15)) || (defined(MCU_MK60N512VMD100)) || (defined(MCU_MK61F12)) || (defined(MCU_MK61F12WS)) || (defined(MCU_MK61F15)) || (defined(MCU_MK61F15WS)) || (defined(MCU_MK63F12)) || (defined(MCU_MK63F12WS)) || (defined(MCU_MK64F12)) || (defined(MCU_MK65F18)) || (defined(MCU_MK65F18WS)) || (defined(MCU_MK66F18)) || (defined(MCU_MK70F12)) || (defined(MCU_MK70F12WS)) || (defined(MCU_MK70F15)) || (defined(MCU_MK70F15WS)) || (defined(MCU_MKV31F12810)) || (defined(MCU_MKV31F25612)) || (defined(MCU_MKV31F51212)) || (defined(MCU_MKW21D5)) || (defined(MCU_MKW21D5WS)) || (defined(MCU_MKW22D5)) || (defined(MCU_MKW22D5WS)) || (defined(MCU_MKW24D5)) || (defined(MCU_MKW24D5WS)) || (defined(MCU_PCK20L4)) */
|
||||
/**
|
||||
* @brief Gets clock source.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Use constants from group "Clock source constants." for processing
|
||||
* return value. The value is cast to "uint8".
|
||||
* @remarks The macro accesses the following registers: SYST_CSR.
|
||||
* @par Example:
|
||||
* @code
|
||||
* uint8 result = SysTick_PDD_GetClkSource(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define SysTick_PDD_GetClkSource(PeripheralBase) ( \
|
||||
0x1U \
|
||||
)
|
||||
#endif /* (defined(MCU_MK10D10)) || (defined(MCU_MK10D5)) || (defined(MCU_MK10D7)) || (defined(MCU_MK10DZ10)) || (defined(MCU_MK10F12)) || (defined(MCU_MK11D5)) || (defined(MCU_MK11D5WS)) || (defined(MCU_MK12D5)) || (defined(MCU_MK20D10)) || (defined(MCU_MK20D5)) || (defined(MCU_MK20D7)) || (defined(MCU_MK20DZ10)) || (defined(MCU_MK20F12)) || (defined(MCU_MK21D5)) || (defined(MCU_MK21D5WS)) || (defined(MCU_MK21F12)) || (defined(MCU_MK21F12WS)) || (defined(MCU_MK22D5)) || (defined(MCU_MK22F12)) || (defined(MCU_MK22F12810)) || (defined(MCU_MK22F25612)) || (defined(MCU_MK22F51212)) || (defined(MCU_MK24F12)) || (defined(MCU_MK30D10)) || (defined(MCU_MK30D7)) || (defined(MCU_MK30DZ10)) || (defined(MCU_MK40D10)) || (defined(MCU_MK40D7)) || (defined(MCU_MK40DZ10)) || (defined(MCU_MK40X256VMD100)) || (defined(MCU_MK50D10)) || (defined(MCU_MK50D7)) || (defined(MCU_MK50DZ10)) || (defined(MCU_MK51D10)) || (defined(MCU_MK51D7)) || (defined(MCU_MK51DZ10)) || (defined(MCU_MK52D10)) || (defined(MCU_MK52DZ10)) || (defined(MCU_MK53D10)) || (defined(MCU_MK53DZ10)) || (defined(MCU_MK60D10)) || (defined(MCU_MK60DZ10)) || (defined(MCU_MK60F12)) || (defined(MCU_MK60F15)) || (defined(MCU_MK60N512VMD100)) || (defined(MCU_MK61F12)) || (defined(MCU_MK61F12WS)) || (defined(MCU_MK61F15)) || (defined(MCU_MK61F15WS)) || (defined(MCU_MK63F12)) || (defined(MCU_MK63F12WS)) || (defined(MCU_MK64F12)) || (defined(MCU_MK65F18)) || (defined(MCU_MK65F18WS)) || (defined(MCU_MK66F18)) || (defined(MCU_MK70F12)) || (defined(MCU_MK70F12WS)) || (defined(MCU_MK70F15)) || (defined(MCU_MK70F15WS)) || (defined(MCU_MKV31F12810)) || (defined(MCU_MKV31F25612)) || (defined(MCU_MKV31F51212)) || (defined(MCU_MKW21D5)) || (defined(MCU_MKW21D5WS)) || (defined(MCU_MKW22D5)) || (defined(MCU_MKW22D5WS)) || (defined(MCU_MKW24D5)) || (defined(MCU_MKW24D5WS)) || (defined(MCU_PCK20L4)) */
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- WriteControlStatusReg
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Writes value to the control and status register.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param Value New content of the control and status register. This parameter
|
||||
* is a 32-bit value.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: SYST_CSR.
|
||||
* @par Example:
|
||||
* @code
|
||||
* SysTick_PDD_WriteControlStatusReg(<peripheral>_BASE_PTR, 1);
|
||||
* @endcode
|
||||
*/
|
||||
#define SysTick_PDD_WriteControlStatusReg(PeripheralBase, Value) ( \
|
||||
SysTick_CSR_REG(PeripheralBase) = \
|
||||
(uint32)(Value) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- ReadControlStatusReg
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Returns the content of the control and status register.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a 32-bit value.
|
||||
* @remarks The macro accesses the following registers: SYST_CSR.
|
||||
* @par Example:
|
||||
* @code
|
||||
* uint32 result =
|
||||
* SysTick_PDD_ReadControlStatusReg(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define SysTick_PDD_ReadControlStatusReg(PeripheralBase) ( \
|
||||
SysTick_CSR_REG(PeripheralBase) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- WriteReloadValueReg
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Writes value to the reload register.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param Value New content of the reload register. This parameter is a 32-bit
|
||||
* value.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: SYST_RVR.
|
||||
* @par Example:
|
||||
* @code
|
||||
* SysTick_PDD_WriteReloadValueReg(<peripheral>_BASE_PTR, 1);
|
||||
* @endcode
|
||||
*/
|
||||
#define SysTick_PDD_WriteReloadValueReg(PeripheralBase, Value) ( \
|
||||
SysTick_RVR_REG(PeripheralBase) = \
|
||||
(uint32)(Value) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- ReadReloadValueReg
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Returns the content of the reload register.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a 32-bit value.
|
||||
* @remarks The macro accesses the following registers: SYST_RVR.
|
||||
* @par Example:
|
||||
* @code
|
||||
* uint32 result = SysTick_PDD_ReadReloadValueReg(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define SysTick_PDD_ReadReloadValueReg(PeripheralBase) ( \
|
||||
SysTick_RVR_REG(PeripheralBase) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- WriteCurrentValueReg
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Writes value to the current value register.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param Value New content of the current value register. This parameter is a
|
||||
* 32-bit value.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: SYST_CVR.
|
||||
* @par Example:
|
||||
* @code
|
||||
* SysTick_PDD_WriteCurrentValueReg(<peripheral>_BASE_PTR, 1);
|
||||
* @endcode
|
||||
*/
|
||||
#define SysTick_PDD_WriteCurrentValueReg(PeripheralBase, Value) ( \
|
||||
SysTick_CVR_REG(PeripheralBase) = \
|
||||
(uint32)(Value) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- ReadCurrentValueReg
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Returns the content of the current value register.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a 32-bit value.
|
||||
* @remarks The macro accesses the following registers: SYST_CVR.
|
||||
* @par Example:
|
||||
* @code
|
||||
* uint32 result =
|
||||
* SysTick_PDD_ReadCurrentValueReg(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define SysTick_PDD_ReadCurrentValueReg(PeripheralBase) ( \
|
||||
SysTick_CVR_REG(PeripheralBase) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- ReadCalibrationReg
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Returns the content of the calibration register.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a 32-bit value.
|
||||
* @remarks The macro accesses the following registers: SYST_CALIB.
|
||||
* @par Example:
|
||||
* @code
|
||||
* uint32 result = SysTick_PDD_ReadCalibrationReg(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define SysTick_PDD_ReadCalibrationReg(PeripheralBase) ( \
|
||||
SysTick_CALIB_REG(PeripheralBase) \
|
||||
)
|
||||
#endif /* #if defined(SysTick_PDD_H_) */
|
||||
|
||||
/* SysTick_PDD.h, eof. */
|
||||
5346
Clean_TMC2209/lib/tmc/hal/Landungsbruecke/freescale/PDD/UART_PDD.h
Normal file
5346
Clean_TMC2209/lib/tmc/hal/Landungsbruecke/freescale/PDD/UART_PDD.h
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,816 @@
|
||||
/*
|
||||
PDD layer implementation for peripheral type USBDCD
|
||||
(C) 2013 Freescale, Inc. All rights reserved.
|
||||
|
||||
This file is static and it is generated from API-Factory
|
||||
*/
|
||||
|
||||
#if !defined(USBDCD_PDD_H_)
|
||||
#define USBDCD_PDD_H_
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- Test if supported MCU is active
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
#if !defined(MCU_ACTIVE)
|
||||
// No MCU is active
|
||||
#error USBDCD PDD library: No derivative is active. Place proper #include with PDD memory map before including PDD library.
|
||||
#elif \
|
||||
!defined(MCU_MK20D10) /* USBDCD */ && \
|
||||
!defined(MCU_MK20D5) /* USBDCD */ && \
|
||||
!defined(MCU_MK20D7) /* USBDCD */ && \
|
||||
!defined(MCU_MK20F12) /* USBDCD */ && \
|
||||
!defined(MCU_MK20DZ10) /* USBDCD */ && \
|
||||
!defined(MCU_MK21D5) /* USBDCD */ && \
|
||||
!defined(MCU_MK21D5WS) /* USBDCD */ && \
|
||||
!defined(MCU_MK21F12) /* USBDCD */ && \
|
||||
!defined(MCU_MK21F12WS) /* USBDCD */ && \
|
||||
!defined(MCU_MK22D5) /* USBDCD */ && \
|
||||
!defined(MCU_MK22F12) /* USBDCD */ && \
|
||||
!defined(MCU_MK24F12) /* USBDCD */ && \
|
||||
!defined(MCU_MK40D10) /* USBDCD */ && \
|
||||
!defined(MCU_MK40D7) /* USBDCD */ && \
|
||||
!defined(MCU_MK40DZ10) /* USBDCD */ && \
|
||||
!defined(MCU_MK40X256VMD100) /* USBDCD */ && \
|
||||
!defined(MCU_MK50D10) /* USBDCD */ && \
|
||||
!defined(MCU_MK50D7) /* USBDCD */ && \
|
||||
!defined(MCU_MK50DZ10) /* USBDCD */ && \
|
||||
!defined(MCU_MK51D10) /* USBDCD */ && \
|
||||
!defined(MCU_MK51D7) /* USBDCD */ && \
|
||||
!defined(MCU_MK51DZ10) /* USBDCD */ && \
|
||||
!defined(MCU_MK52D10) /* USBDCD */ && \
|
||||
!defined(MCU_MK52DZ10) /* USBDCD */ && \
|
||||
!defined(MCU_MK53D10) /* USBDCD */ && \
|
||||
!defined(MCU_MK53DZ10) /* USBDCD */ && \
|
||||
!defined(MCU_MK60D10) /* USBDCD */ && \
|
||||
!defined(MCU_MK60F12) /* USBDCD */ && \
|
||||
!defined(MCU_MK60F15) /* USBDCD */ && \
|
||||
!defined(MCU_MK60DZ10) /* USBDCD */ && \
|
||||
!defined(MCU_MK60N512VMD100) /* USBDCD */ && \
|
||||
!defined(MCU_MK61F12) /* USBDCD */ && \
|
||||
!defined(MCU_MK61F15) /* USBDCD */ && \
|
||||
!defined(MCU_MK61F12WS) /* USBDCD */ && \
|
||||
!defined(MCU_MK61F15WS) /* USBDCD */ && \
|
||||
!defined(MCU_MK63F12) /* USBDCD */ && \
|
||||
!defined(MCU_MK63F12WS) /* USBDCD */ && \
|
||||
!defined(MCU_MK64F12) /* USBDCD */ && \
|
||||
!defined(MCU_MK65F18) /* USBDCD, USBHSDCD */ && \
|
||||
!defined(MCU_MK65F18WS) /* USBDCD, USBHSDCD */ && \
|
||||
!defined(MCU_MK66F18) /* USBDCD, USBHSDCD */ && \
|
||||
!defined(MCU_MK70F12) /* USBDCD */ && \
|
||||
!defined(MCU_MK70F15) /* USBDCD */ && \
|
||||
!defined(MCU_MK70F12WS) /* USBDCD */ && \
|
||||
!defined(MCU_MK70F15WS) /* USBDCD */ && \
|
||||
!defined(MCU_MKW22D5) /* USBDCD */ && \
|
||||
!defined(MCU_MKW22D5WS) /* USBDCD */ && \
|
||||
!defined(MCU_MKW24D5) /* USBDCD */ && \
|
||||
!defined(MCU_MKW24D5WS) /* USBDCD */ && \
|
||||
!defined(MCU_PCK20L4) /* USBDCD */
|
||||
// Unsupported MCU is active
|
||||
#error USBDCD PDD library: Unsupported derivative is active.
|
||||
#endif
|
||||
|
||||
#include "PDD_Types.h"
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- Method symbol definitions
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/* Status flags constants (for ReadStatusReg macro). */
|
||||
#define USBDCD_PDD_ACTIVE_STATUS_INDICATOR USBDCD_STATUS_ACTIVE_MASK /**< Active status indicator - indicates whether the sequence is running */
|
||||
#define USBDCD_PDD_TIMEOUT_FLAG USBDCD_STATUS_TO_MASK /**< Timeout flag */
|
||||
#define USBDCD_PDD_ERROR_FLAG USBDCD_STATUS_ERR_MASK /**< Error flag */
|
||||
|
||||
/* Receiver status bits constants */
|
||||
#define USBDCD_PDD_DATA_PIN_NOT_DETECTED 0U /**< The module is either not enabled, or the module is enabled but the data pins have not yet been detected */
|
||||
#define USBDCD_PDD_DATA_PIN_CONTACT_COMPLETE 0x40000U /**< Data pin contact detection complete */
|
||||
#define USBDCD_PDD_CHARGER_PORT_COMPLETE 0x80000U /**< Charger port detection complete */
|
||||
#define USBDCD_PDD_CHARGER_TYPE_COMPLETE 0xC0000U /**< Charger type detection complete */
|
||||
|
||||
/* Receiver status bits constants */
|
||||
#define USBDCD_PDD_NO_RESULTS_REPORTED 0U /**< No results to report */
|
||||
#define USBDCD_PDD_ATTACHED_TO_HOST 0x10000U /**< Attached to a standard host */
|
||||
#define USBDCD_PDD_ATTACHED_TO_CHARGING_PORT 0x20000U /**< Attached to a charging port */
|
||||
#define USBDCD_PDD_ATTACHED_TO_DEDICATED_CHARGER 0x30000U /**< Attached to a dedicated charger. */
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- PerformSoftwareReset
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Perform a software reset.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: USBDCD_CONTROL,
|
||||
* USBHSDCD_CONTROL (depending on the peripheral).
|
||||
* @par Example:
|
||||
* @code
|
||||
* USBDCD_PDD_PerformSoftwareReset(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define USBDCD_PDD_PerformSoftwareReset(PeripheralBase) ( \
|
||||
USBDCD_CONTROL_REG(PeripheralBase) |= \
|
||||
USBDCD_CONTROL_SR_MASK \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- StartChangeDetectionSequence
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Initiate the charger detection sequence.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: USBDCD_CONTROL,
|
||||
* USBHSDCD_CONTROL (depending on the peripheral).
|
||||
* @par Example:
|
||||
* @code
|
||||
* USBDCD_PDD_StartChangeDetectionSequence(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define USBDCD_PDD_StartChangeDetectionSequence(PeripheralBase) ( \
|
||||
USBDCD_CONTROL_REG(PeripheralBase) |= \
|
||||
USBDCD_CONTROL_START_MASK \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- EnableInterrupt
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Enables interrupts to the system.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: USBDCD_CONTROL,
|
||||
* USBHSDCD_CONTROL (depending on the peripheral).
|
||||
* @par Example:
|
||||
* @code
|
||||
* USBDCD_PDD_EnableInterrupt(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define USBDCD_PDD_EnableInterrupt(PeripheralBase) ( \
|
||||
USBDCD_CONTROL_REG(PeripheralBase) |= \
|
||||
USBDCD_CONTROL_IE_MASK \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- DisableInterrupt
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Disable interrupts to the system.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: USBDCD_CONTROL,
|
||||
* USBHSDCD_CONTROL (depending on the peripheral).
|
||||
* @par Example:
|
||||
* @code
|
||||
* USBDCD_PDD_DisableInterrupt(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define USBDCD_PDD_DisableInterrupt(PeripheralBase) ( \
|
||||
USBDCD_CONTROL_REG(PeripheralBase) &= \
|
||||
(uint32)(~(uint32)USBDCD_CONTROL_IE_MASK) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- GetInterruptFlag
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Gets the status of the interrupt flag bit.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a 32-bit value.
|
||||
* @remarks The macro accesses the following registers: USBDCD_CONTROL,
|
||||
* USBHSDCD_CONTROL (depending on the peripheral).
|
||||
* @par Example:
|
||||
* @code
|
||||
* uint32 result = USBDCD_PDD_GetInterruptFlag(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define USBDCD_PDD_GetInterruptFlag(PeripheralBase) ( \
|
||||
(uint32)(USBDCD_CONTROL_REG(PeripheralBase) & USBDCD_CONTROL_IF_MASK) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- ClearInterruptFlag
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Clears interrupt flag.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: USBDCD_CONTROL,
|
||||
* USBHSDCD_CONTROL (depending on the peripheral).
|
||||
* @par Example:
|
||||
* @code
|
||||
* USBDCD_PDD_ClearInterruptFlag(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define USBDCD_PDD_ClearInterruptFlag(PeripheralBase) ( \
|
||||
USBDCD_CONTROL_REG(PeripheralBase) |= \
|
||||
USBDCD_CONTROL_IACK_MASK \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- ReadControlReg
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Reads control register.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a 32-bit value.
|
||||
* @remarks The macro accesses the following registers: USBDCD_CONTROL,
|
||||
* USBHSDCD_CONTROL (depending on the peripheral).
|
||||
* @par Example:
|
||||
* @code
|
||||
* uint32 result = USBDCD_PDD_ReadControlReg(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define USBDCD_PDD_ReadControlReg(PeripheralBase) ( \
|
||||
USBDCD_CONTROL_REG(PeripheralBase) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- WriteControlReg
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Writes data specified by the Value parameter into control register.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param Value Value to be written to the control register. This parameter is a
|
||||
* 32-bit value.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: USBDCD_CONTROL,
|
||||
* USBHSDCD_CONTROL (depending on the peripheral).
|
||||
* @par Example:
|
||||
* @code
|
||||
* USBDCD_PDD_WriteControlReg(<peripheral>_BASE_PTR, 1);
|
||||
* @endcode
|
||||
*/
|
||||
#define USBDCD_PDD_WriteControlReg(PeripheralBase, Value) ( \
|
||||
USBDCD_CONTROL_REG(PeripheralBase) = \
|
||||
(uint32)(Value) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- SetClockSpeedInKhz
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Sets the numerical value of clock speed in kHz.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param Value Clock speed in kHz, value[1..1023]. This parameter is a 10-bit
|
||||
* value.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: USBDCD_CLOCK,
|
||||
* USBHSDCD_CLOCK (depending on the peripheral).
|
||||
* @par Example:
|
||||
* @code
|
||||
* USBDCD_PDD_SetClockSpeedInKhz(<peripheral>_BASE_PTR, 1);
|
||||
* @endcode
|
||||
*/
|
||||
#define USBDCD_PDD_SetClockSpeedInKhz(PeripheralBase, Value) ( \
|
||||
USBDCD_CLOCK_REG(PeripheralBase) = \
|
||||
(uint32)(( \
|
||||
(uint32)(( \
|
||||
USBDCD_CLOCK_REG(PeripheralBase)) & (( \
|
||||
(uint32)(~(uint32)USBDCD_CLOCK_CLOCK_SPEED_MASK)) & ( \
|
||||
(uint32)(~(uint32)USBDCD_CLOCK_CLOCK_UNIT_MASK))))) | ( \
|
||||
(uint32)((uint32)(Value) << USBDCD_CLOCK_CLOCK_SPEED_SHIFT))) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- SetClockSpeedInMhz
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Sets the numerical value of clock speed in MHz.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param Value Clock speed in MHz, value[1..1023]. This parameter is a 10-bit
|
||||
* value.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: USBDCD_CLOCK,
|
||||
* USBHSDCD_CLOCK (depending on the peripheral).
|
||||
* @par Example:
|
||||
* @code
|
||||
* USBDCD_PDD_SetClockSpeedInMhz(<peripheral>_BASE_PTR, 1);
|
||||
* @endcode
|
||||
*/
|
||||
#define USBDCD_PDD_SetClockSpeedInMhz(PeripheralBase, Value) ( \
|
||||
USBDCD_CLOCK_REG(PeripheralBase) = \
|
||||
(uint32)(( \
|
||||
(uint32)(( \
|
||||
USBDCD_CLOCK_REG(PeripheralBase)) & ( \
|
||||
(uint32)(~(uint32)USBDCD_CLOCK_CLOCK_SPEED_MASK)))) | (( \
|
||||
(uint32)((uint32)(Value) << USBDCD_CLOCK_CLOCK_SPEED_SHIFT)) | ( \
|
||||
USBDCD_CLOCK_CLOCK_UNIT_MASK))) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- ReadClockReg
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Reads clock register.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a 32-bit value.
|
||||
* @remarks The macro accesses the following registers: USBDCD_CLOCK,
|
||||
* USBHSDCD_CLOCK (depending on the peripheral).
|
||||
* @par Example:
|
||||
* @code
|
||||
* uint32 result = USBDCD_PDD_ReadClockReg(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define USBDCD_PDD_ReadClockReg(PeripheralBase) ( \
|
||||
USBDCD_CLOCK_REG(PeripheralBase) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- WriteClockReg
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Writes data specified by the Value parameter into clock register.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param Value Value to be written to the clock register. This parameter is a
|
||||
* 32-bit value.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: USBDCD_CLOCK,
|
||||
* USBHSDCD_CLOCK (depending on the peripheral).
|
||||
* @par Example:
|
||||
* @code
|
||||
* USBDCD_PDD_WriteClockReg(<peripheral>_BASE_PTR, 1);
|
||||
* @endcode
|
||||
*/
|
||||
#define USBDCD_PDD_WriteClockReg(PeripheralBase, Value) ( \
|
||||
USBDCD_CLOCK_REG(PeripheralBase) = \
|
||||
(uint32)(Value) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- GetStatusFlags
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Returns the value of the status register.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a 32-bit value.
|
||||
* @remarks The macro accesses the following registers: USBDCD_STATUS,
|
||||
* USBHSDCD_STATUS (depending on the peripheral).
|
||||
* @par Example:
|
||||
* @code
|
||||
* uint32 result = USBDCD_PDD_GetStatusFlags(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define USBDCD_PDD_GetStatusFlags(PeripheralBase) ( \
|
||||
USBDCD_STATUS_REG(PeripheralBase) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- GetChargerDetectionSequenceStatus
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Returns charger detection sequence status.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a value of "Receiver status bits constants" type. The value
|
||||
* is cast to "uint32".
|
||||
* @remarks The macro accesses the following registers: USBDCD_STATUS,
|
||||
* USBHSDCD_STATUS (depending on the peripheral).
|
||||
* @par Example:
|
||||
* @code
|
||||
* uint32 result =
|
||||
* USBDCD_PDD_GetChargerDetectionSequenceStatus(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define USBDCD_PDD_GetChargerDetectionSequenceStatus(PeripheralBase) ( \
|
||||
(uint32)(USBDCD_STATUS_REG(PeripheralBase) & USBDCD_STATUS_SEQ_STAT_MASK) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- GetChargerDetectionSequenceResults
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Returns charger detection sequence status.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a value of "Receiver status bits constants" type. The value
|
||||
* is cast to "uint32".
|
||||
* @remarks The macro accesses the following registers: USBDCD_STATUS,
|
||||
* USBHSDCD_STATUS (depending on the peripheral).
|
||||
* @par Example:
|
||||
* @code
|
||||
* uint32 result =
|
||||
* USBDCD_PDD_GetChargerDetectionSequenceResults(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define USBDCD_PDD_GetChargerDetectionSequenceResults(PeripheralBase) ( \
|
||||
(uint32)(USBDCD_STATUS_REG(PeripheralBase) & USBDCD_STATUS_SEQ_RES_MASK) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- ReadStatusReg
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Reads status register.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Use constants from group "Status flags constants (for ReadStatusReg
|
||||
* macro)." for processing return value.
|
||||
* @remarks The macro accesses the following registers: USBDCD_STATUS,
|
||||
* USBHSDCD_STATUS (depending on the peripheral).
|
||||
* @par Example:
|
||||
* @code
|
||||
* uint32 result = USBDCD_PDD_ReadStatusReg(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define USBDCD_PDD_ReadStatusReg(PeripheralBase) ( \
|
||||
USBDCD_STATUS_REG(PeripheralBase) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- SetSequenceInitiationTime
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Sets the system latency (in ms).
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param Time System latency (in ms) value[0..1023]. This parameter is a 10-bit
|
||||
* value.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: USBDCD_TIMER0,
|
||||
* USBHSDCD_TIMER0 (depending on the peripheral).
|
||||
* @par Example:
|
||||
* @code
|
||||
* USBDCD_PDD_SetSequenceInitiationTime(<peripheral>_BASE_PTR, 1);
|
||||
* @endcode
|
||||
*/
|
||||
#define USBDCD_PDD_SetSequenceInitiationTime(PeripheralBase, Time) ( \
|
||||
USBDCD_TIMER0_REG(PeripheralBase) = \
|
||||
(uint32)(( \
|
||||
(uint32)(( \
|
||||
USBDCD_TIMER0_REG(PeripheralBase)) & ( \
|
||||
(uint32)(~(uint32)USBDCD_TIMER0_TSEQ_INIT_MASK)))) | ( \
|
||||
(uint32)((uint32)(Time) << USBDCD_TIMER0_TSEQ_INIT_SHIFT))) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- GetUnitConnectionTimerElapse
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Returns unit connection timer elapse value (in ms).
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a 12-bit value. The value is cast to "uint16".
|
||||
* @remarks The macro accesses the following registers: USBDCD_TIMER0,
|
||||
* USBHSDCD_TIMER0 (depending on the peripheral).
|
||||
* @par Example:
|
||||
* @code
|
||||
* uint16 result =
|
||||
* USBDCD_PDD_GetUnitConnectionTimerElapse(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define USBDCD_PDD_GetUnitConnectionTimerElapse(PeripheralBase) ( \
|
||||
(uint16)(USBDCD_TIMER0_REG(PeripheralBase) & USBDCD_TIMER0_TUNITCON_MASK) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- ReadTimer0Reg
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Reads timer 0 register.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a 32-bit value.
|
||||
* @remarks The macro accesses the following registers: USBDCD_TIMER0,
|
||||
* USBHSDCD_TIMER0 (depending on the peripheral).
|
||||
* @par Example:
|
||||
* @code
|
||||
* uint32 result = USBDCD_PDD_ReadTimer0Reg(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define USBDCD_PDD_ReadTimer0Reg(PeripheralBase) ( \
|
||||
USBDCD_TIMER0_REG(PeripheralBase) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- WriteTimer0Reg
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Writes data specified by the Value parameter into timer 0 register.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param Value Value to be written to the timer 0 register. This parameter is a
|
||||
* 32-bit value.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: USBDCD_TIMER0,
|
||||
* USBHSDCD_TIMER0 (depending on the peripheral).
|
||||
* @par Example:
|
||||
* @code
|
||||
* USBDCD_PDD_WriteTimer0Reg(<peripheral>_BASE_PTR, 1);
|
||||
* @endcode
|
||||
*/
|
||||
#define USBDCD_PDD_WriteTimer0Reg(PeripheralBase, Value) ( \
|
||||
USBDCD_TIMER0_REG(PeripheralBase) = \
|
||||
(uint32)(Value) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- SetTimePeriodToDebounceDpSignal
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Sets the time period (ms) to debounce the D+ signal during the data
|
||||
* pin contact detection phase.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param Period Time period (in ms) value[1..1023]. This parameter is a 10-bit
|
||||
* value.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: USBDCD_TIMER1,
|
||||
* USBHSDCD_TIMER1 (depending on the peripheral).
|
||||
* @par Example:
|
||||
* @code
|
||||
* USBDCD_PDD_SetTimePeriodToDebounceDpSignal(<peripheral>_BASE_PTR, 1);
|
||||
* @endcode
|
||||
*/
|
||||
#define USBDCD_PDD_SetTimePeriodToDebounceDpSignal(PeripheralBase, Period) ( \
|
||||
USBDCD_TIMER1_REG(PeripheralBase) = \
|
||||
(uint32)(( \
|
||||
(uint32)(( \
|
||||
USBDCD_TIMER1_REG(PeripheralBase)) & ( \
|
||||
(uint32)(~(uint32)USBDCD_TIMER1_TDCD_DBNC_MASK)))) | ( \
|
||||
(uint32)((uint32)(Period) << USBDCD_TIMER1_TDCD_DBNC_SHIFT))) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- SetTimePeriodComparator
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Sets the time period (ms) comparator enabled.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param Period Time period (in ms) value[1..1023]. This parameter is a 10-bit
|
||||
* value.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: USBDCD_TIMER1,
|
||||
* USBHSDCD_TIMER1 (depending on the peripheral).
|
||||
* @par Example:
|
||||
* @code
|
||||
* USBDCD_PDD_SetTimePeriodComparator(<peripheral>_BASE_PTR, 1);
|
||||
* @endcode
|
||||
*/
|
||||
#define USBDCD_PDD_SetTimePeriodComparator(PeripheralBase, Period) ( \
|
||||
USBDCD_TIMER1_REG(PeripheralBase) = \
|
||||
(uint32)(( \
|
||||
(uint32)(( \
|
||||
USBDCD_TIMER1_REG(PeripheralBase)) & ( \
|
||||
(uint32)(~(uint32)USBDCD_TIMER1_TVDPSRC_ON_MASK)))) | ( \
|
||||
(uint32)(Period))) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- ReadTimer1Reg
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Reads timer 1 register.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a 32-bit value.
|
||||
* @remarks The macro accesses the following registers: USBDCD_TIMER1,
|
||||
* USBHSDCD_TIMER1 (depending on the peripheral).
|
||||
* @par Example:
|
||||
* @code
|
||||
* uint32 result = USBDCD_PDD_ReadTimer1Reg(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define USBDCD_PDD_ReadTimer1Reg(PeripheralBase) ( \
|
||||
USBDCD_TIMER1_REG(PeripheralBase) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- WriteTimer1Reg
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Writes data specified by the Value parameter into timer 1 register.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param Value Value to be written to the timer 1 register. This parameter is a
|
||||
* 32-bit value.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: USBDCD_TIMER1,
|
||||
* USBHSDCD_TIMER1 (depending on the peripheral).
|
||||
* @par Example:
|
||||
* @code
|
||||
* USBDCD_PDD_WriteTimer1Reg(<peripheral>_BASE_PTR, 1);
|
||||
* @endcode
|
||||
*/
|
||||
#define USBDCD_PDD_WriteTimer1Reg(PeripheralBase, Value) ( \
|
||||
USBDCD_TIMER1_REG(PeripheralBase) = \
|
||||
(uint32)(Value) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- SetTimePeriodBeforeEnablingDpPullup
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Sets the time period (ms) before enabling D+ pullup.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param Period Time period (in ms) value[1..1023]. This parameter is a 10-bit
|
||||
* value.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: USBDCD_TIMER2.
|
||||
* @par Example:
|
||||
* @code
|
||||
* USBDCD_PDD_SetTimePeriodBeforeEnablingDpPullup(<peripheral>_BASE_PTR,
|
||||
* 1);
|
||||
* @endcode
|
||||
*/
|
||||
#define USBDCD_PDD_SetTimePeriodBeforeEnablingDpPullup(PeripheralBase, Period) ( \
|
||||
USBDCD_TIMER2_REG(PeripheralBase) = \
|
||||
(uint32)(( \
|
||||
(uint32)(( \
|
||||
USBDCD_TIMER2_REG(PeripheralBase)) & ( \
|
||||
(uint32)(~(uint32)USBDCD_TIMER2_TVDPSRC_CON_MASK)))) | ( \
|
||||
(uint32)((uint32)(Period) << USBDCD_TIMER2_TVDPSRC_CON_SHIFT))) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- SetTimeBeforeCheckDmLine
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Sets the time period (ms) before check D- line.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param Value Time (in ms) value[1..15]. This parameter is a 4-bit value.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: USBDCD_TIMER2.
|
||||
* @par Example:
|
||||
* @code
|
||||
* USBDCD_PDD_SetTimeBeforeCheckDmLine(<peripheral>_BASE_PTR, 1);
|
||||
* @endcode
|
||||
*/
|
||||
#define USBDCD_PDD_SetTimeBeforeCheckDmLine(PeripheralBase, Value) ( \
|
||||
USBDCD_TIMER2_REG(PeripheralBase) = \
|
||||
(uint32)(( \
|
||||
(uint32)(( \
|
||||
USBDCD_TIMER2_REG(PeripheralBase)) & ( \
|
||||
(uint32)(~(uint32)USBDCD_TIMER2_CHECK_DM_MASK)))) | ( \
|
||||
(uint32)(Value))) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- ReadTimer2Reg
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Reads timer 2 register.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a 32-bit value.
|
||||
* @remarks The macro accesses the following registers: USBDCD_TIMER2.
|
||||
* @par Example:
|
||||
* @code
|
||||
* uint32 result = USBDCD_PDD_ReadTimer2Reg(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define USBDCD_PDD_ReadTimer2Reg(PeripheralBase) ( \
|
||||
USBDCD_TIMER2_REG(PeripheralBase) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- WriteTimer2Reg
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Writes data specified by the Value parameter into timer 2 register.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param Value Value to be written to the timer 2 register. This parameter is a
|
||||
* 32-bit value.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: USBDCD_TIMER2.
|
||||
* @par Example:
|
||||
* @code
|
||||
* USBDCD_PDD_WriteTimer2Reg(<peripheral>_BASE_PTR, 1);
|
||||
* @endcode
|
||||
*/
|
||||
#define USBDCD_PDD_WriteTimer2Reg(PeripheralBase, Value) ( \
|
||||
USBDCD_TIMER2_REG(PeripheralBase) = \
|
||||
(uint32)(Value) \
|
||||
)
|
||||
#endif /* #if defined(USBDCD_PDD_H_) */
|
||||
|
||||
/* USBDCD_PDD.h, eof. */
|
||||
4849
Clean_TMC2209/lib/tmc/hal/Landungsbruecke/freescale/PDD/USB_PDD.h
Normal file
4849
Clean_TMC2209/lib/tmc/hal/Landungsbruecke/freescale/PDD/USB_PDD.h
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,413 @@
|
||||
/*
|
||||
PDD layer implementation for peripheral type VREF
|
||||
(C) 2013 Freescale, Inc. All rights reserved.
|
||||
|
||||
This file is static and it is generated from API-Factory
|
||||
*/
|
||||
|
||||
#if !defined(VREF_PDD_H_)
|
||||
#define VREF_PDD_H_
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- Test if supported MCU is active
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
#if !defined(MCU_ACTIVE)
|
||||
// No MCU is active
|
||||
#error VREF PDD library: No derivative is active. Place proper #include with PDD memory map before including PDD library.
|
||||
#elif \
|
||||
!defined(MCU_MK10D10) /* VREF */ && \
|
||||
!defined(MCU_MK10D5) /* VREF */ && \
|
||||
!defined(MCU_MK10D7) /* VREF */ && \
|
||||
!defined(MCU_MK10F12) /* VREF */ && \
|
||||
!defined(MCU_MK10DZ10) /* VREF */ && \
|
||||
!defined(MCU_MK11D5) /* VREF */ && \
|
||||
!defined(MCU_MK11D5WS) /* VREF */ && \
|
||||
!defined(MCU_MK12D5) /* VREF */ && \
|
||||
!defined(MCU_MK20D10) /* VREF */ && \
|
||||
!defined(MCU_MK20D5) /* VREF */ && \
|
||||
!defined(MCU_MK20D7) /* VREF */ && \
|
||||
!defined(MCU_MK20F12) /* VREF */ && \
|
||||
!defined(MCU_MK20DZ10) /* VREF */ && \
|
||||
!defined(MCU_MK21D5) /* VREF */ && \
|
||||
!defined(MCU_MK21D5WS) /* VREF */ && \
|
||||
!defined(MCU_MK21F12) /* VREF */ && \
|
||||
!defined(MCU_MK21F12WS) /* VREF */ && \
|
||||
!defined(MCU_MK22D5) /* VREF */ && \
|
||||
!defined(MCU_MK22F12810) /* VREF */ && \
|
||||
!defined(MCU_MK22F12) /* VREF */ && \
|
||||
!defined(MCU_MK22F25612) /* VREF */ && \
|
||||
!defined(MCU_MK22F51212) /* VREF */ && \
|
||||
!defined(MCU_MK24F12) /* VREF */ && \
|
||||
!defined(MCU_MK30D10) /* VREF */ && \
|
||||
!defined(MCU_MK30D7) /* VREF */ && \
|
||||
!defined(MCU_MK30DZ10) /* VREF */ && \
|
||||
!defined(MCU_MK40D10) /* VREF */ && \
|
||||
!defined(MCU_MK40D7) /* VREF */ && \
|
||||
!defined(MCU_MK40DZ10) /* VREF */ && \
|
||||
!defined(MCU_MK40X256VMD100) /* VREF */ && \
|
||||
!defined(MCU_MK50D10) /* VREF */ && \
|
||||
!defined(MCU_MK50D7) /* VREF */ && \
|
||||
!defined(MCU_MK50DZ10) /* VREF */ && \
|
||||
!defined(MCU_MK51D10) /* VREF */ && \
|
||||
!defined(MCU_MK51D7) /* VREF */ && \
|
||||
!defined(MCU_MK51DZ10) /* VREF */ && \
|
||||
!defined(MCU_MK52D10) /* VREF */ && \
|
||||
!defined(MCU_MK52DZ10) /* VREF */ && \
|
||||
!defined(MCU_MK53D10) /* VREF */ && \
|
||||
!defined(MCU_MK53DZ10) /* VREF */ && \
|
||||
!defined(MCU_MK60D10) /* VREF */ && \
|
||||
!defined(MCU_MK60F12) /* VREF */ && \
|
||||
!defined(MCU_MK60F15) /* VREF */ && \
|
||||
!defined(MCU_MK60DZ10) /* VREF */ && \
|
||||
!defined(MCU_MK60N512VMD100) /* VREF */ && \
|
||||
!defined(MCU_MK61F12) /* VREF */ && \
|
||||
!defined(MCU_MK61F15) /* VREF */ && \
|
||||
!defined(MCU_MK61F12WS) /* VREF */ && \
|
||||
!defined(MCU_MK61F15WS) /* VREF */ && \
|
||||
!defined(MCU_MK63F12) /* VREF */ && \
|
||||
!defined(MCU_MK63F12WS) /* VREF */ && \
|
||||
!defined(MCU_MK64F12) /* VREF */ && \
|
||||
!defined(MCU_MK65F18) /* VREF */ && \
|
||||
!defined(MCU_MK65F18WS) /* VREF */ && \
|
||||
!defined(MCU_MK66F18) /* VREF */ && \
|
||||
!defined(MCU_MK70F12) /* VREF */ && \
|
||||
!defined(MCU_MK70F15) /* VREF */ && \
|
||||
!defined(MCU_MK70F12WS) /* VREF */ && \
|
||||
!defined(MCU_MK70F15WS) /* VREF */ && \
|
||||
!defined(MCU_MKL03Z4) /* VREF */ && \
|
||||
!defined(MCU_MKV31F12810) /* VREF */ && \
|
||||
!defined(MCU_MKV31F25612) /* VREF */ && \
|
||||
!defined(MCU_MKV31F51212) /* VREF */ && \
|
||||
!defined(MCU_PCK20L4) /* VREF */
|
||||
// Unsupported MCU is active
|
||||
#error VREF PDD library: Unsupported derivative is active.
|
||||
#endif
|
||||
|
||||
#include "PDD_Types.h"
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- Method symbol definitions
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/* Position of a parity bit */
|
||||
#define VREF_PDD_DISABLED_OR_NOT_STABLE 0U /**< The module is disabled or not stable. */
|
||||
#define VREF_PDD_STABLE 0x4U /**< The module is stable. */
|
||||
|
||||
/* Type of the buffer mode. */
|
||||
#define VREF_PDD_BANDGAP_ON_ONLY 0U /**< Bandgap on only, for stabilization and startup. */
|
||||
#define VREF_PDD_HIGH_POWER_BUFFER 0x1U /**< High power buffer mode enabled. */
|
||||
#define VREF_PDD_LOW_POWER_BUFFER 0x2U /**< Low power buffer mode enabled. */
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- EnableChopOscillator
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Enables chop oscillator.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param State Enables or disables chop oscillator. This parameter is of
|
||||
* "Global enumeration used for specifying general enable/disable states
|
||||
* (PDD_DISABLE and PDD_ENABLE defined in PDD_Types.h)" type.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: VREF_TRM.
|
||||
* @par Example:
|
||||
* @code
|
||||
* VREF_PDD_EnableChopOscillator(<peripheral>_BASE_PTR, PDD_DISABLE);
|
||||
* @endcode
|
||||
*/
|
||||
#define VREF_PDD_EnableChopOscillator(PeripheralBase, State) ( \
|
||||
VREF_TRM_REG(PeripheralBase) = \
|
||||
(uint8)(( \
|
||||
(uint8)(VREF_TRM_REG(PeripheralBase) & (uint8)(~(uint8)VREF_TRM_CHOPEN_MASK))) | ( \
|
||||
(uint8)((uint8)(State) << VREF_TRM_CHOPEN_SHIFT))) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- SetTrimValue
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Set trim value for voltage reference correction.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param Value Trim value. This parameter is a 6-bit value.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: VREF_TRM.
|
||||
* @par Example:
|
||||
* @code
|
||||
* VREF_PDD_SetTrimValue(<peripheral>_BASE_PTR, 1);
|
||||
* @endcode
|
||||
*/
|
||||
#define VREF_PDD_SetTrimValue(PeripheralBase, Value) ( \
|
||||
VREF_TRM_REG(PeripheralBase) = \
|
||||
(uint8)(( \
|
||||
(uint8)(VREF_TRM_REG(PeripheralBase) & (uint8)(~(uint8)VREF_TRM_TRIM_MASK))) | ( \
|
||||
(uint8)(Value))) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- GetTrimValue
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Returns trim value for voltage reference correction.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a 6-bit value. The value is cast to "uint8".
|
||||
* @remarks The macro accesses the following registers: VREF_TRM.
|
||||
* @par Example:
|
||||
* @code
|
||||
* uint8 result = VREF_PDD_GetTrimValue(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define VREF_PDD_GetTrimValue(PeripheralBase) ( \
|
||||
(uint8)(VREF_TRM_REG(PeripheralBase) & VREF_TRM_TRIM_MASK) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- ReadTrimReg
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Reads trim register.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a 8-bit value.
|
||||
* @remarks The macro accesses the following registers: VREF_TRM.
|
||||
* @par Example:
|
||||
* @code
|
||||
* uint8 result = VREF_PDD_ReadTrimReg(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define VREF_PDD_ReadTrimReg(PeripheralBase) ( \
|
||||
VREF_TRM_REG(PeripheralBase) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- WriteTrimReg
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Writes new value specified by the Value parameter into trim register.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param Value Value to be written to the trim register. This parameter is a
|
||||
* 8-bit value.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: VREF_TRM.
|
||||
* @par Example:
|
||||
* @code
|
||||
* VREF_PDD_WriteTrimReg(<peripheral>_BASE_PTR, 1);
|
||||
* @endcode
|
||||
*/
|
||||
#define VREF_PDD_WriteTrimReg(PeripheralBase, Value) ( \
|
||||
VREF_TRM_REG(PeripheralBase) = \
|
||||
(uint8)(Value) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- EnableInternalVoltageReference
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Enables internal voltage reference.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param State Enables or disables internal voltage reference. This parameter
|
||||
* is of "Global enumeration used for specifying general enable/disable
|
||||
* states (PDD_DISABLE and PDD_ENABLE defined in PDD_Types.h)" type.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: VREF_SC.
|
||||
* @par Example:
|
||||
* @code
|
||||
* VREF_PDD_EnableInternalVoltageReference(<peripheral>_BASE_PTR,
|
||||
* PDD_DISABLE);
|
||||
* @endcode
|
||||
*/
|
||||
#define VREF_PDD_EnableInternalVoltageReference(PeripheralBase, State) ( \
|
||||
VREF_SC_REG(PeripheralBase) = \
|
||||
(uint8)(( \
|
||||
(uint8)(VREF_SC_REG(PeripheralBase) & (uint8)(~(uint8)VREF_SC_VREFEN_MASK))) | ( \
|
||||
(uint8)((uint8)(State) << VREF_SC_VREFEN_SHIFT))) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- EnableRegulator
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Enables regulator.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param State Enables or disables regulator. This parameter is of "Global
|
||||
* enumeration used for specifying general enable/disable states (PDD_DISABLE
|
||||
* and PDD_ENABLE defined in PDD_Types.h)" type.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: VREF_SC.
|
||||
* @par Example:
|
||||
* @code
|
||||
* VREF_PDD_EnableRegulator(<peripheral>_BASE_PTR, PDD_DISABLE);
|
||||
* @endcode
|
||||
*/
|
||||
#define VREF_PDD_EnableRegulator(PeripheralBase, State) ( \
|
||||
VREF_SC_REG(PeripheralBase) = \
|
||||
(uint8)(( \
|
||||
(uint8)(VREF_SC_REG(PeripheralBase) & (uint8)(~(uint8)VREF_SC_REGEN_MASK))) | ( \
|
||||
(uint8)((uint8)(State) << VREF_SC_REGEN_SHIFT))) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- EnableSecondOrderCurvatureCompensation
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Enables second order curvature compensation.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param State Enables or disables second order curvature compensation. This
|
||||
* parameter is of "Global enumeration used for specifying general
|
||||
* enable/disable states (PDD_DISABLE and PDD_ENABLE defined in PDD_Types.h)" type.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: VREF_SC.
|
||||
* @par Example:
|
||||
* @code
|
||||
* VREF_PDD_EnableSecondOrderCurvatureCompensation(<peripheral>_BASE_PTR,
|
||||
* PDD_DISABLE);
|
||||
* @endcode
|
||||
*/
|
||||
#define VREF_PDD_EnableSecondOrderCurvatureCompensation(PeripheralBase, State) ( \
|
||||
VREF_SC_REG(PeripheralBase) = \
|
||||
(uint8)(( \
|
||||
(uint8)(VREF_SC_REG(PeripheralBase) & (uint8)(~(uint8)VREF_SC_ICOMPEN_MASK))) | ( \
|
||||
(uint8)((uint8)(State) << VREF_SC_ICOMPEN_SHIFT))) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- GetInternalVoltageReferenceState
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Returns state of the internal voltage reference.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a value of "Position of a parity bit" type. The value is cast
|
||||
* to "uint8".
|
||||
* @remarks The macro accesses the following registers: VREF_SC.
|
||||
* @par Example:
|
||||
* @code
|
||||
* uint8 result =
|
||||
* VREF_PDD_GetInternalVoltageReferenceState(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define VREF_PDD_GetInternalVoltageReferenceState(PeripheralBase) ( \
|
||||
(uint8)(VREF_SC_REG(PeripheralBase) & VREF_SC_VREFST_MASK) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- SelectBufferMode
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Selects buffer mode.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param Mode Type of the match operation. This parameter is of "Type of the
|
||||
* buffer mode." type.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: VREF_SC.
|
||||
* @par Example:
|
||||
* @code
|
||||
* VREF_PDD_SelectBufferMode(<peripheral>_BASE_PTR,
|
||||
* VREF_PDD_BANDGAP_ON_ONLY);
|
||||
* @endcode
|
||||
*/
|
||||
#define VREF_PDD_SelectBufferMode(PeripheralBase, Mode) ( \
|
||||
VREF_SC_REG(PeripheralBase) = \
|
||||
(uint8)(( \
|
||||
(uint8)(VREF_SC_REG(PeripheralBase) & (uint8)(~(uint8)VREF_SC_MODE_LV_MASK))) | ( \
|
||||
(uint8)(Mode))) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- ReadStatusControlReg
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Reads status and control register.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @return Returns a 8-bit value.
|
||||
* @remarks The macro accesses the following registers: VREF_SC.
|
||||
* @par Example:
|
||||
* @code
|
||||
* uint8 result = VREF_PDD_ReadStatusControlReg(<peripheral>_BASE_PTR);
|
||||
* @endcode
|
||||
*/
|
||||
#define VREF_PDD_ReadStatusControlReg(PeripheralBase) ( \
|
||||
VREF_SC_REG(PeripheralBase) \
|
||||
)
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- WriteStatusControlReg
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @brief Writes new value specified by the Value parameter into status and
|
||||
* control register.
|
||||
* @param PeripheralBase Pointer to a peripheral registers structure (peripheral
|
||||
* base address). You can use the constant defined in the registers
|
||||
* definition header file (<peripheral>_BASE_PTR) or the constant defined in
|
||||
* the peripheral initialization component header file
|
||||
* (<component_name>_DEVICE).
|
||||
* @param Value Value to be written to the status and control register. This
|
||||
* parameter is a 8-bit value.
|
||||
* @return Returns a value of void type.
|
||||
* @remarks The macro accesses the following registers: VREF_SC.
|
||||
* @par Example:
|
||||
* @code
|
||||
* VREF_PDD_WriteStatusControlReg(<peripheral>_BASE_PTR, 1);
|
||||
* @endcode
|
||||
*/
|
||||
#define VREF_PDD_WriteStatusControlReg(PeripheralBase, Value) ( \
|
||||
VREF_SC_REG(PeripheralBase) = \
|
||||
(uint8)(Value) \
|
||||
)
|
||||
#endif /* #if defined(VREF_PDD_H_) */
|
||||
|
||||
/* VREF_PDD.h, eof. */
|
||||
1526
Clean_TMC2209/lib/tmc/hal/Landungsbruecke/freescale/PDD/WDOG_PDD.h
Normal file
1526
Clean_TMC2209/lib/tmc/hal/Landungsbruecke/freescale/PDD/WDOG_PDD.h
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,556 @@
|
||||
/* ###################################################################
|
||||
** THIS COMPONENT MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.
|
||||
** Filename : CDC1.c
|
||||
** Project : Landungsbruecke_KDS_v2.0.0
|
||||
** Processor : MK20DN512VLL10
|
||||
** Component : FSL_USB_CDC_Device
|
||||
** Version : Component 01.031, Driver 01.00, CPU db: 3.00.000
|
||||
** Compiler : GNU C Compiler
|
||||
** Date/Time : 2015-01-09, 16:27, # CodeGen: 0
|
||||
** Abstract :
|
||||
**
|
||||
** Settings :
|
||||
** Component name : CDC1
|
||||
** CPU : Kinetis K20D72
|
||||
** CDC Settings : Enabled
|
||||
** .inf ClassGuid : 4D36E978-E325-11CE-BFC1-08002BE10318
|
||||
** .inf VID : 2504
|
||||
** .inf PID : 0300
|
||||
** .inf PRVDR : Freescale
|
||||
** .inf MFGNAME : My Company
|
||||
** .inf DESCRIPTION : Freescale CDC Device
|
||||
** .inf SERVICE : Virtual Com Driver
|
||||
** Bus reported device : FSL CDC DEVICE
|
||||
** Bus reported vendor : FREESCALE INC.
|
||||
** Send Buffer : RingBuffer
|
||||
** Receive Buffer : RingBuffer
|
||||
** Use Timeout : Disabled
|
||||
** Contents :
|
||||
** ClearRxBuffer - void CDC1_ClearRxBuffer(void);
|
||||
** ClearTxBuffer - void CDC1_ClearTxBuffer(void);
|
||||
** GetFreeInTxBuf - word CDC1_GetFreeInTxBuf(void);
|
||||
** GetCharsInTxBuf - word CDC1_GetCharsInTxBuf(void);
|
||||
** GetCharsInRxBuf - word CDC1_GetCharsInRxBuf(void);
|
||||
** GetChar - byte CDC1_GetChar(CDC1_TComData *Chr);
|
||||
** RecvChar - byte CDC1_RecvChar(CDC1_TComData *Chr);
|
||||
** SendChar - byte CDC1_SendChar(CDC1_TComData Chr);
|
||||
** SendString - byte CDC1_SendString(CDC1_TComData *Chr);
|
||||
** SendBlock - byte CDC1_SendBlock(byte *data, word dataSize);
|
||||
** PutBufferChecked - byte CDC1_PutBufferChecked(byte *buf, size_t bufSize);
|
||||
** App_Callback - void CDC1_App_Callback(byte controller_ID, byte event_type, void *val);
|
||||
** Notify_Callback - void CDC1_Notify_Callback(byte controller_ID, byte event_type, void *val);
|
||||
** App_Task - byte CDC1_App_Task(byte *txBuf, size_t txBufSize);
|
||||
** Init - byte CDC1_Init(void);
|
||||
**
|
||||
** (c) Copyright Freescale, all rights reserved, 2013
|
||||
** Ported as Processor Expert component: Erich Styger
|
||||
** http: www.mcuoneclipse.com
|
||||
** ###################################################################*/
|
||||
/*!
|
||||
** @file CDC1.c
|
||||
** @version 01.00
|
||||
** @brief
|
||||
**
|
||||
*/
|
||||
/*!
|
||||
** @addtogroup CDC1_module CDC1 module documentation
|
||||
** @{
|
||||
*/
|
||||
|
||||
/* MODULE CDC1. */
|
||||
|
||||
#include "CDC1.h"
|
||||
#include "hidef.h" /* for EnableInterrupts; macro */
|
||||
#include "hal/derivative.h" /* include peripheral declarations */
|
||||
#include "usb_cdc.h" /* USB CDC Class Header File */
|
||||
#include <stdio.h>
|
||||
/* skip the inclusion in dependency state */
|
||||
#ifndef __NO_SETJMP
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define CONTROLLER_ID (0) /* ID to identify USB CONTROLLER */
|
||||
|
||||
#if HIGH_SPEED_DEVICE
|
||||
static uint_32 g_cdcBuffer[DIC_BULK_OUT_ENDP_PACKET_SIZE>>1];
|
||||
#endif
|
||||
|
||||
/* Virtual COM Application start Init Flag */
|
||||
static volatile boolean start_app = FALSE;
|
||||
|
||||
/* Virtual COM Application Carrier Activate Flag */
|
||||
static volatile boolean start_transactions = FALSE;
|
||||
|
||||
static volatile boolean transactionOngoing = FALSE;
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_GetFreeInTxBuf (component FSL_USB_CDC_Device)
|
||||
** Description :
|
||||
** Returns the number of free character in the send buffer
|
||||
** Parameters : None
|
||||
** Returns :
|
||||
** --- - Number of free character in the receive
|
||||
** buffer.
|
||||
** ===================================================================
|
||||
*/
|
||||
/*
|
||||
word CDC1_GetFreeInTxBuf(void)
|
||||
{
|
||||
*** Implemented as macro in the header file
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_GetCharsInTxBuf (component FSL_USB_CDC_Device)
|
||||
** Description :
|
||||
** Returns the number of character in the send buffer
|
||||
** Parameters : None
|
||||
** Returns :
|
||||
** --- - Number of character in the receive buffer.
|
||||
** ===================================================================
|
||||
*/
|
||||
/*
|
||||
word CDC1_GetCharsInTxBuf(void)
|
||||
{
|
||||
*** implemented as macro in the header file
|
||||
return (word)Tx1_NofElements();
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_GetCharsInRxBuf (component FSL_USB_CDC_Device)
|
||||
** Description :
|
||||
** Returns the number of character in the receive buffer
|
||||
** Parameters : None
|
||||
** Returns :
|
||||
** --- - Number of character in the receive buffer.
|
||||
** ===================================================================
|
||||
*/
|
||||
word CDC1_GetCharsInRxBuf(void)
|
||||
{
|
||||
static uint8 txBuf[CDC1_DATA_BUFF_SIZE];
|
||||
|
||||
if(CDC1_App_Task(txBuf, sizeof(txBuf))!=ERR_OK) { /* call USB handler: if active, then this will empty the buffer */
|
||||
}
|
||||
return (word)Rx1_NofElements();
|
||||
}
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_GetChar (component FSL_USB_CDC_Device)
|
||||
** Description :
|
||||
** Receives a character from the USB interface. Function is not
|
||||
** blocking if there is no character in the input buffer.
|
||||
** Parameters :
|
||||
** NAME - DESCRIPTION
|
||||
** * Chr - Pointer to where to store the character
|
||||
** received
|
||||
** Returns :
|
||||
** --- - Error code, ERR_OK for success,
|
||||
** ERR_RXEMPTY if nothing is in RX buffer.
|
||||
** ===================================================================
|
||||
*/
|
||||
/**
|
||||
byte CDC1_GetChar(CDC1_TComData *Chr)
|
||||
{
|
||||
*** implemented as macro in the header file
|
||||
return Rx1_Get(Chr);
|
||||
}
|
||||
*/
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_RecvChar (component FSL_USB_CDC_Device)
|
||||
** Description :
|
||||
** Receives a character from the USB interface. Function is
|
||||
** blocking if there is no character in the input buffer.
|
||||
** Parameters :
|
||||
** NAME - DESCRIPTION
|
||||
** * Chr - Pointer to where to store the character
|
||||
** received
|
||||
** Returns :
|
||||
** --- - Error code, ERR_OK for success,
|
||||
** ERR_RXEMPTY if nothing is in RX buffer.
|
||||
** ===================================================================
|
||||
*/
|
||||
byte CDC1_RecvChar(CDC1_TComData *Chr)
|
||||
{
|
||||
while(Rx1_Get(Chr)!=ERR_OK) {
|
||||
/* retry receiving until success */
|
||||
}
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_SendChar (component FSL_USB_CDC_Device)
|
||||
** Description :
|
||||
** Method to send a character to the USB interface. Method is
|
||||
** non-blocking: If the output buffer is full, it tries to send
|
||||
** it over USB. If this fails or buffer is still full, the
|
||||
** character will be lost. If OnError() event is enabled, the
|
||||
** error event will be called in case of error.
|
||||
** Parameters :
|
||||
** NAME - DESCRIPTION
|
||||
** Chr - Character to send.
|
||||
** Returns :
|
||||
** --- - Error code. ERR_OK for success and
|
||||
** ERR_FAILED otherwise.
|
||||
** ===================================================================
|
||||
*/
|
||||
byte CDC1_SendChar(CDC1_TComData Chr)
|
||||
{
|
||||
static uint8 txBuf[CDC1_DATA_BUFF_SIZE];
|
||||
|
||||
if(Tx1_Put(Chr)==ERR_TXFULL) { /* retry once, otherwise throw it away */
|
||||
if(CDC1_App_Task(txBuf, sizeof(txBuf))!=ERR_OK) { /* call USB handler: if active, then this will empty the buffer */
|
||||
return ERR_TXFULL;
|
||||
} else { /* retry, as USB App_Task() should have sent the buffer */
|
||||
return Tx1_Put(Chr); /* retry. If buffer is still full, we will lose the character */
|
||||
}
|
||||
}
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_SendBlock (component FSL_USB_CDC_Device)
|
||||
** Description :
|
||||
** Method to send a data block to the USB interface. Method is
|
||||
** non-blocking: if data cannot be sent, it will be lost. If
|
||||
** OnError() event is enabled, the error event will be called
|
||||
** in case of error.
|
||||
** Parameters :
|
||||
** NAME - DESCRIPTION
|
||||
** * data - Pointer to data to send.
|
||||
** dataSize - Size of data in bytes
|
||||
** Returns :
|
||||
** --- - Error code. ERR_OK for success and
|
||||
** ERR_FAILED otherwise.
|
||||
** ===================================================================
|
||||
*/
|
||||
byte CDC1_SendBlock(byte *data, word dataSize)
|
||||
{
|
||||
byte res = ERR_OK;
|
||||
|
||||
while(dataSize > 0) {
|
||||
if(CDC1_SendChar(*data)!=ERR_OK) {
|
||||
res = ERR_TXFULL;
|
||||
}
|
||||
dataSize--; data++;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_SendString (component FSL_USB_CDC_Device)
|
||||
** Description :
|
||||
** Method to send a string to the USB interface. Method is
|
||||
** non-blocking: if string cannot be sent, it will be lost. If
|
||||
** OnError() event is enabled, the error event will be called
|
||||
** in case of error.
|
||||
** Parameters :
|
||||
** NAME - DESCRIPTION
|
||||
** * Chr - Pointer to string to send.
|
||||
** Returns :
|
||||
** --- - Error code. ERR_OK for success and
|
||||
** ERR_FAILED otherwise.
|
||||
** ===================================================================
|
||||
*/
|
||||
byte CDC1_SendString(CDC1_TComData *Chr)
|
||||
{
|
||||
byte res = ERR_OK;
|
||||
|
||||
while(*Chr != '\0') {
|
||||
if(CDC1_SendChar(*Chr)!=ERR_OK) {
|
||||
res = ERR_TXFULL;
|
||||
}
|
||||
Chr++;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_App_Callback (component FSL_USB_CDC_Device)
|
||||
** Description :
|
||||
** Method to handle class callbacks from USB
|
||||
** Parameters :
|
||||
** NAME - DESCRIPTION
|
||||
** controller_ID - controller ID
|
||||
** event_type - value of the event
|
||||
** val - gives the configuration value
|
||||
** Returns : Nothing
|
||||
** ===================================================================
|
||||
*/
|
||||
void CDC1_App_Callback(byte controller_ID, byte event_type, void *val)
|
||||
{
|
||||
UNUSED(controller_ID);
|
||||
UNUSED(val);
|
||||
if(event_type == USB_APP_BUS_RESET) {
|
||||
start_app = FALSE;
|
||||
} else if(event_type == USB_APP_ENUM_COMPLETE) {
|
||||
#if HIGH_SPEED_DEVICE
|
||||
/* prepare for the next receive event */
|
||||
USB_Class_CDC_Interface_DIC_Recv_Data(&controller_ID,
|
||||
(uint_8_ptr)g_cdcBuffer,
|
||||
DIC_BULK_OUT_ENDP_PACKET_SIZE);
|
||||
#endif
|
||||
start_app = TRUE;
|
||||
} else if((event_type == USB_APP_DATA_RECEIVED)&&(start_transactions==TRUE)) {
|
||||
/* Copy Received Data buffer to Application Buffer */
|
||||
USB_PACKET_SIZE BytesToBeCopied;
|
||||
APP_DATA_STRUCT *dp_rcv = (APP_DATA_STRUCT*)val;
|
||||
uint_8 index;
|
||||
|
||||
BytesToBeCopied = (USB_PACKET_SIZE)((dp_rcv->data_size > CDC1_DATA_BUFF_SIZE) ? CDC1_DATA_BUFF_SIZE:dp_rcv->data_size);
|
||||
for(index = 0; index<BytesToBeCopied ; index++) {
|
||||
if(Rx1_Put(dp_rcv->data_ptr[index])!=ERR_OK) {
|
||||
/* Failed to put byte into buffer. Is the buffer to small? Then increase the Rx buffer.
|
||||
Otherwise not much we could do here, so we are loosing byte here.
|
||||
*/
|
||||
/* Enable OnError() event so this event will be called here */
|
||||
}
|
||||
}
|
||||
(void)USB_Class_CDC_Interface_DIC_Recv_Data(CONTROLLER_ID, NULL, 0); /* see http://eprints.utar.edu.my/143/1/BI-2011-0708672-1.pdf, page 131 */
|
||||
} else if((event_type == USB_APP_SEND_COMPLETE)&&(start_transactions==TRUE)) {
|
||||
transactionOngoing = FALSE;
|
||||
/* Previous Send is complete. Queue next receive */
|
||||
#if HIGH_SPEED_DEVICE
|
||||
//(void)USB_Class_CDC_Interface_DIC_Recv_Data(CONTROLLER_ID, g_cdcBuffer, 0);
|
||||
#else
|
||||
(void)USB_Class_CDC_Interface_DIC_Recv_Data(CONTROLLER_ID, NULL, 0);
|
||||
#endif
|
||||
} else if(event_type == USB_APP_ERROR) { /* detach? */
|
||||
start_app = FALSE;
|
||||
start_transactions = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_Notify_Callback (component FSL_USB_CDC_Device)
|
||||
** Description :
|
||||
** Method to handle PSTN Sub Class callbacks
|
||||
** Parameters :
|
||||
** NAME - DESCRIPTION
|
||||
** controller_ID - controller ID
|
||||
** event_type - value of the event
|
||||
** val -
|
||||
** Returns : Nothing
|
||||
** ===================================================================
|
||||
*/
|
||||
void CDC1_Notify_Callback(byte controller_ID, byte event_type, void *val)
|
||||
{
|
||||
UNUSED(controller_ID);
|
||||
UNUSED(val);
|
||||
if(start_app == TRUE) {
|
||||
if(event_type == USB_APP_CDC_CARRIER_ACTIVATED) {
|
||||
start_transactions = TRUE;
|
||||
} else if(event_type == USB_APP_CDC_CARRIER_DEACTIVATED) {
|
||||
start_transactions = FALSE;
|
||||
}
|
||||
}
|
||||
start_transactions = TRUE; /* ??? see http://forums.freescale.com/t5/Freescale-MQX-trade-USB-Host/Cant-get-CDC-virtual-com-demo-to-work-with-VB2005-on-xp-sp3/m-p/92713#M302 */
|
||||
}
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_RunUsbEngine (component FSL_USB_CDC_Device)
|
||||
**
|
||||
** Description :
|
||||
** Runs the USB polling engine
|
||||
** This method is internal. It is used by Processor Expert only.
|
||||
** ===================================================================
|
||||
*/
|
||||
void CDC1_RunUsbEngine(void)
|
||||
{
|
||||
/* not needed */
|
||||
}
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_SendDataBlock (component FSL_USB_CDC_Device)
|
||||
**
|
||||
** Description :
|
||||
** Sends a USB data block
|
||||
** This method is internal. It is used by Processor Expert only.
|
||||
** ===================================================================
|
||||
*/
|
||||
byte CDC1_SendDataBlock(byte *data, word dataSize)
|
||||
{
|
||||
uint8 res = ERR_OK;
|
||||
|
||||
transactionOngoing = TRUE;
|
||||
if(USB_Class_CDC_Interface_DIC_Send_Data(CONTROLLER_ID, data, dataSize)!=USB_OK) {
|
||||
transactionOngoing = FALSE;
|
||||
return ERR_FAULT;
|
||||
}
|
||||
/* wait for transaction finish */
|
||||
while(transactionOngoing) { /* wait until transaction is finished */
|
||||
CDC1_RunUsbEngine();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_App_Task (component FSL_USB_CDC_Device)
|
||||
** Description :
|
||||
** Application task to be called periodically from the main
|
||||
** task.
|
||||
** Parameters :
|
||||
** NAME - DESCRIPTION
|
||||
** * txBuf - Pointer to temporary buffer used to
|
||||
** transmit data over USB. Should be equal or
|
||||
** greater than the endpoint buffer size. Data
|
||||
** will be sent in an asynchronous way, so
|
||||
** make sure the buffer is *not* on the stack.
|
||||
** This buffer must be available until the
|
||||
** next transmission.
|
||||
** txBufSize - Size of the buffer in bytes
|
||||
** Returns :
|
||||
** --- - Error code, returns ERR_OK if USB
|
||||
** enumeration has been finished, error code
|
||||
** otherwise.
|
||||
** ===================================================================
|
||||
*/
|
||||
byte CDC1_App_Task(byte *txBuf, size_t txBufSize)
|
||||
{
|
||||
uint8 i, res;
|
||||
|
||||
/* device is Kinetis K20D72 */
|
||||
CDC1_RunUsbEngine();
|
||||
/* call the periodic task function */
|
||||
USB_Class_CDC_Periodic_Task();
|
||||
/* check whether enumeration is complete or not */
|
||||
if((start_app==TRUE) && (start_transactions==TRUE)) {
|
||||
if(Tx1_NofElements()!=0) {
|
||||
i = 0;
|
||||
while(i<txBufSize && Tx1_Get(&txBuf[i])==ERR_OK) {
|
||||
i++;
|
||||
}
|
||||
res = CDC1_SendDataBlock(txBuf, i);
|
||||
if(res!=ERR_OK) {
|
||||
return res;
|
||||
}
|
||||
#if 0 /* workaround for problem in USB stack v3.1.1: if last block is 8, 16, 32, 40, 48, ... bytes, it does not get out until the next transfer? */
|
||||
if((i%8)==0) {
|
||||
/* workaround: sending a dummy block of zero bytes */
|
||||
res = CDC1_SendDataBlock(txBuf, 0);
|
||||
if(res!=ERR_OK) {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
} /* if */
|
||||
return ERR_OK;
|
||||
} else {
|
||||
return ERR_BUSOFF; /* USB bus not available yet */
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_Init (component FSL_USB_CDC_Device)
|
||||
** Description :
|
||||
** Initializes the driver
|
||||
** Parameters : None
|
||||
** Returns :
|
||||
** --- - Error code
|
||||
** ===================================================================
|
||||
*/
|
||||
byte CDC1_Init(void)
|
||||
{
|
||||
uint_8 err;
|
||||
|
||||
err = USB_Class_CDC_Init(CONTROLLER_ID, CDC1_App_Callback, NULL, CDC1_Notify_Callback, TRUE);
|
||||
if(err != USB_OK) {
|
||||
/* Error initializing USB-CDC Class */
|
||||
return ERR_FAILED;
|
||||
}
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_PutBufferChecked (component FSL_USB_CDC_Device)
|
||||
** Description :
|
||||
** Puts a data block into the output buffer, but does not send
|
||||
** it. If there is not enough size available, then ERR_TXFULL
|
||||
** is returned, otherwise ERR_OK. The application then needs to
|
||||
** call USB_App_Callback() to actually send the buffer.
|
||||
** Parameters :
|
||||
** NAME - DESCRIPTION
|
||||
** * buf - Pointer to buffer to be sent
|
||||
** bufsize - Buffer size in bytes
|
||||
** Returns :
|
||||
** --- - Error code
|
||||
** ===================================================================
|
||||
*/
|
||||
byte CDC1_PutBufferChecked(byte *buf, size_t bufSize)
|
||||
{
|
||||
byte res;
|
||||
|
||||
if(bufSize>CDC1_GetFreeInTxBuf()) { /* no room at the Inn... */
|
||||
res = ERR_TXFULL;
|
||||
} else {
|
||||
res = ERR_OK;
|
||||
while(bufSize>0 && res==ERR_OK) {
|
||||
res = Tx1_Put(*buf);
|
||||
bufSize--;
|
||||
buf++;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_ClearRxBuffer (component FSL_USB_CDC_Device)
|
||||
** Description :
|
||||
** Clears the receiver buffer content
|
||||
** Parameters : None
|
||||
** Returns : Nothing
|
||||
** ===================================================================
|
||||
*/
|
||||
/**
|
||||
void CDC1_ClearRxBuffer(void)
|
||||
{
|
||||
Implemented as macro in the header file
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_ClearTxBuffer (component FSL_USB_CDC_Device)
|
||||
** Description :
|
||||
** Clears the transmit buffer content
|
||||
** Parameters : None
|
||||
** Returns : Nothing
|
||||
** ===================================================================
|
||||
*/
|
||||
/**
|
||||
void CDC1_ClearTxBuffer(void)
|
||||
{
|
||||
Implemented as macro in the header file
|
||||
}
|
||||
*/
|
||||
|
||||
/* END CDC1. */
|
||||
|
||||
/*!
|
||||
** @}
|
||||
*/
|
||||
/*
|
||||
** ###################################################################
|
||||
**
|
||||
** This file was created by Processor Expert 10.4 [05.11]
|
||||
** for the Freescale Kinetis series of microcontrollers.
|
||||
**
|
||||
** ###################################################################
|
||||
*/
|
||||
@@ -0,0 +1,379 @@
|
||||
/* ###################################################################
|
||||
** THIS COMPONENT MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.
|
||||
** Filename : CDC1.h
|
||||
** Project : Landungsbruecke_KDS_v2.0.0
|
||||
** Processor : MK20DN512VLL10
|
||||
** Component : FSL_USB_CDC_Device
|
||||
** Version : Component 01.031, Driver 01.00, CPU db: 3.00.000
|
||||
** Compiler : GNU C Compiler
|
||||
** Date/Time : 2015-01-09, 16:27, # CodeGen: 0
|
||||
** Abstract :
|
||||
**
|
||||
** Settings :
|
||||
** Component name : CDC1
|
||||
** CPU : Kinetis K20D72
|
||||
** CDC Settings : Enabled
|
||||
** .inf ClassGuid : 4D36E978-E325-11CE-BFC1-08002BE10318
|
||||
** .inf VID : 2504
|
||||
** .inf PID : 0300
|
||||
** .inf PRVDR : Freescale
|
||||
** .inf MFGNAME : My Company
|
||||
** .inf DESCRIPTION : Freescale CDC Device
|
||||
** .inf SERVICE : Virtual Com Driver
|
||||
** Bus reported device : FSL CDC DEVICE
|
||||
** Bus reported vendor : FREESCALE INC.
|
||||
** Send Buffer : RingBuffer
|
||||
** Receive Buffer : RingBuffer
|
||||
** Use Timeout : Disabled
|
||||
** Contents :
|
||||
** ClearRxBuffer - void CDC1_ClearRxBuffer(void);
|
||||
** ClearTxBuffer - void CDC1_ClearTxBuffer(void);
|
||||
** GetFreeInTxBuf - word CDC1_GetFreeInTxBuf(void);
|
||||
** GetCharsInTxBuf - word CDC1_GetCharsInTxBuf(void);
|
||||
** GetCharsInRxBuf - word CDC1_GetCharsInRxBuf(void);
|
||||
** GetChar - byte CDC1_GetChar(CDC1_TComData *Chr);
|
||||
** RecvChar - byte CDC1_RecvChar(CDC1_TComData *Chr);
|
||||
** SendChar - byte CDC1_SendChar(CDC1_TComData Chr);
|
||||
** SendString - byte CDC1_SendString(CDC1_TComData *Chr);
|
||||
** SendBlock - byte CDC1_SendBlock(byte *data, word dataSize);
|
||||
** PutBufferChecked - byte CDC1_PutBufferChecked(byte *buf, size_t bufSize);
|
||||
** App_Callback - void CDC1_App_Callback(byte controller_ID, byte event_type, void *val);
|
||||
** Notify_Callback - void CDC1_Notify_Callback(byte controller_ID, byte event_type, void *val);
|
||||
** App_Task - byte CDC1_App_Task(byte *txBuf, size_t txBufSize);
|
||||
** Init - byte CDC1_Init(void);
|
||||
**
|
||||
** (c) Copyright Freescale, all rights reserved, 2013
|
||||
** Ported as Processor Expert component: Erich Styger
|
||||
** http: www.mcuoneclipse.com
|
||||
** ###################################################################*/
|
||||
/*!
|
||||
** @file CDC1.h
|
||||
** @version 01.00
|
||||
** @brief
|
||||
**
|
||||
*/
|
||||
/*!
|
||||
** @addtogroup CDC1_module CDC1 module documentation
|
||||
** @{
|
||||
*/
|
||||
|
||||
#ifndef __CDC1_H
|
||||
#define __CDC1_H
|
||||
|
||||
/* MODULE CDC1. */
|
||||
|
||||
/* Include shared modules, which are used for whole project */
|
||||
|
||||
#include "PE_Types.h"
|
||||
#include "PE_Error.h"
|
||||
#include "PE_Const.h"
|
||||
#include "MK20D10.h"
|
||||
#include "MK20D10.h"
|
||||
/* Include inherited beans */
|
||||
#include "Tx1.h"
|
||||
#include "Rx1.h"
|
||||
#include <stddef.h> /* for size_t */
|
||||
|
||||
//#include "Cpu.h"
|
||||
|
||||
|
||||
#ifndef __BWUserType_CDC1_TComData
|
||||
#define __BWUserType_CDC1_TComData
|
||||
typedef byte CDC1_TComData ; /* User type for communication data type. */
|
||||
#endif
|
||||
|
||||
/*
|
||||
DATA_BUFF_SIZE should be greater than or equal to the endpoint buffer size,
|
||||
otherwise there will be data loss. For MC9S08JS16, maximum DATA_BUFF_SIZE
|
||||
supported is 16 Bytes
|
||||
*/
|
||||
#define CDC1_DATA_BUFF_SIZE 64
|
||||
|
||||
#define CDC1_USB_ERR_SEND 1 /* Error while sending */
|
||||
#define CDC1_USB_ERR_BUSOFF 2 /* Bus not ready */
|
||||
#define CDC1_USB_ERR_INIT 3 /* USB initialization error */
|
||||
#define CDC1_USB_ERR_TX_CHAR 4 /* Error sending character */
|
||||
#define CDC1_USB_ERR_TX_STRING 5 /* Error sending string */
|
||||
#define CDC1_USB_ERR_CHECKED_TXFULL 6 /* Error during sending a checked block */
|
||||
#define CDC1_USB_ERR_RECEIVE 7 /* Error while starting an receive transaction */
|
||||
#define CDC1_USB_ERR_RX_PUT 8 /* Error while putting RX byte into buffer */
|
||||
#define CDC1_USB_ERR_TX_BLOCK 9 /* Error sending data block */
|
||||
#define CDC1_USB_TIMEOUT_SEND 10 /* Timeout while sending */
|
||||
|
||||
|
||||
#define CDC1_GetFreeInTxBuf() \
|
||||
Tx1_NofFreeElements()
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_GetFreeInTxBuf (component FSL_USB_CDC_Device)
|
||||
** Description :
|
||||
** Returns the number of free character in the send buffer
|
||||
** Parameters : None
|
||||
** Returns :
|
||||
** --- - Number of free character in the receive
|
||||
** buffer.
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
byte CDC1_RecvChar(CDC1_TComData *Chr);
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_RecvChar (component FSL_USB_CDC_Device)
|
||||
** Description :
|
||||
** Receives a character from the USB interface. Function is
|
||||
** blocking if there is no character in the input buffer.
|
||||
** Parameters :
|
||||
** NAME - DESCRIPTION
|
||||
** * Chr - Pointer to where to store the character
|
||||
** received
|
||||
** Returns :
|
||||
** --- - Error code, ERR_OK for success,
|
||||
** ERR_RXEMPTY if nothing is in RX buffer.
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
byte CDC1_SendChar(CDC1_TComData Chr);
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_SendChar (component FSL_USB_CDC_Device)
|
||||
** Description :
|
||||
** Method to send a character to the USB interface. Method is
|
||||
** non-blocking: If the output buffer is full, it tries to send
|
||||
** it over USB. If this fails or buffer is still full, the
|
||||
** character will be lost. If OnError() event is enabled, the
|
||||
** error event will be called in case of error.
|
||||
** Parameters :
|
||||
** NAME - DESCRIPTION
|
||||
** Chr - Character to send.
|
||||
** Returns :
|
||||
** --- - Error code. ERR_OK for success and
|
||||
** ERR_FAILED otherwise.
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
#define CDC1_GetCharsInTxBuf() \
|
||||
Tx1_NofElements()
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_GetCharsInTxBuf (component FSL_USB_CDC_Device)
|
||||
** Description :
|
||||
** Returns the number of character in the send buffer
|
||||
** Parameters : None
|
||||
** Returns :
|
||||
** --- - Number of character in the receive buffer.
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
word CDC1_GetCharsInRxBuf(void);
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_GetCharsInRxBuf (component FSL_USB_CDC_Device)
|
||||
** Description :
|
||||
** Returns the number of character in the receive buffer
|
||||
** Parameters : None
|
||||
** Returns :
|
||||
** --- - Number of character in the receive buffer.
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
byte CDC1_Init(void);
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_Init (component FSL_USB_CDC_Device)
|
||||
** Description :
|
||||
** Initializes the driver
|
||||
** Parameters : None
|
||||
** Returns :
|
||||
** --- - Error code
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
byte CDC1_App_Task(byte *txBuf, size_t txBufSize);
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_App_Task (component FSL_USB_CDC_Device)
|
||||
** Description :
|
||||
** Application task to be called periodically from the main
|
||||
** task.
|
||||
** Parameters :
|
||||
** NAME - DESCRIPTION
|
||||
** * txBuf - Pointer to temporary buffer used to
|
||||
** transmit data over USB. Should be equal or
|
||||
** greater than the endpoint buffer size. Data
|
||||
** will be sent in an asynchronous way, so
|
||||
** make sure the buffer is *not* on the stack.
|
||||
** This buffer must be available until the
|
||||
** next transmission.
|
||||
** txBufSize - Size of the buffer in bytes
|
||||
** Returns :
|
||||
** --- - Error code, returns ERR_OK if USB
|
||||
** enumeration has been finished, error code
|
||||
** otherwise.
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
byte CDC1_SendString(CDC1_TComData *Chr);
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_SendString (component FSL_USB_CDC_Device)
|
||||
** Description :
|
||||
** Method to send a string to the USB interface. Method is
|
||||
** non-blocking: if string cannot be sent, it will be lost. If
|
||||
** OnError() event is enabled, the error event will be called
|
||||
** in case of error.
|
||||
** Parameters :
|
||||
** NAME - DESCRIPTION
|
||||
** * Chr - Pointer to string to send.
|
||||
** Returns :
|
||||
** --- - Error code. ERR_OK for success and
|
||||
** ERR_FAILED otherwise.
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
#define CDC1_GetChar(Chr) \
|
||||
Rx1_Get(Chr)
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_GetChar (component FSL_USB_CDC_Device)
|
||||
** Description :
|
||||
** Receives a character from the USB interface. Function is not
|
||||
** blocking if there is no character in the input buffer.
|
||||
** Parameters :
|
||||
** NAME - DESCRIPTION
|
||||
** * Chr - Pointer to where to store the character
|
||||
** received
|
||||
** Returns :
|
||||
** --- - Error code, ERR_OK for success,
|
||||
** ERR_RXEMPTY if nothing is in RX buffer.
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
byte CDC1_PutBufferChecked(byte *buf, size_t bufSize);
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_PutBufferChecked (component FSL_USB_CDC_Device)
|
||||
** Description :
|
||||
** Puts a data block into the output buffer, but does not send
|
||||
** it. If there is not enough size available, then ERR_TXFULL
|
||||
** is returned, otherwise ERR_OK. The application then needs to
|
||||
** call USB_App_Callback() to actually send the buffer.
|
||||
** Parameters :
|
||||
** NAME - DESCRIPTION
|
||||
** * buf - Pointer to buffer to be sent
|
||||
** bufsize - Buffer size in bytes
|
||||
** Returns :
|
||||
** --- - Error code
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
void CDC1_App_Callback(byte controller_ID, byte event_type, void *val);
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_App_Callback (component FSL_USB_CDC_Device)
|
||||
** Description :
|
||||
** Method to handle class callbacks from USB
|
||||
** Parameters :
|
||||
** NAME - DESCRIPTION
|
||||
** controller_ID - controller ID
|
||||
** event_type - value of the event
|
||||
** val - gives the configuration value
|
||||
** Returns : Nothing
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
void CDC1_Notify_Callback(byte controller_ID, byte event_type, void *val);
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_Notify_Callback (component FSL_USB_CDC_Device)
|
||||
** Description :
|
||||
** Method to handle PSTN Sub Class callbacks
|
||||
** Parameters :
|
||||
** NAME - DESCRIPTION
|
||||
** controller_ID - controller ID
|
||||
** event_type - value of the event
|
||||
** val -
|
||||
** Returns : Nothing
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
#define CDC1_ClearRxBuffer() \
|
||||
Rx1_Clear()
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_ClearRxBuffer (component FSL_USB_CDC_Device)
|
||||
** Description :
|
||||
** Clears the receiver buffer content
|
||||
** Parameters : None
|
||||
** Returns : Nothing
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
#define CDC1_ClearTxBuffer() \
|
||||
Tx1_Clear()
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_ClearTxBuffer (component FSL_USB_CDC_Device)
|
||||
** Description :
|
||||
** Clears the transmit buffer content
|
||||
** Parameters : None
|
||||
** Returns : Nothing
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
void CDC1_RunUsbEngine(void);
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_RunUsbEngine (component FSL_USB_CDC_Device)
|
||||
**
|
||||
** Description :
|
||||
** Runs the USB polling engine
|
||||
** This method is internal. It is used by Processor Expert only.
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
byte CDC1_SendBlock(byte *data, word dataSize);
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_SendBlock (component FSL_USB_CDC_Device)
|
||||
** Description :
|
||||
** Method to send a data block to the USB interface. Method is
|
||||
** non-blocking: if data cannot be sent, it will be lost. If
|
||||
** OnError() event is enabled, the error event will be called
|
||||
** in case of error.
|
||||
** Parameters :
|
||||
** NAME - DESCRIPTION
|
||||
** * data - Pointer to data to send.
|
||||
** dataSize - Size of data in bytes
|
||||
** Returns :
|
||||
** --- - Error code. ERR_OK for success and
|
||||
** ERR_FAILED otherwise.
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
byte CDC1_SendDataBlock(byte *data, word dataSize);
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CDC1_SendDataBlock (component FSL_USB_CDC_Device)
|
||||
**
|
||||
** Description :
|
||||
** Sends a USB data block
|
||||
** This method is internal. It is used by Processor Expert only.
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
/* END CDC1. */
|
||||
|
||||
#endif
|
||||
/* ifndef __CDC1_H */
|
||||
/*!
|
||||
** @}
|
||||
*/
|
||||
/*
|
||||
** ###################################################################
|
||||
**
|
||||
** This file was created by Processor Expert 10.4 [05.11]
|
||||
** for the Freescale Kinetis series of microcontrollers.
|
||||
**
|
||||
** ###################################################################
|
||||
*/
|
||||
@@ -0,0 +1,103 @@
|
||||
/* ###################################################################
|
||||
** THIS COMPONENT MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.
|
||||
** Filename : CS1.c
|
||||
** Project : Landungsbruecke_KDS_v2.0.0
|
||||
** Processor : MK20DN512VLL10
|
||||
** Component : CriticalSection
|
||||
** Version : Component 01.006, Driver 01.00, CPU db: 3.00.000
|
||||
** Compiler : GNU C Compiler
|
||||
** Date/Time : 2015-01-09, 16:27, # CodeGen: 0
|
||||
** Abstract :
|
||||
**
|
||||
** Settings :
|
||||
**
|
||||
** Contents :
|
||||
** CriticalVariable - void CS1_CriticalVariable(void);
|
||||
** EnterCritical - void CS1_EnterCritical(void);
|
||||
** ExitCritical - void CS1_ExitCritical(void);
|
||||
**
|
||||
** License : Open Source (LGPL)
|
||||
** Copyright : Erich Styger, 2014, all rights reserved.
|
||||
** Web : www.mcuoneclipse.com
|
||||
** This an open source software implementing a driver using Processor Expert.
|
||||
** This is a free software and is opened for education, research and commercial developments under license policy of following terms:
|
||||
** * This is a free software and there is NO WARRANTY.
|
||||
** * No restriction on use. You can use, modify and redistribute it for personal, non-profit or commercial product UNDER YOUR RESPONSIBILITY.
|
||||
** * Redistributions of source code must retain the above copyright notice.
|
||||
** ###################################################################*/
|
||||
/*!
|
||||
** @file CS1.c
|
||||
** @version 01.00
|
||||
** @brief
|
||||
**
|
||||
*/
|
||||
/*!
|
||||
** @addtogroup CS1_module CS1 module documentation
|
||||
** @{
|
||||
*/
|
||||
|
||||
/* MODULE CS1. */
|
||||
|
||||
#include "CS1.h"
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CS1_CriticalVariable (component CriticalSection)
|
||||
** Description :
|
||||
** Defines a variable if necessary. This is a macro.
|
||||
** Parameters : None
|
||||
** Returns : Nothing
|
||||
** ===================================================================
|
||||
*/
|
||||
/*
|
||||
void CS1_CriticalVariable(void)
|
||||
{
|
||||
*** Implemented as macro in the header file CS1.h
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CS1_EnterCritical (component CriticalSection)
|
||||
** Description :
|
||||
** Enters a critical section
|
||||
** Parameters : None
|
||||
** Returns : Nothing
|
||||
** ===================================================================
|
||||
*/
|
||||
/*
|
||||
void CS1_EnterCritical(void)
|
||||
{
|
||||
*** Implemented as macro in the header file CS1.h
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CS1_ExitCritical (component CriticalSection)
|
||||
** Description :
|
||||
** Exits a critical section
|
||||
** Parameters : None
|
||||
** Returns : Nothing
|
||||
** ===================================================================
|
||||
*/
|
||||
/*
|
||||
void CS1_ExitCritical(void)
|
||||
{
|
||||
*** Implemented as macro in the header file CS1.h
|
||||
}
|
||||
*/
|
||||
|
||||
/* END CS1. */
|
||||
|
||||
/*!
|
||||
** @}
|
||||
*/
|
||||
/*
|
||||
** ###################################################################
|
||||
**
|
||||
** This file was created by Processor Expert 10.4 [05.11]
|
||||
** for the Freescale Kinetis series of microcontrollers.
|
||||
**
|
||||
** ###################################################################
|
||||
*/
|
||||
@@ -0,0 +1,126 @@
|
||||
/* ###################################################################
|
||||
** THIS COMPONENT MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.
|
||||
** Filename : CS1.h
|
||||
** Project : Landungsbruecke_KDS_v2.0.0
|
||||
** Processor : MK20DN512VLL10
|
||||
** Component : CriticalSection
|
||||
** Version : Component 01.006, Driver 01.00, CPU db: 3.00.000
|
||||
** Compiler : GNU C Compiler
|
||||
** Date/Time : 2015-01-09, 16:27, # CodeGen: 0
|
||||
** Abstract :
|
||||
**
|
||||
** Settings :
|
||||
**
|
||||
** Contents :
|
||||
** CriticalVariable - void CS1_CriticalVariable(void);
|
||||
** EnterCritical - void CS1_EnterCritical(void);
|
||||
** ExitCritical - void CS1_ExitCritical(void);
|
||||
**
|
||||
** License : Open Source (LGPL)
|
||||
** Copyright : Erich Styger, 2014, all rights reserved.
|
||||
** Web : www.mcuoneclipse.com
|
||||
** This an open source software implementing a driver using Processor Expert.
|
||||
** This is a free software and is opened for education, research and commercial developments under license policy of following terms:
|
||||
** * This is a free software and there is NO WARRANTY.
|
||||
** * No restriction on use. You can use, modify and redistribute it for personal, non-profit or commercial product UNDER YOUR RESPONSIBILITY.
|
||||
** * Redistributions of source code must retain the above copyright notice.
|
||||
** ###################################################################*/
|
||||
/*!
|
||||
** @file CS1.h
|
||||
** @version 01.00
|
||||
** @brief
|
||||
**
|
||||
*/
|
||||
/*!
|
||||
** @addtogroup CS1_module CS1 module documentation
|
||||
** @{
|
||||
*/
|
||||
|
||||
#ifndef __CS1_H
|
||||
#define __CS1_H
|
||||
|
||||
/* MODULE CS1. */
|
||||
|
||||
/* Include shared modules, which are used for whole project */
|
||||
#include "PE_Types.h"
|
||||
#include "PE_Error.h"
|
||||
#include "PE_Const.h"
|
||||
#include "MK20D10.h"
|
||||
/* Include inherited beans */
|
||||
|
||||
//#include "Cpu.h"
|
||||
|
||||
|
||||
/* workaround macros for wrong EnterCritical()/ExitCritical() in the low level drivers. Will be removed once PEx is fixed */
|
||||
#define CS1_CriticalVariableDrv() \
|
||||
CS1_CriticalVariable()
|
||||
#define CS1_EnterCriticalDrv() \
|
||||
CS1_EnterCritical()
|
||||
#define CS1_ExitCriticalDrv() \
|
||||
CS1_ExitCritical()
|
||||
|
||||
#define CS1_CriticalVariable() \
|
||||
uint8 cpuSR; /* variable to store current status */
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CS1_CriticalVariable (component CriticalSection)
|
||||
** Description :
|
||||
** Defines a variable if necessary. This is a macro.
|
||||
** Parameters : None
|
||||
** Returns : Nothing
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
#define CS1_EnterCritical() \
|
||||
do { \
|
||||
asm ( \
|
||||
"MRS R0, PRIMASK\n\t" \
|
||||
"CPSID I\n\t" \
|
||||
"STRB R0, %[output]" \
|
||||
: [output] "=m" (cpuSR) :: "r0"); \
|
||||
} while(0)
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CS1_EnterCritical (component CriticalSection)
|
||||
** Description :
|
||||
** Enters a critical section
|
||||
** Parameters : None
|
||||
** Returns : Nothing
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
#define CS1_ExitCritical() \
|
||||
do{ \
|
||||
asm ( \
|
||||
"ldrb r0, %[input]\n\t" \
|
||||
"msr PRIMASK,r0;\n\t" \
|
||||
::[input] "m" (cpuSR) : "r0"); \
|
||||
} while(0)
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : CS1_ExitCritical (component CriticalSection)
|
||||
** Description :
|
||||
** Exits a critical section
|
||||
** Parameters : None
|
||||
** Returns : Nothing
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
/* END CS1. */
|
||||
|
||||
#endif
|
||||
/* ifndef __CS1_H */
|
||||
/*!
|
||||
** @}
|
||||
*/
|
||||
/*
|
||||
** ###################################################################
|
||||
**
|
||||
** This file was created by Processor Expert 10.4 [05.11]
|
||||
** for the Freescale Kinetis series of microcontrollers.
|
||||
**
|
||||
** ###################################################################
|
||||
*/
|
||||
@@ -0,0 +1,12 @@
|
||||
/******************************************************************************
|
||||
* Configuration file for the FSL USB stack created with Processor Expert.
|
||||
*****************************************************************************/
|
||||
#ifndef __FSL_USB_STACK_CONFIG_
|
||||
#define __FSL_USB_STACK_CONFIG_
|
||||
|
||||
/* Overwrite initialization values from Processor Expert Init() component. These are 'known working values'.
|
||||
* Otherwise you have to setup the bits (e.g. Pull-up/pull-down resistors!
|
||||
* */
|
||||
#define USB_USER_CONFIG_USE_STACK_INIT 1 /* value set by component property 'Use USB Stack Initialization' */
|
||||
|
||||
#endif /* __FSL_USB_STACK_CONFIG_ */
|
||||
@@ -0,0 +1,96 @@
|
||||
/* ###################################################################
|
||||
** THIS COMPONENT MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.
|
||||
** Filename : PE_Const.h
|
||||
** Project : Landungsbruecke_KDS_v2.0.0
|
||||
** Processor : MK20DN512VLL10
|
||||
** Component : PE_Const
|
||||
** Version : Driver 01.00
|
||||
** Compiler : GNU C Compiler
|
||||
** Date/Time : 2015-01-09, 16:27, # CodeGen: 0
|
||||
** Abstract :
|
||||
** This component "PE_Const" contains internal definitions
|
||||
** of the constants.
|
||||
** Settings :
|
||||
** Contents :
|
||||
** No public methods
|
||||
**
|
||||
** Copyright : 1997 - 2014 Freescale Semiconductor, Inc.
|
||||
** All Rights Reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without modification,
|
||||
** are permitted provided that the following conditions are met:
|
||||
**
|
||||
** o Redistributions of source code must retain the above copyright notice, this list
|
||||
** of conditions and the following disclaimer.
|
||||
**
|
||||
** o Redistributions in binary form must reproduce the above copyright notice, this
|
||||
** list of conditions and the following disclaimer in the documentation and/or
|
||||
** other materials provided with the distribution.
|
||||
**
|
||||
** o Neither the name of Freescale Semiconductor, Inc. nor the names of its
|
||||
** contributors may be used to endorse or promote products derived from this
|
||||
** software without specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
** ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
** ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
**
|
||||
** http: www.freescale.com
|
||||
** mail: support@freescale.com
|
||||
** ###################################################################*/
|
||||
/*!
|
||||
** @file PE_Const.h
|
||||
** @version 01.00
|
||||
** @brief
|
||||
** This component "PE_Const" contains internal definitions
|
||||
** of the constants.
|
||||
*/
|
||||
/*!
|
||||
** @addtogroup PE_Const_module PE_Const module documentation
|
||||
** @{
|
||||
*/
|
||||
|
||||
#ifndef __PE_Const_H
|
||||
#define __PE_Const_H
|
||||
|
||||
|
||||
/* Reset cause constants */
|
||||
#define RSTSRC_WAKEUP 0x01U /*!< LLWU module wakeup reset */
|
||||
#define RSTSRC_LVD 0x02U /*!< Low-voltage detect reset */
|
||||
#define RSTSRC_LOC 0x04U /*!< Loss-of-clock reset */
|
||||
#define RSTSRC_LOL 0x08U /*!< Loss-of-lock reset */
|
||||
#define RSTSRC_COP 0x20U /*!< Watchdog reset */
|
||||
#define RSTSRC_WDOG 0x20U /*!< Watchdog reset */
|
||||
#define RSTSRC_PIN 0x40U /*!< External pin reset */
|
||||
#define RSTSRC_POR 0x80U /*!< Power-on reset */
|
||||
#define RSTSRC_JTAG 0x0100U /*!< JTAG reset pin */
|
||||
#define RSTSRC_LOCKUP 0x0200U /*!< Core Lock-up reset */
|
||||
#define RSTSRC_SW 0x0400U /*!< Software reset */
|
||||
#define RSTSRC_MDM_AP 0x0800U /*!< Reset caused by host debugger system */
|
||||
#define RSTSRC_EZPT 0x1000U /*!< EzPort reset */
|
||||
#define RSTSRC_SACKERR 0x2000U /*!< Stop Mode Acknowledge Error Reset */
|
||||
|
||||
|
||||
/* Low voltage interrupt cause constants */
|
||||
#define LVDSRC_LVD 0x01U /*!< Low voltage detect */
|
||||
#define LVDSRC_LVW 0x02U /*!< Low-voltage warning */
|
||||
|
||||
#endif /* _PE_Const_H */
|
||||
/*!
|
||||
** @}
|
||||
*/
|
||||
/*
|
||||
** ###################################################################
|
||||
**
|
||||
** This file was created by Processor Expert 10.4 [05.11]
|
||||
** for the Freescale Kinetis series of microcontrollers.
|
||||
**
|
||||
** ###################################################################
|
||||
*/
|
||||
@@ -0,0 +1,128 @@
|
||||
/* ###################################################################
|
||||
** THIS COMPONENT MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.
|
||||
** Filename : PE_Error.h
|
||||
** Project : Landungsbruecke_KDS_v2.0.0
|
||||
** Processor : MK20DN512VLL10
|
||||
** Component : PE_Error
|
||||
** Version : Driver 01.00
|
||||
** Compiler : GNU C Compiler
|
||||
** Date/Time : 2015-01-09, 16:27, # CodeGen: 0
|
||||
** Abstract :
|
||||
** This component "PE_Error" contains internal definitions
|
||||
** of the error constants.
|
||||
** Contents :
|
||||
** No public methods
|
||||
**
|
||||
** Copyright : 1997 - 2014 Freescale Semiconductor, Inc.
|
||||
** All Rights Reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without modification,
|
||||
** are permitted provided that the following conditions are met:
|
||||
**
|
||||
** o Redistributions of source code must retain the above copyright notice, this list
|
||||
** of conditions and the following disclaimer.
|
||||
**
|
||||
** o Redistributions in binary form must reproduce the above copyright notice, this
|
||||
** list of conditions and the following disclaimer in the documentation and/or
|
||||
** other materials provided with the distribution.
|
||||
**
|
||||
** o Neither the name of Freescale Semiconductor, Inc. nor the names of its
|
||||
** contributors may be used to endorse or promote products derived from this
|
||||
** software without specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
** ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
** ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
**
|
||||
** http: www.freescale.com
|
||||
** mail: support@freescale.com
|
||||
** ###################################################################*/
|
||||
/*!
|
||||
** @file PE_Error.h
|
||||
** @version 01.00
|
||||
** @brief
|
||||
** This component "PE_Error" contains internal definitions
|
||||
** of the error constants.
|
||||
*/
|
||||
/*!
|
||||
** @addtogroup PE_Error_module PE_Error module documentation
|
||||
** @{
|
||||
*/
|
||||
|
||||
#ifndef __PE_Error_H
|
||||
#define __PE_Error_H
|
||||
|
||||
#define ERR_OK 0x00U /*!< OK */
|
||||
#define ERR_SPEED 0x01U /*!< This device does not work in the active speed mode. */
|
||||
#define ERR_RANGE 0x02U /*!< Parameter out of range. */
|
||||
#define ERR_VALUE 0x03U /*!< Parameter of incorrect value. */
|
||||
#define ERR_OVERFLOW 0x04U /*!< Timer overflow. */
|
||||
#define ERR_MATH 0x05U /*!< Overflow during evaluation. */
|
||||
#define ERR_ENABLED 0x06U /*!< Device is enabled. */
|
||||
#define ERR_DISABLED 0x07U /*!< Device is disabled. */
|
||||
#define ERR_BUSY 0x08U /*!< Device is busy. */
|
||||
#define ERR_NOTAVAIL 0x09U /*!< Requested value or method not available. */
|
||||
#define ERR_RXEMPTY 0x0AU /*!< No data in receiver. */
|
||||
#define ERR_TXFULL 0x0BU /*!< Transmitter is full. */
|
||||
#define ERR_BUSOFF 0x0CU /*!< Bus not available. */
|
||||
#define ERR_OVERRUN 0x0DU /*!< Overrun error is detected. */
|
||||
#define ERR_FRAMING 0x0EU /*!< Framing error is detected. */
|
||||
#define ERR_PARITY 0x0FU /*!< Parity error is detected. */
|
||||
#define ERR_NOISE 0x10U /*!< Noise error is detected. */
|
||||
#define ERR_IDLE 0x11U /*!< Idle error is detected. */
|
||||
#define ERR_FAULT 0x12U /*!< Fault error is detected. */
|
||||
#define ERR_BREAK 0x13U /*!< Break char is received during communication. */
|
||||
#define ERR_CRC 0x14U /*!< CRC error is detected. */
|
||||
#define ERR_ARBITR 0x15U /*!< A node losts arbitration. This error occurs if two nodes start transmission at the same time. */
|
||||
#define ERR_PROTECT 0x16U /*!< Protection error is detected. */
|
||||
#define ERR_UNDERFLOW 0x17U /*!< Underflow error is detected. */
|
||||
#define ERR_UNDERRUN 0x18U /*!< Underrun error is detected. */
|
||||
#define ERR_COMMON 0x19U /*!< Common error of a device. */
|
||||
#define ERR_LINSYNC 0x1AU /*!< LIN synchronization error is detected. */
|
||||
#define ERR_FAILED 0x1BU /*!< Requested functionality or process failed. */
|
||||
#define ERR_QFULL 0x1CU /*!< Queue is full. */
|
||||
#define ERR_PARAM_MASK 0x80U /*!< Invalid mask. */
|
||||
#define ERR_PARAM_MODE 0x81U /*!< Invalid mode. */
|
||||
#define ERR_PARAM_INDEX 0x82U /*!< Invalid index. */
|
||||
#define ERR_PARAM_DATA 0x83U /*!< Invalid data. */
|
||||
#define ERR_PARAM_SIZE 0x84U /*!< Invalid size. */
|
||||
#define ERR_PARAM_VALUE 0x85U /*!< Invalid value. */
|
||||
#define ERR_PARAM_RANGE 0x86U /*!< Invalid parameter's range or parameters' combination. */
|
||||
#define ERR_PARAM_LOW_VALUE 0x87U /*!< Invalid value (LOW part). */
|
||||
#define ERR_PARAM_HIGH_VALUE 0x88U /*!< Invalid value (HIGH part). */
|
||||
#define ERR_PARAM_ADDRESS 0x89U /*!< Invalid address. */
|
||||
#define ERR_PARAM_PARITY 0x8AU /*!< Invalid parity. */
|
||||
#define ERR_PARAM_WIDTH 0x8BU /*!< Invalid width. */
|
||||
#define ERR_PARAM_LENGTH 0x8CU /*!< Invalid length. */
|
||||
#define ERR_PARAM_ADDRESS_TYPE 0x8DU /*!< Invalid address type. */
|
||||
#define ERR_PARAM_COMMAND_TYPE 0x8EU /*!< Invalid command type. */
|
||||
#define ERR_PARAM_COMMAND 0x8FU /*!< Invalid command. */
|
||||
#define ERR_PARAM_RECIPIENT 0x90U /*!< Invalid recipient. */
|
||||
#define ERR_PARAM_BUFFER_COUNT 0x91U /*!< Invalid buffer count. */
|
||||
#define ERR_PARAM_ID 0x92U /*!< Invalid ID. */
|
||||
#define ERR_PARAM_GROUP 0x93U /*!< Invalid group. */
|
||||
#define ERR_PARAM_CHIP_SELECT 0x94U /*!< Invalid chip select. */
|
||||
#define ERR_PARAM_ATTRIBUTE_SET 0x95U /*!< Invalid set of attributes. */
|
||||
#define ERR_PARAM_SAMPLE_COUNT 0x96U /*!< Invalid sample count. */
|
||||
#define ERR_PARAM_CONDITION 0x97U /*!< Invalid condition. */
|
||||
#define ERR_PARAM_TICKS 0x98U /*!< Invalid ticks parameter. */
|
||||
|
||||
#endif /* __PE_Error_H */
|
||||
/*!
|
||||
** @}
|
||||
*/
|
||||
/*
|
||||
** ###################################################################
|
||||
**
|
||||
** This file was created by Processor Expert 10.4 [05.11]
|
||||
** for the Freescale Kinetis series of microcontrollers.
|
||||
**
|
||||
** ###################################################################
|
||||
*/
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,223 @@
|
||||
/* ################################################################### */
|
||||
/*##
|
||||
/*## This component module is generated by Processor Expert. Do not modify it. */
|
||||
/*## */
|
||||
/*## Filename : ProcessorExpert.ld */
|
||||
/*## */
|
||||
/*## Project : Landungsbruecke_KDS_v2.0.0 */
|
||||
/*## */
|
||||
/*## Processor : MK20DN512VLL10 */
|
||||
/*## */
|
||||
/*## Compiler : GNU C Compiler */
|
||||
/*## */
|
||||
/*## Date/Time : 2015-01-09, 16:27, # CodeGen: 0 */
|
||||
/*## */
|
||||
/*## Abstract : */
|
||||
/*## */
|
||||
/*## This file is used by the linker. It describes files to be linked, */
|
||||
/*## memory ranges, stack size, etc. For detailed description about linker */
|
||||
/*## command files see compiler documentation. This file is generated by default. */
|
||||
/*## You can switch off generation by setting the property "Generate linker file = no" */
|
||||
/*## in the "Build options" tab of the CPU component and then modify this file as needed. */
|
||||
/*##
|
||||
/*## */
|
||||
/*## ###################################################################*/
|
||||
|
||||
|
||||
/* Entry Point */
|
||||
ENTRY(__thumb_startup)
|
||||
|
||||
/* Highest address of the user mode stack */
|
||||
_estack = 0x20000000; /* end of m_data */
|
||||
__SP_INIT = _estack;
|
||||
|
||||
/* Generate a link error if heap and stack don't fit into RAM */
|
||||
__heap_size = 0x00; /* required amount of heap */
|
||||
__stack_size = 0x0400; /* required amount of stack */
|
||||
|
||||
MEMORY {
|
||||
m_interrupts (RX) : ORIGIN = 0x00000000, LENGTH = 0x000001E0
|
||||
m_text (RX) : ORIGIN = 0x00000410, LENGTH = 0x0007FBF0
|
||||
m_data (RW) : ORIGIN = 0x1FFF0000, LENGTH = 0x00010000
|
||||
m_data_20000000 (RW) : ORIGIN = 0x20000000, LENGTH = 0x00010000
|
||||
m_cfmprotrom (RX) : ORIGIN = 0x00000400, LENGTH = 0x00000010
|
||||
}
|
||||
|
||||
/* Define output sections */
|
||||
SECTIONS
|
||||
{
|
||||
/* The startup code goes first into INTERNAL_FLASH */
|
||||
.interrupts :
|
||||
{
|
||||
__vector_table = .;
|
||||
. = ALIGN(4);
|
||||
KEEP(*(.vectortable)) /* Startup code */
|
||||
. = ALIGN(4);
|
||||
} > m_interrupts
|
||||
|
||||
.cfmprotect :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
KEEP(*(.cfmconfig)) /* Flash Configuration Field (FCF) */
|
||||
. = ALIGN(4);
|
||||
} > m_cfmprotrom
|
||||
|
||||
/* The program code and other data goes into INTERNAL_FLASH */
|
||||
.text :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
*(.text) /* .text sections (code) */
|
||||
*(.text*) /* .text* sections (code) */
|
||||
*(.rodata) /* .rodata sections (constants, strings, etc.) */
|
||||
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
|
||||
*(.glue_7) /* glue arm to thumb code */
|
||||
*(.glue_7t) /* glue thumb to arm code */
|
||||
*(.eh_frame)
|
||||
|
||||
KEEP (*(.init))
|
||||
KEEP (*(.fini))
|
||||
|
||||
. = ALIGN(4);
|
||||
|
||||
_etext = .; /* define a global symbols at end of code */
|
||||
} > m_text
|
||||
|
||||
.ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } > m_text
|
||||
.ARM : {
|
||||
__exidx_start = .;
|
||||
*(.ARM.exidx*)
|
||||
__exidx_end = .;
|
||||
} > m_text
|
||||
|
||||
.ctors :
|
||||
{
|
||||
__CTOR_LIST__ = .;
|
||||
/* gcc uses crtbegin.o to find the start of
|
||||
the constructors, so we make sure it is
|
||||
first. Because this is a wildcard, it
|
||||
doesn't matter if the user does not
|
||||
actually link against crtbegin.o; the
|
||||
linker won't look for a file to match a
|
||||
wildcard. The wildcard also means that it
|
||||
doesn't matter which directory crtbegin.o
|
||||
is in. */
|
||||
KEEP (*crtbegin.o(.ctors))
|
||||
/* We don't want to include the .ctor section from
|
||||
from the crtend.o file until after the sorted ctors.
|
||||
The .ctor section from the crtend file contains the
|
||||
end of ctors marker and it must be last */
|
||||
KEEP (*(EXCLUDE_FILE (*crtend.o ) .ctors))
|
||||
KEEP (*(SORT(.ctors.*)))
|
||||
KEEP (*(.ctors))
|
||||
__CTOR_END__ = .;
|
||||
} > m_text
|
||||
|
||||
.dtors :
|
||||
{
|
||||
__DTOR_LIST__ = .;
|
||||
KEEP (*crtbegin.o(.dtors))
|
||||
KEEP (*(EXCLUDE_FILE (*crtend.o ) .dtors))
|
||||
KEEP (*(SORT(.dtors.*)))
|
||||
KEEP (*(.dtors))
|
||||
__DTOR_END__ = .;
|
||||
} > m_text
|
||||
|
||||
.preinit_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__preinit_array_start = .);
|
||||
KEEP (*(.preinit_array*))
|
||||
PROVIDE_HIDDEN (__preinit_array_end = .);
|
||||
} > m_text
|
||||
.init_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__init_array_start = .);
|
||||
KEEP (*(SORT(.init_array.*)))
|
||||
KEEP (*(.init_array*))
|
||||
PROVIDE_HIDDEN (__init_array_end = .);
|
||||
} > m_text
|
||||
.fini_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__fini_array_start = .);
|
||||
KEEP (*(SORT(.fini_array.*)))
|
||||
KEEP (*(.fini_array*))
|
||||
PROVIDE_HIDDEN (__fini_array_end = .);
|
||||
|
||||
___ROM_AT = .;
|
||||
} > m_text
|
||||
/* Initialized data sections goes into RAM, load LMA copy after code */
|
||||
.data : AT(___ROM_AT)
|
||||
{
|
||||
. = ALIGN(4);
|
||||
_sdata = .; /* create a global symbol at data start */
|
||||
*(.data) /* .data sections */
|
||||
*(.data*) /* .data* sections */
|
||||
|
||||
. = ALIGN(4);
|
||||
|
||||
_edata = .; /* define a global symbol at data end */
|
||||
} > m_data
|
||||
|
||||
___data_size = _edata - _sdata;
|
||||
___m_data_20000000_ROMStart = ___ROM_AT + SIZEOF(.data);
|
||||
.m_data_20000000 : AT(___m_data_20000000_ROMStart)
|
||||
{
|
||||
. = ALIGN(4);
|
||||
___m_data_20000000_RAMStart = .;
|
||||
*(.m_data_20000000) /* This is an User defined section */
|
||||
___m_data_20000000_RAMEnd = .;
|
||||
. = ALIGN(4);
|
||||
} > m_data_20000000
|
||||
___m_data_20000000_ROMSize = ___m_data_20000000_RAMEnd - ___m_data_20000000_RAMStart;
|
||||
|
||||
|
||||
|
||||
/* Uninitialized data section */
|
||||
. = ALIGN(4);
|
||||
.bss :
|
||||
{
|
||||
/* This is used by the startup in order to initialize the .bss section */
|
||||
__START_BSS = .;
|
||||
PROVIDE ( __bss_start__ = __START_BSS );
|
||||
|
||||
*(.bss)
|
||||
*(.bss*)
|
||||
*(COMMON)
|
||||
|
||||
. = ALIGN(4);
|
||||
__END_BSS = .;
|
||||
PROVIDE ( __bss_end__ = __END_BSS );
|
||||
} > m_data
|
||||
|
||||
_romp_at = ___ROM_AT + SIZEOF(.data) +SIZEOF(.m_data_20000000);
|
||||
.romp : AT(_romp_at)
|
||||
{
|
||||
__S_romp = _romp_at;
|
||||
LONG(___ROM_AT);
|
||||
LONG(_sdata);
|
||||
LONG(___data_size);
|
||||
LONG(___m_data_20000000_ROMStart);
|
||||
LONG(___m_data_20000000_RAMStart);
|
||||
LONG(___m_data_20000000_ROMSize);
|
||||
LONG(0);
|
||||
LONG(0);
|
||||
LONG(0);
|
||||
} > m_data
|
||||
|
||||
/* User_heap_stack section, used to check that there is enough RAM left */
|
||||
._user_heap_stack :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
PROVIDE ( end = . );
|
||||
PROVIDE ( _end = . );
|
||||
__heap_addr = .;
|
||||
__HeapBase = .;
|
||||
. = . + __heap_size;
|
||||
__HeapLimit = .;
|
||||
. = . + __stack_size;
|
||||
. = ALIGN(4);
|
||||
} > m_data
|
||||
|
||||
.ARM.attributes 0 : { *(.ARM.attributes) }
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,202 @@
|
||||
/* ###################################################################
|
||||
** THIS COMPONENT MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.
|
||||
** Filename : Rx1.c
|
||||
** Project : Landungsbruecke_KDS_v2.0.0
|
||||
** Processor : MK20DN512VLL10
|
||||
** Component : RingBuffer
|
||||
** Version : Component 01.025, Driver 01.00, CPU db: 3.00.000
|
||||
** Compiler : GNU C Compiler
|
||||
** Date/Time : 2015-01-09, 16:27, # CodeGen: 0
|
||||
** Abstract :
|
||||
** This component implements a ring buffer for different integer data type.
|
||||
** Settings :
|
||||
** Component name : Rx1
|
||||
** Buffer Size : 1
|
||||
** Contents :
|
||||
** Clear - void Rx1_Clear(void);
|
||||
** Put - byte Rx1_Put(Rx1_ElementType elem);
|
||||
** Get - byte Rx1_Get(Rx1_ElementType *elemP);
|
||||
** NofElements - Rx1_BufSizeType Rx1_NofElements(void);
|
||||
** NofFreeElements - Rx1_BufSizeType Rx1_NofFreeElements(void);
|
||||
** Init - void Rx1_Init(void);
|
||||
**
|
||||
** License : Open Source (LGPL)
|
||||
** Copyright : (c) Copyright Erich Styger, 2014, all rights reserved.
|
||||
** Web: http://www.mcuoneclipse.com
|
||||
** This an open source software of an embedded component for Processor Expert.
|
||||
** This is a free software and is opened for education, research and commercial developments under license policy of following terms:
|
||||
** * This is a free software and there is NO WARRANTY.
|
||||
** * No restriction on use. You can use, modify and redistribute it for personal, non-profit or commercial product UNDER YOUR RESPONSIBILITY.
|
||||
** * Redistributions of source code must retain the above copyright notice.
|
||||
** ###################################################################*/
|
||||
/*!
|
||||
** @file Rx1.c
|
||||
** @version 01.00
|
||||
** @brief
|
||||
** This component implements a ring buffer for different integer data type.
|
||||
*/
|
||||
/*!
|
||||
** @addtogroup Rx1_module Rx1 module documentation
|
||||
** @{
|
||||
*/
|
||||
|
||||
/* MODULE Rx1. */
|
||||
|
||||
#include "Rx1.h"
|
||||
|
||||
#if Rx1_IS_REENTRANT
|
||||
#define Rx1_DEFINE_CRITICAL() CS1_CriticalVariable()
|
||||
#define Rx1_ENTER_CRITICAL() CS1_EnterCritical()
|
||||
#define Rx1_EXIT_CRITICAL() CS1_ExitCritical()
|
||||
#else
|
||||
#define Rx1_DEFINE_CRITICAL() /* nothing */
|
||||
#define Rx1_ENTER_CRITICAL() /* nothing */
|
||||
#define Rx1_EXIT_CRITICAL() /* nothing */
|
||||
#endif
|
||||
static Rx1_ElementType Rx1_buffer[Rx1_BUF_SIZE]; /* ring buffer */
|
||||
static Rx1_BufSizeType Rx1_inIdx; /* input index */
|
||||
static Rx1_BufSizeType Rx1_outIdx; /* output index */
|
||||
static Rx1_BufSizeType Rx1_inSize; /* size data in buffer */
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : Rx1_Put (component RingBuffer)
|
||||
** Description :
|
||||
** Puts a new element into the buffer
|
||||
** Parameters :
|
||||
** NAME - DESCRIPTION
|
||||
** elem - New element to be put into the buffer
|
||||
** Returns :
|
||||
** --- - Error code
|
||||
** ===================================================================
|
||||
*/
|
||||
byte Rx1_Put(Rx1_ElementType elem)
|
||||
{
|
||||
byte res = ERR_OK;
|
||||
Rx1_DEFINE_CRITICAL();
|
||||
|
||||
Rx1_ENTER_CRITICAL();
|
||||
if(Rx1_inSize==Rx1_BUF_SIZE) {
|
||||
res = ERR_TXFULL;
|
||||
} else {
|
||||
Rx1_buffer[Rx1_inIdx] = elem;
|
||||
Rx1_inSize++;
|
||||
Rx1_inIdx++;
|
||||
if(Rx1_inIdx==Rx1_BUF_SIZE) {
|
||||
Rx1_inIdx = 0;
|
||||
}
|
||||
}
|
||||
Rx1_EXIT_CRITICAL();
|
||||
return res;
|
||||
}
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : Rx1_Get (component RingBuffer)
|
||||
** Description :
|
||||
** Removes an element from the buffer
|
||||
** Parameters :
|
||||
** NAME - DESCRIPTION
|
||||
** * elemP - Pointer to where to store the received
|
||||
** element
|
||||
** Returns :
|
||||
** --- - Error code
|
||||
** ===================================================================
|
||||
*/
|
||||
byte Rx1_Get(Rx1_ElementType *elemP)
|
||||
{
|
||||
byte res = ERR_OK;
|
||||
Rx1_DEFINE_CRITICAL();
|
||||
|
||||
Rx1_ENTER_CRITICAL();
|
||||
if(Rx1_inSize==0) {
|
||||
res = ERR_RXEMPTY;
|
||||
} else {
|
||||
*elemP = Rx1_buffer[Rx1_outIdx];
|
||||
Rx1_inSize--;
|
||||
Rx1_outIdx++;
|
||||
if(Rx1_outIdx==Rx1_BUF_SIZE) {
|
||||
Rx1_outIdx = 0;
|
||||
}
|
||||
}
|
||||
Rx1_EXIT_CRITICAL();
|
||||
return res;
|
||||
}
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : Rx1_NofElements (component RingBuffer)
|
||||
** Description :
|
||||
** Returns the actual number of elements in the buffer.
|
||||
** Parameters : None
|
||||
** Returns :
|
||||
** --- - Number of elements in the buffer.
|
||||
** ===================================================================
|
||||
*/
|
||||
Rx1_BufSizeType Rx1_NofElements(void)
|
||||
{
|
||||
return Rx1_inSize;
|
||||
}
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : Rx1_NofFreeElements (component RingBuffer)
|
||||
** Description :
|
||||
** Returns the actual number of free elements/space in the
|
||||
** buffer.
|
||||
** Parameters : None
|
||||
** Returns :
|
||||
** --- - Number of elements in the buffer.
|
||||
** ===================================================================
|
||||
*/
|
||||
Rx1_BufSizeType Rx1_NofFreeElements(void)
|
||||
{
|
||||
return (Rx1_BufSizeType)(Rx1_BUF_SIZE-Rx1_inSize);
|
||||
}
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : Rx1_Init (component RingBuffer)
|
||||
** Description :
|
||||
** Initializes the data structure
|
||||
** Parameters : None
|
||||
** Returns : Nothing
|
||||
** ===================================================================
|
||||
*/
|
||||
void Rx1_Init(void)
|
||||
{
|
||||
Rx1_inIdx = 0;
|
||||
Rx1_outIdx = 0;
|
||||
Rx1_inSize = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : Rx1_Clear (component RingBuffer)
|
||||
** Description :
|
||||
** Clear (empty) the ring buffer.
|
||||
** Parameters : None
|
||||
** Returns : Nothing
|
||||
** ===================================================================
|
||||
*/
|
||||
void Rx1_Clear(void)
|
||||
{
|
||||
Rx1_DEFINE_CRITICAL();
|
||||
|
||||
Rx1_ENTER_CRITICAL();
|
||||
Rx1_Init();
|
||||
Rx1_EXIT_CRITICAL();
|
||||
}
|
||||
|
||||
/* END Rx1. */
|
||||
|
||||
/*!
|
||||
** @}
|
||||
*/
|
||||
/*
|
||||
** ###################################################################
|
||||
**
|
||||
** This file was created by Processor Expert 10.4 [05.11]
|
||||
** for the Freescale Kinetis series of microcontrollers.
|
||||
**
|
||||
** ###################################################################
|
||||
*/
|
||||
@@ -0,0 +1,167 @@
|
||||
/* ###################################################################
|
||||
** THIS COMPONENT MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.
|
||||
** Filename : Rx1.h
|
||||
** Project : Landungsbruecke_KDS_v2.0.0
|
||||
** Processor : MK20DN512VLL10
|
||||
** Component : RingBuffer
|
||||
** Version : Component 01.025, Driver 01.00, CPU db: 3.00.000
|
||||
** Compiler : GNU C Compiler
|
||||
** Date/Time : 2015-01-09, 16:27, # CodeGen: 0
|
||||
** Abstract :
|
||||
** This component implements a ring buffer for different integer data type.
|
||||
** Settings :
|
||||
** Component name : Rx1
|
||||
** Buffer Size : 1
|
||||
** Contents :
|
||||
** Clear - void Rx1_Clear(void);
|
||||
** Put - byte Rx1_Put(Rx1_ElementType elem);
|
||||
** Get - byte Rx1_Get(Rx1_ElementType *elemP);
|
||||
** NofElements - Rx1_BufSizeType Rx1_NofElements(void);
|
||||
** NofFreeElements - Rx1_BufSizeType Rx1_NofFreeElements(void);
|
||||
** Init - void Rx1_Init(void);
|
||||
**
|
||||
** License : Open Source (LGPL)
|
||||
** Copyright : (c) Copyright Erich Styger, 2014, all rights reserved.
|
||||
** Web: http://www.mcuoneclipse.com
|
||||
** This an open source software of an embedded component for Processor Expert.
|
||||
** This is a free software and is opened for education, research and commercial developments under license policy of following terms:
|
||||
** * This is a free software and there is NO WARRANTY.
|
||||
** * No restriction on use. You can use, modify and redistribute it for personal, non-profit or commercial product UNDER YOUR RESPONSIBILITY.
|
||||
** * Redistributions of source code must retain the above copyright notice.
|
||||
** ###################################################################*/
|
||||
/*!
|
||||
** @file Rx1.h
|
||||
** @version 01.00
|
||||
** @brief
|
||||
** This component implements a ring buffer for different integer data type.
|
||||
*/
|
||||
/*!
|
||||
** @addtogroup Rx1_module Rx1 module documentation
|
||||
** @{
|
||||
*/
|
||||
|
||||
#ifndef __Rx1_H
|
||||
#define __Rx1_H
|
||||
|
||||
/* MODULE Rx1. */
|
||||
|
||||
/* Include shared modules, which are used for whole project */
|
||||
#include "PE_Types.h"
|
||||
#include "PE_Error.h"
|
||||
#include "PE_Const.h"
|
||||
#include "MK20D10.h"
|
||||
/* Include inherited beans */
|
||||
#include "CS1.h"
|
||||
|
||||
//#include "Cpu.h"
|
||||
|
||||
|
||||
#define Rx1_BUF_SIZE 64 /* number of elements in the buffer */
|
||||
#define Rx1_ELEM_SIZE 1 /* size of a single element in bytes */
|
||||
#define Rx1_IS_REENTRANT 0 /* 0: Critical section NOT used for accessing shared data, 1 otherwise */
|
||||
#if Rx1_ELEM_SIZE==1
|
||||
typedef uint8 Rx1_ElementType; /* type of single element */
|
||||
#elif Rx1_ELEM_SIZE==2
|
||||
typedef uint16 Rx1_ElementType; /* type of single element */
|
||||
#elif Rx1_ELEM_SIZE==4
|
||||
typedef uint32 Rx1_ElementType; /* type of single element */
|
||||
#else
|
||||
#error "illegal element type size in properties"
|
||||
#endif
|
||||
#if Rx1_BUF_SIZE<=256
|
||||
typedef uint8 Rx1_BufSizeType; /* up to 256 elements (index 0x00..0xFF) */
|
||||
#else
|
||||
typedef uint16 Rx1_BufSizeType; /* more than 256 elements, up to 2^16 */
|
||||
#endif
|
||||
|
||||
byte Rx1_Put(Rx1_ElementType elem);
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : Rx1_Put (component RingBuffer)
|
||||
** Description :
|
||||
** Puts a new element into the buffer
|
||||
** Parameters :
|
||||
** NAME - DESCRIPTION
|
||||
** elem - New element to be put into the buffer
|
||||
** Returns :
|
||||
** --- - Error code
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
byte Rx1_Get(Rx1_ElementType *elemP);
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : Rx1_Get (component RingBuffer)
|
||||
** Description :
|
||||
** Removes an element from the buffer
|
||||
** Parameters :
|
||||
** NAME - DESCRIPTION
|
||||
** * elemP - Pointer to where to store the received
|
||||
** element
|
||||
** Returns :
|
||||
** --- - Error code
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
Rx1_BufSizeType Rx1_NofElements(void);
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : Rx1_NofElements (component RingBuffer)
|
||||
** Description :
|
||||
** Returns the actual number of elements in the buffer.
|
||||
** Parameters : None
|
||||
** Returns :
|
||||
** --- - Number of elements in the buffer.
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
void Rx1_Init(void);
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : Rx1_Init (component RingBuffer)
|
||||
** Description :
|
||||
** Initializes the data structure
|
||||
** Parameters : None
|
||||
** Returns : Nothing
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
Rx1_BufSizeType Rx1_NofFreeElements(void);
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : Rx1_NofFreeElements (component RingBuffer)
|
||||
** Description :
|
||||
** Returns the actual number of free elements/space in the
|
||||
** buffer.
|
||||
** Parameters : None
|
||||
** Returns :
|
||||
** --- - Number of elements in the buffer.
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
void Rx1_Clear(void);
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : Rx1_Clear (component RingBuffer)
|
||||
** Description :
|
||||
** Clear (empty) the ring buffer.
|
||||
** Parameters : None
|
||||
** Returns : Nothing
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
/* END Rx1. */
|
||||
|
||||
#endif
|
||||
/* ifndef __Rx1_H */
|
||||
/*!
|
||||
** @}
|
||||
*/
|
||||
/*
|
||||
** ###################################################################
|
||||
**
|
||||
** This file was created by Processor Expert 10.4 [05.11]
|
||||
** for the Freescale Kinetis series of microcontrollers.
|
||||
**
|
||||
** ###################################################################
|
||||
*/
|
||||
@@ -0,0 +1,202 @@
|
||||
/* ###################################################################
|
||||
** THIS COMPONENT MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.
|
||||
** Filename : Tx1.c
|
||||
** Project : Landungsbruecke_KDS_v2.0.0
|
||||
** Processor : MK20DN512VLL10
|
||||
** Component : RingBuffer
|
||||
** Version : Component 01.025, Driver 01.00, CPU db: 3.00.000
|
||||
** Compiler : GNU C Compiler
|
||||
** Date/Time : 2015-01-09, 16:27, # CodeGen: 0
|
||||
** Abstract :
|
||||
** This component implements a ring buffer for different integer data type.
|
||||
** Settings :
|
||||
** Component name : Tx1
|
||||
** Buffer Size : 1
|
||||
** Contents :
|
||||
** Clear - void Tx1_Clear(void);
|
||||
** Put - byte Tx1_Put(Tx1_ElementType elem);
|
||||
** Get - byte Tx1_Get(Tx1_ElementType *elemP);
|
||||
** NofElements - Tx1_BufSizeType Tx1_NofElements(void);
|
||||
** NofFreeElements - Tx1_BufSizeType Tx1_NofFreeElements(void);
|
||||
** Init - void Tx1_Init(void);
|
||||
**
|
||||
** License : Open Source (LGPL)
|
||||
** Copyright : (c) Copyright Erich Styger, 2014, all rights reserved.
|
||||
** Web: http://www.mcuoneclipse.com
|
||||
** This an open source software of an embedded component for Processor Expert.
|
||||
** This is a free software and is opened for education, research and commercial developments under license policy of following terms:
|
||||
** * This is a free software and there is NO WARRANTY.
|
||||
** * No restriction on use. You can use, modify and redistribute it for personal, non-profit or commercial product UNDER YOUR RESPONSIBILITY.
|
||||
** * Redistributions of source code must retain the above copyright notice.
|
||||
** ###################################################################*/
|
||||
/*!
|
||||
** @file Tx1.c
|
||||
** @version 01.00
|
||||
** @brief
|
||||
** This component implements a ring buffer for different integer data type.
|
||||
*/
|
||||
/*!
|
||||
** @addtogroup Tx1_module Tx1 module documentation
|
||||
** @{
|
||||
*/
|
||||
|
||||
/* MODULE Tx1. */
|
||||
|
||||
#include "Tx1.h"
|
||||
|
||||
#if Tx1_IS_REENTRANT
|
||||
#define Tx1_DEFINE_CRITICAL() CS1_CriticalVariable()
|
||||
#define Tx1_ENTER_CRITICAL() CS1_EnterCritical()
|
||||
#define Tx1_EXIT_CRITICAL() CS1_ExitCritical()
|
||||
#else
|
||||
#define Tx1_DEFINE_CRITICAL() /* nothing */
|
||||
#define Tx1_ENTER_CRITICAL() /* nothing */
|
||||
#define Tx1_EXIT_CRITICAL() /* nothing */
|
||||
#endif
|
||||
static Tx1_ElementType Tx1_buffer[Tx1_BUF_SIZE]; /* ring buffer */
|
||||
static Tx1_BufSizeType Tx1_inIdx; /* input index */
|
||||
static Tx1_BufSizeType Tx1_outIdx; /* output index */
|
||||
static Tx1_BufSizeType Tx1_inSize; /* size data in buffer */
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : Tx1_Put (component RingBuffer)
|
||||
** Description :
|
||||
** Puts a new element into the buffer
|
||||
** Parameters :
|
||||
** NAME - DESCRIPTION
|
||||
** elem - New element to be put into the buffer
|
||||
** Returns :
|
||||
** --- - Error code
|
||||
** ===================================================================
|
||||
*/
|
||||
byte Tx1_Put(Tx1_ElementType elem)
|
||||
{
|
||||
byte res = ERR_OK;
|
||||
Tx1_DEFINE_CRITICAL();
|
||||
|
||||
Tx1_ENTER_CRITICAL();
|
||||
if(Tx1_inSize==Tx1_BUF_SIZE) {
|
||||
res = ERR_TXFULL;
|
||||
} else {
|
||||
Tx1_buffer[Tx1_inIdx] = elem;
|
||||
Tx1_inSize++;
|
||||
Tx1_inIdx++;
|
||||
if(Tx1_inIdx==Tx1_BUF_SIZE) {
|
||||
Tx1_inIdx = 0;
|
||||
}
|
||||
}
|
||||
Tx1_EXIT_CRITICAL();
|
||||
return res;
|
||||
}
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : Tx1_Get (component RingBuffer)
|
||||
** Description :
|
||||
** Removes an element from the buffer
|
||||
** Parameters :
|
||||
** NAME - DESCRIPTION
|
||||
** * elemP - Pointer to where to store the received
|
||||
** element
|
||||
** Returns :
|
||||
** --- - Error code
|
||||
** ===================================================================
|
||||
*/
|
||||
byte Tx1_Get(Tx1_ElementType *elemP)
|
||||
{
|
||||
byte res = ERR_OK;
|
||||
Tx1_DEFINE_CRITICAL();
|
||||
|
||||
Tx1_ENTER_CRITICAL();
|
||||
if(Tx1_inSize==0) {
|
||||
res = ERR_RXEMPTY;
|
||||
} else {
|
||||
*elemP = Tx1_buffer[Tx1_outIdx];
|
||||
Tx1_inSize--;
|
||||
Tx1_outIdx++;
|
||||
if(Tx1_outIdx==Tx1_BUF_SIZE) {
|
||||
Tx1_outIdx = 0;
|
||||
}
|
||||
}
|
||||
Tx1_EXIT_CRITICAL();
|
||||
return res;
|
||||
}
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : Tx1_NofElements (component RingBuffer)
|
||||
** Description :
|
||||
** Returns the actual number of elements in the buffer.
|
||||
** Parameters : None
|
||||
** Returns :
|
||||
** --- - Number of elements in the buffer.
|
||||
** ===================================================================
|
||||
*/
|
||||
Tx1_BufSizeType Tx1_NofElements(void)
|
||||
{
|
||||
return Tx1_inSize;
|
||||
}
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : Tx1_NofFreeElements (component RingBuffer)
|
||||
** Description :
|
||||
** Returns the actual number of free elements/space in the
|
||||
** buffer.
|
||||
** Parameters : None
|
||||
** Returns :
|
||||
** --- - Number of elements in the buffer.
|
||||
** ===================================================================
|
||||
*/
|
||||
Tx1_BufSizeType Tx1_NofFreeElements(void)
|
||||
{
|
||||
return (Tx1_BufSizeType)(Tx1_BUF_SIZE-Tx1_inSize);
|
||||
}
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : Tx1_Init (component RingBuffer)
|
||||
** Description :
|
||||
** Initializes the data structure
|
||||
** Parameters : None
|
||||
** Returns : Nothing
|
||||
** ===================================================================
|
||||
*/
|
||||
void Tx1_Init(void)
|
||||
{
|
||||
Tx1_inIdx = 0;
|
||||
Tx1_outIdx = 0;
|
||||
Tx1_inSize = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : Tx1_Clear (component RingBuffer)
|
||||
** Description :
|
||||
** Clear (empty) the ring buffer.
|
||||
** Parameters : None
|
||||
** Returns : Nothing
|
||||
** ===================================================================
|
||||
*/
|
||||
void Tx1_Clear(void)
|
||||
{
|
||||
Tx1_DEFINE_CRITICAL();
|
||||
|
||||
Tx1_ENTER_CRITICAL();
|
||||
Tx1_Init();
|
||||
Tx1_EXIT_CRITICAL();
|
||||
}
|
||||
|
||||
/* END Tx1. */
|
||||
|
||||
/*!
|
||||
** @}
|
||||
*/
|
||||
/*
|
||||
** ###################################################################
|
||||
**
|
||||
** This file was created by Processor Expert 10.4 [05.11]
|
||||
** for the Freescale Kinetis series of microcontrollers.
|
||||
**
|
||||
** ###################################################################
|
||||
*/
|
||||
@@ -0,0 +1,167 @@
|
||||
/* ###################################################################
|
||||
** THIS COMPONENT MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.
|
||||
** Filename : Tx1.h
|
||||
** Project : Landungsbruecke_KDS_v2.0.0
|
||||
** Processor : MK20DN512VLL10
|
||||
** Component : RingBuffer
|
||||
** Version : Component 01.025, Driver 01.00, CPU db: 3.00.000
|
||||
** Compiler : GNU C Compiler
|
||||
** Date/Time : 2015-01-09, 16:27, # CodeGen: 0
|
||||
** Abstract :
|
||||
** This component implements a ring buffer for different integer data type.
|
||||
** Settings :
|
||||
** Component name : Tx1
|
||||
** Buffer Size : 1
|
||||
** Contents :
|
||||
** Clear - void Tx1_Clear(void);
|
||||
** Put - byte Tx1_Put(Tx1_ElementType elem);
|
||||
** Get - byte Tx1_Get(Tx1_ElementType *elemP);
|
||||
** NofElements - Tx1_BufSizeType Tx1_NofElements(void);
|
||||
** NofFreeElements - Tx1_BufSizeType Tx1_NofFreeElements(void);
|
||||
** Init - void Tx1_Init(void);
|
||||
**
|
||||
** License : Open Source (LGPL)
|
||||
** Copyright : (c) Copyright Erich Styger, 2014, all rights reserved.
|
||||
** Web: http://www.mcuoneclipse.com
|
||||
** This an open source software of an embedded component for Processor Expert.
|
||||
** This is a free software and is opened for education, research and commercial developments under license policy of following terms:
|
||||
** * This is a free software and there is NO WARRANTY.
|
||||
** * No restriction on use. You can use, modify and redistribute it for personal, non-profit or commercial product UNDER YOUR RESPONSIBILITY.
|
||||
** * Redistributions of source code must retain the above copyright notice.
|
||||
** ###################################################################*/
|
||||
/*!
|
||||
** @file Tx1.h
|
||||
** @version 01.00
|
||||
** @brief
|
||||
** This component implements a ring buffer for different integer data type.
|
||||
*/
|
||||
/*!
|
||||
** @addtogroup Tx1_module Tx1 module documentation
|
||||
** @{
|
||||
*/
|
||||
|
||||
#ifndef __Tx1_H
|
||||
#define __Tx1_H
|
||||
|
||||
/* MODULE Tx1. */
|
||||
|
||||
/* Include shared modules, which are used for whole project */
|
||||
#include "PE_Types.h"
|
||||
#include "PE_Error.h"
|
||||
#include "PE_Const.h"
|
||||
#include "MK20D10.h"
|
||||
/* Include inherited beans */
|
||||
#include "CS1.h"
|
||||
|
||||
//#include "Cpu.h"
|
||||
|
||||
|
||||
#define Tx1_BUF_SIZE 64 /* number of elements in the buffer */
|
||||
#define Tx1_ELEM_SIZE 1 /* size of a single element in bytes */
|
||||
#define Tx1_IS_REENTRANT 0 /* 0: Critical section NOT used for accessing shared data, 1 otherwise */
|
||||
#if Tx1_ELEM_SIZE==1
|
||||
typedef uint8 Tx1_ElementType; /* type of single element */
|
||||
#elif Tx1_ELEM_SIZE==2
|
||||
typedef uint16 Tx1_ElementType; /* type of single element */
|
||||
#elif Tx1_ELEM_SIZE==4
|
||||
typedef uint32 Tx1_ElementType; /* type of single element */
|
||||
#else
|
||||
#error "illegal element type size in properties"
|
||||
#endif
|
||||
#if Tx1_BUF_SIZE<=256
|
||||
typedef uint8 Tx1_BufSizeType; /* up to 256 elements (index 0x00..0xFF) */
|
||||
#else
|
||||
typedef uint16 Tx1_BufSizeType; /* more than 256 elements, up to 2^16 */
|
||||
#endif
|
||||
|
||||
byte Tx1_Put(Tx1_ElementType elem);
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : Tx1_Put (component RingBuffer)
|
||||
** Description :
|
||||
** Puts a new element into the buffer
|
||||
** Parameters :
|
||||
** NAME - DESCRIPTION
|
||||
** elem - New element to be put into the buffer
|
||||
** Returns :
|
||||
** --- - Error code
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
byte Tx1_Get(Tx1_ElementType *elemP);
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : Tx1_Get (component RingBuffer)
|
||||
** Description :
|
||||
** Removes an element from the buffer
|
||||
** Parameters :
|
||||
** NAME - DESCRIPTION
|
||||
** * elemP - Pointer to where to store the received
|
||||
** element
|
||||
** Returns :
|
||||
** --- - Error code
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
Tx1_BufSizeType Tx1_NofElements(void);
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : Tx1_NofElements (component RingBuffer)
|
||||
** Description :
|
||||
** Returns the actual number of elements in the buffer.
|
||||
** Parameters : None
|
||||
** Returns :
|
||||
** --- - Number of elements in the buffer.
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
void Tx1_Init(void);
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : Tx1_Init (component RingBuffer)
|
||||
** Description :
|
||||
** Initializes the data structure
|
||||
** Parameters : None
|
||||
** Returns : Nothing
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
Tx1_BufSizeType Tx1_NofFreeElements(void);
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : Tx1_NofFreeElements (component RingBuffer)
|
||||
** Description :
|
||||
** Returns the actual number of free elements/space in the
|
||||
** buffer.
|
||||
** Parameters : None
|
||||
** Returns :
|
||||
** --- - Number of elements in the buffer.
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
void Tx1_Clear(void);
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : Tx1_Clear (component RingBuffer)
|
||||
** Description :
|
||||
** Clear (empty) the ring buffer.
|
||||
** Parameters : None
|
||||
** Returns : Nothing
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
/* END Tx1. */
|
||||
|
||||
#endif
|
||||
/* ifndef __Tx1_H */
|
||||
/*!
|
||||
** @}
|
||||
*/
|
||||
/*
|
||||
** ###################################################################
|
||||
**
|
||||
** This file was created by Processor Expert 10.4 [05.11]
|
||||
** for the Freescale Kinetis series of microcontrollers.
|
||||
**
|
||||
** ###################################################################
|
||||
*/
|
||||
@@ -0,0 +1,396 @@
|
||||
/* ###################################################################
|
||||
** THIS COMPONENT MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.
|
||||
** Filename : USB0.c
|
||||
** Project : Landungsbruecke_KDS_v2.0.0
|
||||
** Processor : MK20DN512VLL10
|
||||
** Component : Init_USB_OTG
|
||||
** Version : Component 01.004, Driver 01.04, CPU db: 3.00.000
|
||||
** Compiler : GNU C Compiler
|
||||
** Date/Time : 2015-01-09, 16:27, # CodeGen: 0
|
||||
** Abstract :
|
||||
** This file implements the USB_OTG (USB0) module initialization
|
||||
** according to the Peripheral Initialization settings, and
|
||||
** defines interrupt service routines prototypes.
|
||||
** Settings :
|
||||
** Component name : USB0
|
||||
** Device : USB0
|
||||
** Settings :
|
||||
** Clock gate : Enabled
|
||||
** Clock settings :
|
||||
** Clock divider :
|
||||
** Clock divider source : PLL/FLL clock
|
||||
** Clock divider input frequency : 96 MHz
|
||||
** Clock divider fraction : multiply by 1
|
||||
** Clock divider divisor : divide by 2
|
||||
** Module clock source : Clock divider output
|
||||
** Module clock frequency : 48 MHz
|
||||
** Pull-up/pull-down settings :
|
||||
** Weak pulldowns : Enabled
|
||||
** Pull-up/pull-down control : Mode dependent
|
||||
** D+ pull-up : Disabled
|
||||
** D+ pull-down : Disabled
|
||||
** D- pull-down : Disabled
|
||||
** D+ pull-up for non-OTG mode : Disabled
|
||||
** Endpoints :
|
||||
** EP0 : Disabled
|
||||
** Direct low speed : Disabled
|
||||
** Retry : Enabled
|
||||
** Setup transfers : Enabled
|
||||
** Handshake : Disabled
|
||||
** Rx transfer : Disabled
|
||||
** Tx transfer : Disabled
|
||||
** Force stall : Disabled
|
||||
** EP1 : Disabled
|
||||
** Setup transfers : Enabled
|
||||
** Handshake : Disabled
|
||||
** Rx transfer : Disabled
|
||||
** Tx transfer : Disabled
|
||||
** Force stall : Disabled
|
||||
** EP2 : Disabled
|
||||
** Setup transfers : Enabled
|
||||
** Handshake : Disabled
|
||||
** Rx transfer : Disabled
|
||||
** Tx transfer : Disabled
|
||||
** Force stall : Disabled
|
||||
** EP3 : Disabled
|
||||
** Setup transfers : Enabled
|
||||
** Handshake : Disabled
|
||||
** Rx transfer : Disabled
|
||||
** Tx transfer : Disabled
|
||||
** Force stall : Disabled
|
||||
** EP4 : Disabled
|
||||
** Setup transfers : Enabled
|
||||
** Handshake : Disabled
|
||||
** Rx transfer : Disabled
|
||||
** Tx transfer : Disabled
|
||||
** Force stall : Disabled
|
||||
** EP5 : Disabled
|
||||
** Setup transfers : Enabled
|
||||
** Handshake : Disabled
|
||||
** Rx transfer : Disabled
|
||||
** Tx transfer : Disabled
|
||||
** Force stall : Disabled
|
||||
** EP6 : Disabled
|
||||
** Setup transfers : Enabled
|
||||
** Handshake : Disabled
|
||||
** Rx transfer : Disabled
|
||||
** Tx transfer : Disabled
|
||||
** Force stall : Disabled
|
||||
** EP7 : Disabled
|
||||
** Setup transfers : Enabled
|
||||
** Handshake : Disabled
|
||||
** Rx transfer : Disabled
|
||||
** Tx transfer : Disabled
|
||||
** Force stall : Disabled
|
||||
** EP8 : Disabled
|
||||
** Setup transfers : Enabled
|
||||
** Handshake : Disabled
|
||||
** Rx transfer : Disabled
|
||||
** Tx transfer : Disabled
|
||||
** Force stall : Disabled
|
||||
** EP9 : Disabled
|
||||
** Setup transfers : Enabled
|
||||
** Handshake : Disabled
|
||||
** Rx transfer : Disabled
|
||||
** Tx transfer : Disabled
|
||||
** Force stall : Disabled
|
||||
** EP10 : Disabled
|
||||
** Setup transfers : Enabled
|
||||
** Handshake : Disabled
|
||||
** Rx transfer : Disabled
|
||||
** Tx transfer : Disabled
|
||||
** Force stall : Disabled
|
||||
** EP11 : Disabled
|
||||
** Setup transfers : Enabled
|
||||
** Handshake : Disabled
|
||||
** Rx transfer : Disabled
|
||||
** Tx transfer : Disabled
|
||||
** Force stall : Disabled
|
||||
** EP12 : Disabled
|
||||
** Setup transfers : Enabled
|
||||
** Handshake : Disabled
|
||||
** Rx transfer : Disabled
|
||||
** Tx transfer : Disabled
|
||||
** Force stall : Disabled
|
||||
** EP13 : Disabled
|
||||
** Setup transfers : Enabled
|
||||
** Handshake : Disabled
|
||||
** Rx transfer : Disabled
|
||||
** Tx transfer : Disabled
|
||||
** Force stall : Disabled
|
||||
** EP14 : Disabled
|
||||
** Setup transfers : Enabled
|
||||
** Handshake : Disabled
|
||||
** Rx transfer : Disabled
|
||||
** Tx transfer : Disabled
|
||||
** Force stall : Disabled
|
||||
** EP15 : Disabled
|
||||
** Setup transfers : Enabled
|
||||
** Handshake : Disabled
|
||||
** Rx transfer : Disabled
|
||||
** Tx transfer : Disabled
|
||||
** Force stall : Disabled
|
||||
** Buffer descriptor table :
|
||||
** External object declaration : extern uint8 g_Mem[];
|
||||
** Address : ((uint32)&g_Mem[0])
|
||||
** SOF threshold : 0
|
||||
** Pins :
|
||||
** Alternate clock source : Disabled
|
||||
** SOF output : Disabled
|
||||
** Data plus : Enabled
|
||||
** Pin : USB0_DP
|
||||
** Pin signal :
|
||||
** Data minus : Enabled
|
||||
** Pin : USB0_DM
|
||||
** Pin signal :
|
||||
** Interrupts :
|
||||
** USB :
|
||||
** Interrupt : INT_USB0
|
||||
** Interrupt request : Disabled
|
||||
** Interrupt priority : 0 (Highest)
|
||||
** ISR Name : USB_ISR
|
||||
** Stall : Enabled
|
||||
** Attach : Enabled
|
||||
** Resume : Enabled
|
||||
** Sleep : Enabled
|
||||
** Token OK : Enabled
|
||||
** Start of frame : Enabled
|
||||
** Error interrupt : Enabled
|
||||
** USB reset : Enabled
|
||||
** Asynchronous Resume interrupt : Enabled
|
||||
** Error interrupts :
|
||||
** Bit stuff error : Disabled
|
||||
** DMA error : Disabled
|
||||
** Bus turnaround timeout : Disabled
|
||||
** Data length error : Disabled
|
||||
** CRC16 error : Disabled
|
||||
** CRC5 or EOF : Disabled
|
||||
** PID error : Disabled
|
||||
** OTG interrupts :
|
||||
** ID pin changed : Disabled
|
||||
** 1 ms interrupt : Disabled
|
||||
** Line stage change : Disabled
|
||||
** Session valid : Disabled
|
||||
** "B" session end : Disabled
|
||||
** "A" bus valid : Disabled
|
||||
** Initialization :
|
||||
** Mode : Device
|
||||
** USB transceiver suspend state : Enabled
|
||||
** Call Init method : yes
|
||||
** Contents :
|
||||
** Init - void USB0_Init(void);
|
||||
**
|
||||
** Copyright : 1997 - 2014 Freescale Semiconductor, Inc.
|
||||
** All Rights Reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without modification,
|
||||
** are permitted provided that the following conditions are met:
|
||||
**
|
||||
** o Redistributions of source code must retain the above copyright notice, this list
|
||||
** of conditions and the following disclaimer.
|
||||
**
|
||||
** o Redistributions in binary form must reproduce the above copyright notice, this
|
||||
** list of conditions and the following disclaimer in the documentation and/or
|
||||
** other materials provided with the distribution.
|
||||
**
|
||||
** o Neither the name of Freescale Semiconductor, Inc. nor the names of its
|
||||
** contributors may be used to endorse or promote products derived from this
|
||||
** software without specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
** ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
** ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
**
|
||||
** http: www.freescale.com
|
||||
** mail: support@freescale.com
|
||||
** ###################################################################*/
|
||||
/*!
|
||||
** @file USB0.c
|
||||
** @version 01.04
|
||||
** @brief
|
||||
** This file implements the USB_OTG (USB0) module initialization
|
||||
** according to the Peripheral Initialization settings, and
|
||||
** defines interrupt service routines prototypes.
|
||||
*/
|
||||
/*!
|
||||
** @addtogroup USB0_module USB0 module documentation
|
||||
** @{
|
||||
*/
|
||||
|
||||
/* MODULE USB0. */
|
||||
|
||||
#include "USB0.h"
|
||||
/* Including shared modules, which are used in the whole project */
|
||||
#include "PE_Types.h"
|
||||
#include "PE_Error.h"
|
||||
#include "PE_Const.h"
|
||||
#include "hal/derivative.h"
|
||||
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : USB0_Init (component Init_USB_OTG)
|
||||
** Description :
|
||||
** This method initializes registers of the USB_OTG module
|
||||
** according to the Peripheral Initialization settings.
|
||||
** Call this method in user code to initialize the module. By
|
||||
** default, the method is called by PE automatically; see "Call
|
||||
** Init method" property of the component for more details.
|
||||
** Parameters : None
|
||||
** Returns : Nothing
|
||||
** ===================================================================
|
||||
*/
|
||||
extern uint8 g_Mem[];
|
||||
void USB0_Init(void)
|
||||
{
|
||||
/* SIM_CLKDIV2: USBDIV=1,USBFRAC=0 */
|
||||
SIM_CLKDIV2 = (uint32)((SIM_CLKDIV2 & (uint32)~(uint32)(
|
||||
SIM_CLKDIV2_USBDIV(0x06) |
|
||||
SIM_CLKDIV2_USBFRAC_MASK
|
||||
)) | (uint32)(
|
||||
SIM_CLKDIV2_USBDIV(0x01)
|
||||
));
|
||||
/* SIM_SOPT2: USBSRC=1 */
|
||||
SIM_SOPT2 |= SIM_SOPT2_USBSRC_MASK;
|
||||
/* SIM_SCGC4: USBOTG=1 */
|
||||
SIM_SCGC4 |= SIM_SCGC4_USBOTG_MASK;
|
||||
/* USB0_CTL: ODDRST=1 */
|
||||
USB0_CTL |= USB_CTL_ODDRST_MASK;
|
||||
/* USB0_USBCTRL: SUSP=1,PDE=1,??=0,??=0,??=0,??=0,??=0,??=0 */
|
||||
USB0_USBCTRL = (USB_USBCTRL_SUSP_MASK | USB_USBCTRL_PDE_MASK);
|
||||
/* USB0_OTGISTAT: IDCHG=1,ONEMSEC=1,LINE_STATE_CHG=1,??=1,SESSVLDCHG=1,B_SESS_CHG=1,??=1,AVBUSCHG=1 */
|
||||
USB0_OTGISTAT = USB_OTGISTAT_IDCHG_MASK |
|
||||
USB_OTGISTAT_ONEMSEC_MASK |
|
||||
USB_OTGISTAT_LINE_STATE_CHG_MASK |
|
||||
USB_OTGISTAT_SESSVLDCHG_MASK |
|
||||
USB_OTGISTAT_B_SESS_CHG_MASK |
|
||||
USB_OTGISTAT_AVBUSCHG_MASK |
|
||||
0x12U;
|
||||
/* USB0_ISTAT: STALL=1,ATTACH=1,RESUME=1,SLEEP=1,TOKDNE=1,SOFTOK=1,ERROR=1,USBRST=1 */
|
||||
USB0_ISTAT = USB_ISTAT_STALL_MASK |
|
||||
USB_ISTAT_ATTACH_MASK |
|
||||
USB_ISTAT_RESUME_MASK |
|
||||
USB_ISTAT_SLEEP_MASK |
|
||||
USB_ISTAT_TOKDNE_MASK |
|
||||
USB_ISTAT_SOFTOK_MASK |
|
||||
USB_ISTAT_ERROR_MASK |
|
||||
USB_ISTAT_USBRST_MASK;
|
||||
/* USB0_ERRSTAT: BTSERR=1,??=1,DMAERR=1,BTOERR=1,DFN8=1,CRC16=1,CRC5EOF=1,PIDERR=1 */
|
||||
USB0_ERRSTAT = USB_ERRSTAT_BTSERR_MASK |
|
||||
USB_ERRSTAT_DMAERR_MASK |
|
||||
USB_ERRSTAT_BTOERR_MASK |
|
||||
USB_ERRSTAT_DFN8_MASK |
|
||||
USB_ERRSTAT_CRC16_MASK |
|
||||
USB_ERRSTAT_CRC5EOF_MASK |
|
||||
USB_ERRSTAT_PIDERR_MASK |
|
||||
0x40U;
|
||||
/* USB0_INTEN: STALLEN=1,ATTACHEN=1,RESUMEEN=1,SLEEPEN=1,TOKDNEEN=1,SOFTOKEN=1,ERROREN=1,USBRSTEN=1 */
|
||||
USB0_INTEN = USB_INTEN_STALLEN_MASK |
|
||||
USB_INTEN_ATTACHEN_MASK |
|
||||
USB_INTEN_RESUMEEN_MASK |
|
||||
USB_INTEN_SLEEPEN_MASK |
|
||||
USB_INTEN_TOKDNEEN_MASK |
|
||||
USB_INTEN_SOFTOKEN_MASK |
|
||||
USB_INTEN_ERROREN_MASK |
|
||||
USB_INTEN_USBRSTEN_MASK;
|
||||
/* USB0_ERREN: BTSERREN=0,??=0,DMAERREN=0,BTOERREN=0,DFN8EN=0,CRC16EN=0,CRC5EOFEN=0,PIDERREN=0 */
|
||||
USB0_ERREN = 0x00U;
|
||||
/* USB0_USBTRC0: USBRESET=0,??=1,USBRESMEN=1,??=0,??=0,??=0,SYNC_DET=0,USB_RESUME_INT=0 */
|
||||
USB0_USBTRC0 = (USB_USBTRC0_USBRESMEN_MASK | 0x40U);
|
||||
/* USB0_OTGICR: IDEN=0,ONEMSECEN=0,LINESTATEEN=0,??=0,SESSVLDEN=0,BSESSEN=0,??=0,AVBUSEN=0 */
|
||||
USB0_OTGICR = 0x00U;
|
||||
/* USB0_ADDR: LSEN=0,ADDR=0 */
|
||||
USB0_ADDR = USB_ADDR_ADDR(0x00);
|
||||
/* USB0_ENDPT0: HOSTWOHUB=0,RETRYDIS=0,??=0,EPCTLDIS=0,EPRXEN=0,EPTXEN=0,EPSTALL=0,EPHSHK=0 */
|
||||
USB0_ENDPT0 = 0x00U;
|
||||
/* USB0_ENDPT1: HOSTWOHUB=0,RETRYDIS=0,??=0,EPCTLDIS=0,EPRXEN=0,EPTXEN=0,EPSTALL=0,EPHSHK=0 */
|
||||
USB0_ENDPT1 = 0x00U;
|
||||
/* USB0_ENDPT2: HOSTWOHUB=0,RETRYDIS=0,??=0,EPCTLDIS=0,EPRXEN=0,EPTXEN=0,EPSTALL=0,EPHSHK=0 */
|
||||
USB0_ENDPT2 = 0x00U;
|
||||
/* USB0_ENDPT3: HOSTWOHUB=0,RETRYDIS=0,??=0,EPCTLDIS=0,EPRXEN=0,EPTXEN=0,EPSTALL=0,EPHSHK=0 */
|
||||
USB0_ENDPT3 = 0x00U;
|
||||
/* USB0_ENDPT4: HOSTWOHUB=0,RETRYDIS=0,??=0,EPCTLDIS=0,EPRXEN=0,EPTXEN=0,EPSTALL=0,EPHSHK=0 */
|
||||
USB0_ENDPT4 = 0x00U;
|
||||
/* USB0_ENDPT5: HOSTWOHUB=0,RETRYDIS=0,??=0,EPCTLDIS=0,EPRXEN=0,EPTXEN=0,EPSTALL=0,EPHSHK=0 */
|
||||
USB0_ENDPT5 = 0x00U;
|
||||
/* USB0_ENDPT6: HOSTWOHUB=0,RETRYDIS=0,??=0,EPCTLDIS=0,EPRXEN=0,EPTXEN=0,EPSTALL=0,EPHSHK=0 */
|
||||
USB0_ENDPT6 = 0x00U;
|
||||
/* USB0_ENDPT7: HOSTWOHUB=0,RETRYDIS=0,??=0,EPCTLDIS=0,EPRXEN=0,EPTXEN=0,EPSTALL=0,EPHSHK=0 */
|
||||
USB0_ENDPT7 = 0x00U;
|
||||
/* USB0_ENDPT8: HOSTWOHUB=0,RETRYDIS=0,??=0,EPCTLDIS=0,EPRXEN=0,EPTXEN=0,EPSTALL=0,EPHSHK=0 */
|
||||
USB0_ENDPT8 = 0x00U;
|
||||
/* USB0_ENDPT9: HOSTWOHUB=0,RETRYDIS=0,??=0,EPCTLDIS=0,EPRXEN=0,EPTXEN=0,EPSTALL=0,EPHSHK=0 */
|
||||
USB0_ENDPT9 = 0x00U;
|
||||
/* USB0_ENDPT10: HOSTWOHUB=0,RETRYDIS=0,??=0,EPCTLDIS=0,EPRXEN=0,EPTXEN=0,EPSTALL=0,EPHSHK=0 */
|
||||
USB0_ENDPT10 = 0x00U;
|
||||
/* USB0_ENDPT11: HOSTWOHUB=0,RETRYDIS=0,??=0,EPCTLDIS=0,EPRXEN=0,EPTXEN=0,EPSTALL=0,EPHSHK=0 */
|
||||
USB0_ENDPT11 = 0x00U;
|
||||
/* USB0_ENDPT12: HOSTWOHUB=0,RETRYDIS=0,??=0,EPCTLDIS=0,EPRXEN=0,EPTXEN=0,EPSTALL=0,EPHSHK=0 */
|
||||
USB0_ENDPT12 = 0x00U;
|
||||
/* USB0_ENDPT13: HOSTWOHUB=0,RETRYDIS=0,??=0,EPCTLDIS=0,EPRXEN=0,EPTXEN=0,EPSTALL=0,EPHSHK=0 */
|
||||
USB0_ENDPT13 = 0x00U;
|
||||
/* USB0_ENDPT14: HOSTWOHUB=0,RETRYDIS=0,??=0,EPCTLDIS=0,EPRXEN=0,EPTXEN=0,EPSTALL=0,EPHSHK=0 */
|
||||
USB0_ENDPT14 = 0x00U;
|
||||
/* USB0_ENDPT15: HOSTWOHUB=0,RETRYDIS=0,??=0,EPCTLDIS=0,EPRXEN=0,EPTXEN=0,EPSTALL=0,EPHSHK=0 */
|
||||
USB0_ENDPT15 = 0x00U;
|
||||
USB0_BDTPAGE1 = (uint8)((((uint32)((uint32)&g_Mem[0])) >> 0x08) & 0xFEU);
|
||||
USB0_BDTPAGE2 = (uint8)((((uint32)((uint32)&g_Mem[0])) >> 0x10) & 0xFFU);
|
||||
USB0_BDTPAGE3 = (uint8)((((uint32)((uint32)&g_Mem[0])) >> 0x18) & 0xFFU);
|
||||
/* USB0_SOFTHLD: CNT=0 */
|
||||
USB0_SOFTHLD = USB_SOFTHLD_CNT(0x00);
|
||||
/* USB0_OTGCTL: DPHIGH=0,??=0,DPLOW=0,DMLOW=0,??=0,OTGEN=0,??=0,??=0 */
|
||||
USB0_OTGCTL = 0x00U;
|
||||
/* USB0_CONTROL: ??=0,??=0,??=0,DPPULLUPNONOTG=0,??=0,??=0,??=0,??=0 */
|
||||
USB0_CONTROL = 0x00U;
|
||||
/* USB0_CTL: TXSUSPENDTOKENBUSY=0,HOSTMODEEN=0,ODDRST=0,USBENSOFEN=1 */
|
||||
USB0_CTL = (uint8)((USB0_CTL & (uint8)~(uint8)(
|
||||
USB_CTL_TXSUSPENDTOKENBUSY_MASK |
|
||||
USB_CTL_HOSTMODEEN_MASK |
|
||||
USB_CTL_ODDRST_MASK
|
||||
)) | (uint8)(
|
||||
USB_CTL_USBENSOFEN_MASK
|
||||
));
|
||||
}
|
||||
|
||||
/*
|
||||
** ###################################################################
|
||||
**
|
||||
** The interrupt service routine(s) must be implemented
|
||||
** by user in one of the following user modules.
|
||||
**
|
||||
** If the "Generate ISR" option is enabled, Processor Expert generates
|
||||
** ISR templates in the CPU event module.
|
||||
**
|
||||
** User modules:
|
||||
** main.c
|
||||
** Events.c
|
||||
**
|
||||
** ###################################################################
|
||||
PE_ISR(USB_ISR)
|
||||
{
|
||||
// NOTE: The routine should include actions to clear the appropriate
|
||||
// interrupt flags.
|
||||
//
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/* END USB0. */
|
||||
/*!
|
||||
** @}
|
||||
*/
|
||||
/*
|
||||
** ###################################################################
|
||||
**
|
||||
** This file was created by Processor Expert 10.4 [05.11]
|
||||
** for the Freescale Kinetis series of microcontrollers.
|
||||
**
|
||||
** ###################################################################
|
||||
*/
|
||||
@@ -0,0 +1,279 @@
|
||||
/* ###################################################################
|
||||
** THIS COMPONENT MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.
|
||||
** Filename : USB0.h
|
||||
** Project : Landungsbruecke_KDS_v2.0.0
|
||||
** Processor : MK20DN512VLL10
|
||||
** Component : Init_USB_OTG
|
||||
** Version : Component 01.004, Driver 01.04, CPU db: 3.00.000
|
||||
** Compiler : GNU C Compiler
|
||||
** Date/Time : 2015-01-09, 16:27, # CodeGen: 0
|
||||
** Abstract :
|
||||
** This file implements the USB_OTG (USB0) module initialization
|
||||
** according to the Peripheral Initialization settings, and
|
||||
** defines interrupt service routines prototypes.
|
||||
** Settings :
|
||||
** Component name : USB0
|
||||
** Device : USB0
|
||||
** Settings :
|
||||
** Clock gate : Enabled
|
||||
** Clock settings :
|
||||
** Clock divider :
|
||||
** Clock divider source : PLL/FLL clock
|
||||
** Clock divider input frequency : 96 MHz
|
||||
** Clock divider fraction : multiply by 1
|
||||
** Clock divider divisor : divide by 2
|
||||
** Module clock source : Clock divider output
|
||||
** Module clock frequency : 48 MHz
|
||||
** Pull-up/pull-down settings :
|
||||
** Weak pulldowns : Enabled
|
||||
** Pull-up/pull-down control : Mode dependent
|
||||
** D+ pull-up : Disabled
|
||||
** D+ pull-down : Disabled
|
||||
** D- pull-down : Disabled
|
||||
** D+ pull-up for non-OTG mode : Disabled
|
||||
** Endpoints :
|
||||
** EP0 : Disabled
|
||||
** Direct low speed : Disabled
|
||||
** Retry : Enabled
|
||||
** Setup transfers : Enabled
|
||||
** Handshake : Disabled
|
||||
** Rx transfer : Disabled
|
||||
** Tx transfer : Disabled
|
||||
** Force stall : Disabled
|
||||
** EP1 : Disabled
|
||||
** Setup transfers : Enabled
|
||||
** Handshake : Disabled
|
||||
** Rx transfer : Disabled
|
||||
** Tx transfer : Disabled
|
||||
** Force stall : Disabled
|
||||
** EP2 : Disabled
|
||||
** Setup transfers : Enabled
|
||||
** Handshake : Disabled
|
||||
** Rx transfer : Disabled
|
||||
** Tx transfer : Disabled
|
||||
** Force stall : Disabled
|
||||
** EP3 : Disabled
|
||||
** Setup transfers : Enabled
|
||||
** Handshake : Disabled
|
||||
** Rx transfer : Disabled
|
||||
** Tx transfer : Disabled
|
||||
** Force stall : Disabled
|
||||
** EP4 : Disabled
|
||||
** Setup transfers : Enabled
|
||||
** Handshake : Disabled
|
||||
** Rx transfer : Disabled
|
||||
** Tx transfer : Disabled
|
||||
** Force stall : Disabled
|
||||
** EP5 : Disabled
|
||||
** Setup transfers : Enabled
|
||||
** Handshake : Disabled
|
||||
** Rx transfer : Disabled
|
||||
** Tx transfer : Disabled
|
||||
** Force stall : Disabled
|
||||
** EP6 : Disabled
|
||||
** Setup transfers : Enabled
|
||||
** Handshake : Disabled
|
||||
** Rx transfer : Disabled
|
||||
** Tx transfer : Disabled
|
||||
** Force stall : Disabled
|
||||
** EP7 : Disabled
|
||||
** Setup transfers : Enabled
|
||||
** Handshake : Disabled
|
||||
** Rx transfer : Disabled
|
||||
** Tx transfer : Disabled
|
||||
** Force stall : Disabled
|
||||
** EP8 : Disabled
|
||||
** Setup transfers : Enabled
|
||||
** Handshake : Disabled
|
||||
** Rx transfer : Disabled
|
||||
** Tx transfer : Disabled
|
||||
** Force stall : Disabled
|
||||
** EP9 : Disabled
|
||||
** Setup transfers : Enabled
|
||||
** Handshake : Disabled
|
||||
** Rx transfer : Disabled
|
||||
** Tx transfer : Disabled
|
||||
** Force stall : Disabled
|
||||
** EP10 : Disabled
|
||||
** Setup transfers : Enabled
|
||||
** Handshake : Disabled
|
||||
** Rx transfer : Disabled
|
||||
** Tx transfer : Disabled
|
||||
** Force stall : Disabled
|
||||
** EP11 : Disabled
|
||||
** Setup transfers : Enabled
|
||||
** Handshake : Disabled
|
||||
** Rx transfer : Disabled
|
||||
** Tx transfer : Disabled
|
||||
** Force stall : Disabled
|
||||
** EP12 : Disabled
|
||||
** Setup transfers : Enabled
|
||||
** Handshake : Disabled
|
||||
** Rx transfer : Disabled
|
||||
** Tx transfer : Disabled
|
||||
** Force stall : Disabled
|
||||
** EP13 : Disabled
|
||||
** Setup transfers : Enabled
|
||||
** Handshake : Disabled
|
||||
** Rx transfer : Disabled
|
||||
** Tx transfer : Disabled
|
||||
** Force stall : Disabled
|
||||
** EP14 : Disabled
|
||||
** Setup transfers : Enabled
|
||||
** Handshake : Disabled
|
||||
** Rx transfer : Disabled
|
||||
** Tx transfer : Disabled
|
||||
** Force stall : Disabled
|
||||
** EP15 : Disabled
|
||||
** Setup transfers : Enabled
|
||||
** Handshake : Disabled
|
||||
** Rx transfer : Disabled
|
||||
** Tx transfer : Disabled
|
||||
** Force stall : Disabled
|
||||
** Buffer descriptor table :
|
||||
** External object declaration : extern uint8 g_Mem[];
|
||||
** Address : ((uint32)&g_Mem[0])
|
||||
** SOF threshold : 0
|
||||
** Pins :
|
||||
** Alternate clock source : Disabled
|
||||
** SOF output : Disabled
|
||||
** Data plus : Enabled
|
||||
** Pin : USB0_DP
|
||||
** Pin signal :
|
||||
** Data minus : Enabled
|
||||
** Pin : USB0_DM
|
||||
** Pin signal :
|
||||
** Interrupts :
|
||||
** USB :
|
||||
** Interrupt : INT_USB0
|
||||
** Interrupt request : Disabled
|
||||
** Interrupt priority : 0 (Highest)
|
||||
** ISR Name : USB_ISR
|
||||
** Stall : Enabled
|
||||
** Attach : Enabled
|
||||
** Resume : Enabled
|
||||
** Sleep : Enabled
|
||||
** Token OK : Enabled
|
||||
** Start of frame : Enabled
|
||||
** Error interrupt : Enabled
|
||||
** USB reset : Enabled
|
||||
** Asynchronous Resume interrupt : Enabled
|
||||
** Error interrupts :
|
||||
** Bit stuff error : Disabled
|
||||
** DMA error : Disabled
|
||||
** Bus turnaround timeout : Disabled
|
||||
** Data length error : Disabled
|
||||
** CRC16 error : Disabled
|
||||
** CRC5 or EOF : Disabled
|
||||
** PID error : Disabled
|
||||
** OTG interrupts :
|
||||
** ID pin changed : Disabled
|
||||
** 1 ms interrupt : Disabled
|
||||
** Line stage change : Disabled
|
||||
** Session valid : Disabled
|
||||
** "B" session end : Disabled
|
||||
** "A" bus valid : Disabled
|
||||
** Initialization :
|
||||
** Mode : Device
|
||||
** USB transceiver suspend state : Enabled
|
||||
** Call Init method : yes
|
||||
** Contents :
|
||||
** Init - void USB0_Init(void);
|
||||
**
|
||||
** Copyright : 1997 - 2014 Freescale Semiconductor, Inc.
|
||||
** All Rights Reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without modification,
|
||||
** are permitted provided that the following conditions are met:
|
||||
**
|
||||
** o Redistributions of source code must retain the above copyright notice, this list
|
||||
** of conditions and the following disclaimer.
|
||||
**
|
||||
** o Redistributions in binary form must reproduce the above copyright notice, this
|
||||
** list of conditions and the following disclaimer in the documentation and/or
|
||||
** other materials provided with the distribution.
|
||||
**
|
||||
** o Neither the name of Freescale Semiconductor, Inc. nor the names of its
|
||||
** contributors may be used to endorse or promote products derived from this
|
||||
** software without specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
** ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
** ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
**
|
||||
** http: www.freescale.com
|
||||
** mail: support@freescale.com
|
||||
** ###################################################################*/
|
||||
/*!
|
||||
** @file USB0.h
|
||||
** @version 01.04
|
||||
** @brief
|
||||
** This file implements the USB_OTG (USB0) module initialization
|
||||
** according to the Peripheral Initialization settings, and
|
||||
** defines interrupt service routines prototypes.
|
||||
*/
|
||||
/*!
|
||||
** @addtogroup USB0_module USB0 module documentation
|
||||
** @{
|
||||
*/
|
||||
|
||||
#ifndef USB0_H_
|
||||
#define USB0_H_
|
||||
|
||||
/* MODULE USB0. */
|
||||
|
||||
/* Including shared modules, which are used in the whole project */
|
||||
#include "PE_Types.h"
|
||||
#include "PE_Error.h"
|
||||
#include "PE_Const.h"
|
||||
#include "MK20D10.h"
|
||||
//#include "Cpu.h"
|
||||
|
||||
/* Peripheral base address parameter */
|
||||
#define USB0_DEVICE USB0_BASE_PTR
|
||||
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : USB0_Init (component Init_USB_OTG)
|
||||
** Description :
|
||||
** This method initializes registers of the USB_OTG module
|
||||
** according to the Peripheral Initialization settings.
|
||||
** Call this method in user code to initialize the module. By
|
||||
** default, the method is called by PE automatically; see "Call
|
||||
** Init method" property of the component for more details.
|
||||
** Parameters : None
|
||||
** Returns : Nothing
|
||||
** ===================================================================
|
||||
*/
|
||||
void USB0_Init(void);
|
||||
/*
|
||||
** ===================================================================
|
||||
** The interrupt service routine must be implemented by user in one
|
||||
** of the user modules (see USB0.c file for more information).
|
||||
** ===================================================================
|
||||
*/
|
||||
//PE_ISR(USB_ISR);
|
||||
void __attribute((interrupt)) USB_ISR(void);
|
||||
|
||||
|
||||
/* END USB0. */
|
||||
#endif /* #ifndef __USB0_H_ */
|
||||
/*!
|
||||
** @}
|
||||
*/
|
||||
/*
|
||||
** ###################################################################
|
||||
**
|
||||
** This file was created by Processor Expert 10.4 [05.11]
|
||||
** for the Freescale Kinetis series of microcontrollers.
|
||||
**
|
||||
** ###################################################################
|
||||
*/
|
||||
@@ -0,0 +1,112 @@
|
||||
/* ###################################################################
|
||||
** THIS COMPONENT MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.
|
||||
** Filename : USB1.c
|
||||
** Project : Landungsbruecke_KDS_v2.0.0
|
||||
** Processor : MK20DN512VLL10
|
||||
** Component : FSL_USB_Stack
|
||||
** Version : Component 01.025, Driver 01.00, CPU db: 3.00.000
|
||||
** Compiler : GNU C Compiler
|
||||
** Date/Time : 2015-01-09, 16:27, # CodeGen: 0
|
||||
** Abstract :
|
||||
** This component implements a wrapper to the FSL USB Stack.
|
||||
** Settings :
|
||||
** Component name : USB1
|
||||
** Freescale USB Stack Version : v4.1.1
|
||||
** USB : Init_USB_OTG_VAR0
|
||||
** Device Class : CDC Device
|
||||
** CDC Device : Enabled
|
||||
** CDCDevice : FSL_USB_CDC_Device
|
||||
** HID Keyboard Device : Disabled
|
||||
** MSD Host : Disabled
|
||||
** Call Init Method : yes
|
||||
** Contents :
|
||||
** Init - byte USB1_Init(void);
|
||||
**
|
||||
** (c) Copyright Freescale, all rights reserved, 2013-2014.
|
||||
** Ported as Processor Expert component: Erich Styger
|
||||
** http: www.mcuoneclipse.com
|
||||
** ###################################################################*/
|
||||
/*!
|
||||
** @file USB1.c
|
||||
** @version 01.00
|
||||
** @brief
|
||||
** This component implements a wrapper to the FSL USB Stack.
|
||||
*/
|
||||
/*!
|
||||
** @addtogroup USB1_module USB1 module documentation
|
||||
** @{
|
||||
*/
|
||||
|
||||
/* MODULE USB1. */
|
||||
|
||||
#include "USB1.h"
|
||||
#include "hal/derivative.h" /* include peripheral declarations */
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : USB1_usb_int_dis (component FSL_USB_Stack)
|
||||
**
|
||||
** Description :
|
||||
** Disables USB interrupts (if supported)
|
||||
** This method is internal. It is used by Processor Expert only.
|
||||
** ===================================================================
|
||||
*/
|
||||
void USB1_usb_int_dis(void)
|
||||
{
|
||||
/* Kinetis K20D72 */
|
||||
NVICISER1 = (1<<9); /* Disable interrupts from USB module (Interrupt Clear-Enable Register) */
|
||||
}
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : USB1_usb_int_en (component FSL_USB_Stack)
|
||||
**
|
||||
** Description :
|
||||
** Enables USB interrupts (if supported).
|
||||
** This method is internal. It is used by Processor Expert only.
|
||||
** ===================================================================
|
||||
*/
|
||||
void USB1_usb_int_en(void)
|
||||
{
|
||||
/* Kinetis K20D72 */
|
||||
NVICICPR2 = (1<<9); /* Clear any pending interrupts on USB (Interrupt Clear-Pending Register) */
|
||||
NVICISER2 = (1<<9); /* Enable interrupts from USB module (Interrupt Set-Enable Register) */
|
||||
}
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : USB1_Init (component FSL_USB_Stack)
|
||||
** Description :
|
||||
** Initializes the driver
|
||||
** Parameters : None
|
||||
** Returns :
|
||||
** --- - Error code
|
||||
** ===================================================================
|
||||
*/
|
||||
byte USB1_Init(void)
|
||||
{
|
||||
byte err;
|
||||
|
||||
/* Initialize the USB interface */
|
||||
err = CDC1_Init();
|
||||
if(err != ERR_OK) {
|
||||
/* Error initializing USB Class */
|
||||
return ERR_FAILED;
|
||||
}
|
||||
USB1_usb_int_en();
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
/* END USB1. */
|
||||
|
||||
/*!
|
||||
** @}
|
||||
*/
|
||||
/*
|
||||
** ###################################################################
|
||||
**
|
||||
** This file was created by Processor Expert 10.4 [05.11]
|
||||
** for the Freescale Kinetis series of microcontrollers.
|
||||
**
|
||||
** ###################################################################
|
||||
*/
|
||||
@@ -0,0 +1,132 @@
|
||||
/* ###################################################################
|
||||
** THIS COMPONENT MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.
|
||||
** Filename : USB1.h
|
||||
** Project : Landungsbruecke_KDS_v2.0.0
|
||||
** Processor : MK20DN512VLL10
|
||||
** Component : FSL_USB_Stack
|
||||
** Version : Component 01.025, Driver 01.00, CPU db: 3.00.000
|
||||
** Compiler : GNU C Compiler
|
||||
** Date/Time : 2015-01-09, 16:27, # CodeGen: 0
|
||||
** Abstract :
|
||||
** This component implements a wrapper to the FSL USB Stack.
|
||||
** Settings :
|
||||
** Component name : USB1
|
||||
** Freescale USB Stack Version : v4.1.1
|
||||
** USB : Init_USB_OTG_VAR0
|
||||
** Device Class : CDC Device
|
||||
** CDC Device : Enabled
|
||||
** CDCDevice : FSL_USB_CDC_Device
|
||||
** HID Keyboard Device : Disabled
|
||||
** MSD Host : Disabled
|
||||
** Call Init Method : yes
|
||||
** Contents :
|
||||
** Init - byte USB1_Init(void);
|
||||
**
|
||||
** (c) Copyright Freescale, all rights reserved, 2013-2014.
|
||||
** Ported as Processor Expert component: Erich Styger
|
||||
** http: www.mcuoneclipse.com
|
||||
** ###################################################################*/
|
||||
/*!
|
||||
** @file USB1.h
|
||||
** @version 01.00
|
||||
** @brief
|
||||
** This component implements a wrapper to the FSL USB Stack.
|
||||
*/
|
||||
/*!
|
||||
** @addtogroup USB1_module USB1 module documentation
|
||||
** @{
|
||||
*/
|
||||
|
||||
#ifndef __USB1_H
|
||||
#define __USB1_H
|
||||
|
||||
/* MODULE USB1. */
|
||||
|
||||
/* Include shared modules, which are used for whole project */
|
||||
#include "PE_Types.h"
|
||||
#include "PE_Error.h"
|
||||
#include "PE_Const.h"
|
||||
#include "MK20D10.h"
|
||||
/* Include inherited beans */
|
||||
#include "USB0.h"
|
||||
#include "CDC1.h"
|
||||
#include <stddef.h> /* for size_t */
|
||||
|
||||
/* Interfaces/wrappers to the CDC device class, needed by FSShell: */
|
||||
#define USB1_SendString(str) CDC1_SendString(str)
|
||||
#define USB1_RecvChar(chr) CDC1_GetChar(chr)
|
||||
#define USB1_SendChar(chr) CDC1_SendChar(chr)
|
||||
#define USB1_GetCharsInRxBuf() CDC1_GetCharsInRxBuf()
|
||||
|
||||
//#include "Cpu.h"
|
||||
|
||||
|
||||
#ifndef __BWUserType_USB1_TComData
|
||||
#define __BWUserType_USB1_TComData
|
||||
typedef byte USB1_TComData ; /* User type for communication data type. */
|
||||
#endif
|
||||
|
||||
/*
|
||||
DATA_BUFF_SIZE should be greater than or equal to the endpoint buffer size,
|
||||
otherwise there will be data loss. For MC9S08JS16, maximum DATA_BUFF_SIZE
|
||||
supported is 16 Bytes
|
||||
*/
|
||||
#define USB1_DATA_BUFF_SIZE 64 /* data buffer size as specified in the properties */
|
||||
|
||||
#define USB1_USB_ERR_SEND 1 /* Error while sending */
|
||||
#define USB1_USB_ERR_BUSOFF 2 /* Bus not ready */
|
||||
#define USB1_USB_ERR_INIT 3 /* USB initialization error */
|
||||
#define USB1_USB_ERR_TX_CHAR 4 /* Error sending character */
|
||||
#define USB1_USB_ERR_TX_STRING 5 /* Error sending string */
|
||||
#define USB1_USB_ERR_CHECKED_TXFULL 6 /* Error during sending a checked block */
|
||||
#define USB1_USB_ERR_RECEIVE 7 /* Error while starting a receive transaction */
|
||||
|
||||
byte USB1_Init(void);
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : USB1_Init (component FSL_USB_Stack)
|
||||
** Description :
|
||||
** Initializes the driver
|
||||
** Parameters : None
|
||||
** Returns :
|
||||
** --- - Error code
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
void USB1_usb_int_dis(void);
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : USB1_usb_int_dis (component FSL_USB_Stack)
|
||||
**
|
||||
** Description :
|
||||
** Disables USB interrupts (if supported)
|
||||
** This method is internal. It is used by Processor Expert only.
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
void USB1_usb_int_en(void);
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : USB1_usb_int_en (component FSL_USB_Stack)
|
||||
**
|
||||
** Description :
|
||||
** Enables USB interrupts (if supported).
|
||||
** This method is internal. It is used by Processor Expert only.
|
||||
** ===================================================================
|
||||
*/
|
||||
|
||||
/* END USB1. */
|
||||
|
||||
#endif
|
||||
/* ifndef __USB1_H */
|
||||
/*!
|
||||
** @}
|
||||
*/
|
||||
/*
|
||||
** ###################################################################
|
||||
**
|
||||
** This file was created by Processor Expert 10.4 [05.11]
|
||||
** for the Freescale Kinetis series of microcontrollers.
|
||||
**
|
||||
** ###################################################################
|
||||
*/
|
||||
@@ -0,0 +1,211 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Freescale Semiconductor Inc.
|
||||
* (c) Copyright 2004-2010 Freescale Semiconductor, Inc.
|
||||
* ALL RIGHTS RESERVED.
|
||||
*
|
||||
******************************************************************************
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY FREESCALE "AS IS" AND ANY EXPRESSED OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL FREESCALE OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
**************************************************************************//*!
|
||||
*
|
||||
* @file USB_Config.h
|
||||
*
|
||||
* @author B14088
|
||||
*
|
||||
* @version
|
||||
*
|
||||
* @date Oct 31, 2010
|
||||
*
|
||||
* @brief
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef USB_CONFIG_H_
|
||||
#define USB_CONFIG_H_
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Includes Section */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Typedef Section */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function's Prototypes */
|
||||
/*****************************************************************************/
|
||||
/* CDC class services */
|
||||
extern void USB_Class_CDC_Service_Dic_Bulk_In (PTR_USB_DEV_EVENT_STRUCT event);
|
||||
extern void USB_Class_CDC_Service_Dic_Bulk_Out(PTR_USB_DEV_EVENT_STRUCT event);
|
||||
extern void USB_Class_CDC_Service_Cic_Notify(PTR_USB_DEV_EVENT_STRUCT event);
|
||||
extern void USB_NULL_CALLBACK (PTR_USB_DEV_EVENT_STRUCT event);
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Defines & Macros Section */
|
||||
/*****************************************************************************/
|
||||
|
||||
#define REMOTE_WAKEUP_SUPPORT (TRUE)
|
||||
|
||||
/* CDC specific configuration parameters */
|
||||
#define DATA_CLASS_SUPPORT (TRUE)
|
||||
#define CIC_NOTIF_ELEM_SUPPORT (TRUE) /* Mandatory */
|
||||
#define DIC_ISOCHRONOUS_SETTING (FALSE)
|
||||
#define IMPLEMENT_QUEUING (FALSE)
|
||||
|
||||
/* Hardware components configuration */
|
||||
#define USB_HW_VREG_EN TRUE
|
||||
#define USB_HW_PU_EN TRUE
|
||||
|
||||
/* Event callbacks assignation */
|
||||
#define USB_EP0_CALLBACK USB_Control_Service
|
||||
|
||||
#if DIC_ISOCHRONOUS_SETTING
|
||||
#define USB_EP1_CALLBACK USB_Class_CDC_Service_Dic_Iso_In
|
||||
#define USB_EP2_CALLBACK USB_Class_CDC_Service_Dic_Iso_Out
|
||||
#else
|
||||
#define USB_EP1_CALLBACK USB_Class_CDC_Service_Dic_Bulk_In
|
||||
#define USB_EP2_CALLBACK USB_Class_CDC_Service_Dic_Bulk_Out
|
||||
#endif
|
||||
|
||||
#define USB_EP3_CALLBACK USB_Class_CDC_Service_Cic_Notify
|
||||
#define USB_EP4_CALLBACK USB_NULL_CALLBACK
|
||||
#define USB_EP5_CALLBACK USB_NULL_CALLBACK
|
||||
#define USB_EP6_CALLBACK USB_NULL_CALLBACK
|
||||
#define USB_EP7_CALLBACK USB_NULL_CALLBACK
|
||||
#define USB_EP8_CALLBACK USB_NULL_CALLBACK
|
||||
#define USB_EP9_CALLBACK USB_NULL_CALLBACK
|
||||
#define USB_EP10_CALLBACK USB_NULL_CALLBACK
|
||||
#define USB_EP11_CALLBACK USB_NULL_CALLBACK
|
||||
#define USB_EP12_CALLBACK USB_NULL_CALLBACK
|
||||
#define USB_EP13_CALLBACK USB_NULL_CALLBACK
|
||||
#define USB_EP14_CALLBACK USB_NULL_CALLBACK
|
||||
#define USB_EP15_CALLBACK USB_NULL_CALLBACK
|
||||
|
||||
#define USB_BUS_RESET_CALLBACK USB_Reset_Service
|
||||
#define USB_SUSPEND_CALLBACK USB_Suspend_Service
|
||||
#define USB_SOF_CALLBACK USB_Sof_Service
|
||||
#define USB_RESUME_CALLBACK USB_Resume_Service
|
||||
#define USB_SLEEP_CALLBACK USB_Suspend_Service
|
||||
#define USB_SPEED_DETECTION_CALLBACK USB_NULL_CALLBACK
|
||||
#define USB_ERROR_CALLBACK USB_Error_Service
|
||||
#define USB_STALL_CALLBACK USB_Stall_Service
|
||||
|
||||
/* Endpoints configuration */
|
||||
#define USB_EP0_ENABLE TRUE
|
||||
#define USB_EP0_DIR EP_CTRL
|
||||
#define USB_EP0_HSHK TRUE
|
||||
#define USB_EP0_SIZE 32
|
||||
|
||||
#if DIC_ISOCHRONOUS_SETTING
|
||||
#define USB_EP1_ENABLE TRUE
|
||||
#define USB_EP1_DIR USB_DIR_IN
|
||||
#define USB_EP1_HSHK FALSE
|
||||
#define USB_EP1_SIZE 64
|
||||
|
||||
#define USB_EP2_ENABLE TRUE
|
||||
#define USB_EP2_DIR EP_OUT
|
||||
#define USB_EP2_HSHK FALSE
|
||||
#define USB_EP2_SIZE 64
|
||||
#else
|
||||
#define USB_EP1_ENABLE TRUE
|
||||
#define USB_EP1_DIR EP_IN
|
||||
#define USB_EP1_HSHK TRUE
|
||||
#define USB_EP1_SIZE 32
|
||||
|
||||
#define USB_EP2_ENABLE TRUE
|
||||
#define USB_EP2_DIR EP_OUT
|
||||
#define USB_EP2_HSHK TRUE
|
||||
#define USB_EP2_SIZE 32
|
||||
#endif
|
||||
|
||||
#define USB_EP3_ENABLE TRUE
|
||||
#define USB_EP3_DIR EP_IN
|
||||
#define USB_EP3_HSHK TRUE
|
||||
#define USB_EP3_SIZE 32
|
||||
|
||||
#define USB_EP4_ENABLE FALSE
|
||||
#define USB_EP4_DIR NA
|
||||
#define USB_EP4_HSHK TRUE
|
||||
#define USB_EP4_SIZE 0
|
||||
|
||||
#define USB_EP5_ENABLE FALSE
|
||||
#define USB_EP5_DIR NA
|
||||
#define USB_EP5_HSHK TRUE
|
||||
#define USB_EP5_SIZE 0
|
||||
|
||||
#define USB_EP6_ENABLE FALSE
|
||||
#define USB_EP6_DIR NA
|
||||
#define USB_EP6_HSHK TRUE
|
||||
#define USB_EP6_SIZE 0
|
||||
|
||||
#define USB_EP7_ENABLE FALSE
|
||||
#define USB_EP7_DIR NA
|
||||
#define USB_EP7_HSHK TRUE
|
||||
#define USB_EP7_SIZE 0
|
||||
|
||||
#define USB_EP8_ENABLE FALSE
|
||||
#define USB_EP8_DIR NA
|
||||
#define USB_EP8_HSHK TRUE
|
||||
#define USB_EP8_SIZE 0
|
||||
|
||||
#define USB_EP9_ENABLE FALSE
|
||||
#define USB_EP9_DIR NA
|
||||
#define USB_EP9_HSHK TRUE
|
||||
#define USB_EP9_SIZE 0
|
||||
|
||||
#define USB_EP10_ENABLE FALSE
|
||||
#define USB_EP10_DIR NA
|
||||
#define USB_EP10_HSHK TRUE
|
||||
#define USB_EP10_SIZE 0
|
||||
|
||||
#define USB_EP11_ENABLE FALSE
|
||||
#define USB_EP11_DIR NA
|
||||
#define USB_EP11_HSHK TRUE
|
||||
#define USB_EP11_SIZE 0
|
||||
|
||||
#define USB_EP12_ENABLE FALSE
|
||||
#define USB_EP12_DIR NA
|
||||
#define USB_EP12_HSHK TRUE
|
||||
#define USB_EP12_SIZE 0
|
||||
|
||||
#define USB_EP13_ENABLE FALSE
|
||||
#define USB_EP13_DIR NA
|
||||
#define USB_EP13_HSHK TRUE
|
||||
#define USB_EP13_SIZE 0
|
||||
|
||||
#define USB_EP14_ENABLE FALSE
|
||||
#define USB_EP14_DIR NA
|
||||
#define USB_EP14_HSHK TRUE
|
||||
#define USB_EP14_SIZE 0
|
||||
|
||||
#define USB_EP15_ENABLE FALSE
|
||||
#define USB_EP15_DIR NA
|
||||
#define USB_EP15_HSHK TRUE
|
||||
#define USB_EP15_SIZE 0
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Extern Variables Section */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function Prototypes Section */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#endif /* USB_CONFIG_H_ */
|
||||
@@ -0,0 +1,64 @@
|
||||
/******************************************************/
|
||||
/**
|
||||
* @file hidef.h
|
||||
* Machine/compiler dependent declarations.
|
||||
*/
|
||||
/*----------------------------------------------------
|
||||
Copyright (c) Freescale DevTech
|
||||
All rights reserved
|
||||
Do not modify!
|
||||
*****************************************************/
|
||||
|
||||
#ifndef _H_HIDEF_
|
||||
#define _H_HIDEF_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef EnableInterrupts
|
||||
#ifndef DisableInterrupts
|
||||
|
||||
#if defined(__CWCC__)
|
||||
#pragma gcc_extensions on
|
||||
|
||||
/**** Version for ColFire V1 */
|
||||
#include <stddef.h>
|
||||
#include "types.h"
|
||||
|
||||
/*!< Macro to enable all interrupts. */
|
||||
#define EnableInterrupts asm ("CPSIE i")
|
||||
|
||||
/*!< Macro to disable all interrupts. */
|
||||
#define DisableInterrupts asm ("CPSID i")
|
||||
|
||||
#elif defined(__IAR_SYSTEMS_ICC__)
|
||||
#include <intrinsics.h>
|
||||
|
||||
#define EnableInterrupts; __enable_interrupt()
|
||||
#define DisableInterrupts __disable_interrupt()
|
||||
|
||||
#elif defined (__CC_ARM)
|
||||
#define EnableInterrupts __enable_irq()
|
||||
#define DisableInterrupts __disable_irq()
|
||||
|
||||
#elif defined (__GNUC__)
|
||||
#include <stddef.h>
|
||||
#include "types.h"
|
||||
|
||||
/*!< Macro to enable all interrupts. */
|
||||
#define EnableInterrupts asm ("CPSIE i")
|
||||
|
||||
/*!< Macro to disable all interrupts. */
|
||||
#define DisableInterrupts asm ("CPSID i")
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif /* #ifdef DisableInterrupts */
|
||||
#endif/* #ifdef EnableInterrupts */
|
||||
/*****************************************************/
|
||||
/* end hidef.h */
|
||||
@@ -0,0 +1,180 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Freescale Semiconductor Inc.
|
||||
* (c) Copyright 2004-2010 Freescale Semiconductor, Inc.
|
||||
* ALL RIGHTS RESERVED.
|
||||
*
|
||||
******************************************************************************
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY FREESCALE "AS IS" AND ANY EXPRESSED OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL FREESCALE OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
**************************************************************************//*!
|
||||
*
|
||||
* @file types.h
|
||||
*
|
||||
* @author
|
||||
*
|
||||
* @version
|
||||
*
|
||||
* @date
|
||||
*
|
||||
* @brief The file contains definitions of datatypes.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
#ifndef _TYPES_H
|
||||
#define _TYPES_H
|
||||
|
||||
/******************************************************************************
|
||||
* Includes
|
||||
*****************************************************************************/
|
||||
#include <stddef.h>
|
||||
/******************************************************************************
|
||||
* Constants - None
|
||||
*****************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Macro's
|
||||
*****************************************************************************/
|
||||
#define LSB(a) ((a)._byte.byte0)
|
||||
#define MSB(a) ((a)._byte.byte1)
|
||||
|
||||
#define LOWER_LSB(a) ((a)._byte.byte0)
|
||||
#define LOWER_MSB(a) ((a)._byte.byte1)
|
||||
#define UPPER_LSB(a) ((a)._byte.byte2)
|
||||
#define UPPER_MSB(a) ((a)._byte.byte3)
|
||||
|
||||
#define _PTR_ *
|
||||
#define _CODE_PTR_ *
|
||||
|
||||
#ifndef TRUE
|
||||
#define FALSE 0
|
||||
#define TRUE 1
|
||||
#endif
|
||||
|
||||
#define BYTESWAP16(x) (uint_16)((((x) & 0xFF00) >> 0x8) | (((x) & 0xFF) << 0x8))
|
||||
#define BYTESWAP32(val) (uint_32)((BYTESWAP16((uint_32)(val) & (uint_32)0xFFFF) << 0x10) | \
|
||||
(BYTESWAP16((uint_32)((val) >> 0x10))))
|
||||
|
||||
#ifdef CPU_LITTLE_ENDIAN /* << EST: defined by Processor Expert CPU.h for Kinetis devices */
|
||||
#ifndef LITTLE_ENDIAN /* might be defined already on the compiler command line? */
|
||||
#define LITTLE_ENDIAN
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef LITTLE_ENDIAN
|
||||
#define ieee_htons(x) (uint_16)(x)
|
||||
#define ieee_htonl(x) (uint_32)(x)
|
||||
#define ieee_ntohs(x) (uint_16)(x)
|
||||
#define ieee_ntohl(x) (uint_32)(x)
|
||||
#else
|
||||
#define ieee_htons(x) BYTESWAP16(x)
|
||||
#define ieee_htonl(x) BYTESWAP32(x)
|
||||
#define ieee_ntohs(x) BYTESWAP16(x)
|
||||
#define ieee_ntohl(x) BYTESWAP32(x)
|
||||
#endif
|
||||
|
||||
#ifndef UNUSED
|
||||
#define UNUSED(x) (void)(x);
|
||||
#endif
|
||||
/******************************************************************************
|
||||
* Types
|
||||
*****************************************************************************/
|
||||
typedef void _PTR_ pointer; /* Machine representation of a pointer */
|
||||
typedef unsigned char uint_8; /* 8-bit*/
|
||||
typedef signed char int_8; /* 8-bit*/
|
||||
|
||||
typedef unsigned short uint_16; /* 16-bit*/
|
||||
typedef signed short int_16; /* 16-bit*/
|
||||
|
||||
typedef unsigned long uint_32; /* 32-bit*/
|
||||
typedef signed long int_32; /* 32-bit*/
|
||||
|
||||
typedef unsigned char boolean; /* 8-bit*/
|
||||
|
||||
typedef uint_8* uint_8_ptr; /* ptr to 8-bit*/
|
||||
typedef uint_16* uint_16_ptr; /* ptr to 16-bit */
|
||||
typedef uint_32* uint_32_ptr; /* ptr to 32-bit*/
|
||||
|
||||
typedef uint_8_ptr uint8_ptr; /* ptr to 8-bit*/
|
||||
|
||||
/* definition of 8 bit word */
|
||||
typedef union _BYTE
|
||||
{
|
||||
uint_8 _byte;
|
||||
struct
|
||||
{
|
||||
unsigned b0:1;
|
||||
unsigned b1:1;
|
||||
unsigned b2:1;
|
||||
unsigned b3:1;
|
||||
unsigned b4:1;
|
||||
unsigned b5:1;
|
||||
unsigned b6:1;
|
||||
unsigned b7:1;
|
||||
}Bit;
|
||||
} BYTE;
|
||||
|
||||
/* definition of 16 bit word */
|
||||
typedef union _WORD
|
||||
{
|
||||
uint_16 _word;
|
||||
struct
|
||||
{
|
||||
uint_8 byte1;
|
||||
uint_8 byte0;
|
||||
}_byte;
|
||||
struct
|
||||
{
|
||||
BYTE HighB;
|
||||
BYTE LowB;
|
||||
}_Byte;
|
||||
} WORD;
|
||||
|
||||
/* definition of 32 bit word */
|
||||
typedef union _DWORD
|
||||
{
|
||||
uint_32 _dword;
|
||||
struct
|
||||
{
|
||||
uint_8 byte3;
|
||||
uint_8 byte2;
|
||||
uint_8 byte1;
|
||||
uint_8 byte0;
|
||||
}_byte;
|
||||
struct
|
||||
{
|
||||
uint_16 word1;
|
||||
uint_16 word0;
|
||||
}_word;
|
||||
struct
|
||||
{
|
||||
BYTE Byte3;
|
||||
BYTE Byte2;
|
||||
BYTE Byte1;
|
||||
BYTE Byte0;
|
||||
}_Byte;
|
||||
struct
|
||||
{
|
||||
WORD Word1;
|
||||
WORD Word0;
|
||||
}_Word;
|
||||
} DWORD;
|
||||
|
||||
/******************************************************************************
|
||||
* Global Functions - None
|
||||
*****************************************************************************/
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Freescale Semiconductor Inc.
|
||||
* (c) Copyright 2004-2009 Freescale Semiconductor, Inc.
|
||||
* ALL RIGHTS RESERVED.
|
||||
*
|
||||
******************************************************************************
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY FREESCALE "AS IS" AND ANY EXPRESSED OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL FREESCALE OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
**************************************************************************//*!
|
||||
*
|
||||
* @file usb_bdt_kinetis.h
|
||||
*
|
||||
* @author
|
||||
*
|
||||
* @version
|
||||
*
|
||||
* @date Jun-05-2009
|
||||
*
|
||||
* @brief The file contains definitions of Buffer Descriptor Table.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef _USBBDT_H
|
||||
#define _USBBDT_H
|
||||
|
||||
/******************************************************************************
|
||||
* Includes
|
||||
*****************************************************************************/
|
||||
#include "types.h"
|
||||
|
||||
/******************************************************************************
|
||||
* Constants - None
|
||||
*****************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Macro's
|
||||
*****************************************************************************/
|
||||
/* Buffer Descriptor Status Register Initialization Parameters */
|
||||
#define _BDTSTALL (0x04) /* Buffer Stall enable */
|
||||
#define _DATA0 (0x00) /* DATA0 packet expected next */
|
||||
#define _DATA1 (0x40) /* DATA1 packet expected next */
|
||||
#define _DTS (0x08) /* DTS Mask */
|
||||
#define _SIE (0x80) /* SIE owns buffer */
|
||||
#define _CPU (0x00) /* CPU owns buffer */
|
||||
#define _KEEP (0x20) /* keep bit */
|
||||
|
||||
#define MAX_BDT_INDEX (64) /* Maximum BDT Indexes */
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* Types
|
||||
*****************************************************************************/
|
||||
/* This structure is an exact replica of the BDT MAP in the USB RAM
|
||||
The BDT_STAT defines the stat byte of the buffer descriptor vector.
|
||||
McuCtlBit structure defines the bits that have a meaning from CPU
|
||||
point of view.SieCtlBit structure defines the bits that have a
|
||||
meaning from USB controller point of view.
|
||||
*/
|
||||
|
||||
#if defined(__CWCC__)
|
||||
#pragma align_array_members on
|
||||
#endif
|
||||
/* << EST pushing current packing */
|
||||
#pragma pack(push)
|
||||
#pragma pack(1)
|
||||
typedef struct _MCU_CTL_BIT{
|
||||
uint_8 :1;
|
||||
uint_8 :1;
|
||||
uint_8 bdtstall:1; /* Buffer Stall Enable */
|
||||
uint_8 dts:1; /* Data Toggle Synch Enable */
|
||||
uint_8 keep:1; /* Address Increment Disable */
|
||||
uint_8 ninc:1; /* BD Keep Enable */
|
||||
uint_8 data:1; /* Data Toggle Synch Value */
|
||||
uint_8 own:1; /* USB Ownership */
|
||||
}MCU_CTL_BIT; /* read Stat */
|
||||
|
||||
typedef struct _SIE_CTL_BIT{
|
||||
uint_8 :1;
|
||||
uint_8 :1;
|
||||
uint_8 pid0:1; /* Packet Identifier bit 0 */
|
||||
uint_8 pid1:1; /* Packet Identifier bit 1 */
|
||||
uint_8 pid2:1; /* Packet Identifier bit 2 */
|
||||
uint_8 pid3:1; /* Packet Identifier bit 3 */
|
||||
uint_8 :1;
|
||||
uint_8 own:1;
|
||||
}SIE_CTL_BIT; /* write Stat */
|
||||
|
||||
typedef struct _REC_PID{
|
||||
uint_8 :2;
|
||||
uint_8 pid:4; /* Packet Identifier */
|
||||
uint_8 :2;
|
||||
}REC_PID;
|
||||
|
||||
typedef union _BD_STAT
|
||||
{
|
||||
uint_8 _byte;
|
||||
MCU_CTL_BIT McuCtlBit;
|
||||
SIE_CTL_BIT SieCtlBit;
|
||||
REC_PID RecPid;
|
||||
} BD_STAT; /* Buffer Descriptor Status Register */
|
||||
|
||||
typedef struct _BUFF_DSC
|
||||
{
|
||||
BD_STAT Stat;
|
||||
uint_8 reserved1;
|
||||
uint_16 cnt; /* Count of bytes receieved or sent */
|
||||
/* six MSB bits are reserved ones */
|
||||
uint_32 addr; /* Buffer Address */
|
||||
} BUFF_DSC, *P_BUFF_DSC; /* Buffer Descriptor Table */
|
||||
|
||||
typedef struct _g_bdtmap {
|
||||
|
||||
BUFF_DSC ep_dsc[MAX_BDT_INDEX]; /* Endpoint Descriptor */
|
||||
}BDTMAP;
|
||||
#if defined(__CWCC__)
|
||||
#pragma align_array_members off
|
||||
#pragma options align=reset
|
||||
#elif defined(__IAR_SYSTEMS_ICC__)
|
||||
#pragma pack()
|
||||
#else /* e.g. gcc */
|
||||
/* << EST restoring previous packing */
|
||||
#pragma pack(pop)
|
||||
#endif
|
||||
/******************************************************************************
|
||||
* Global Functions - None
|
||||
*****************************************************************************/
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,809 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Freescale Semiconductor Inc.
|
||||
* (c) Copyright 2004-2009 Freescale Semiconductor, Inc.
|
||||
* ALL RIGHTS RESERVED.
|
||||
*
|
||||
******************************************************************************
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY FREESCALE "AS IS" AND ANY EXPRESSED OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL FREESCALE OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
**************************************************************************//*!
|
||||
*
|
||||
* @file usb_cdc.c
|
||||
*
|
||||
* @author
|
||||
*
|
||||
* @version
|
||||
*
|
||||
* @date May-28-2009
|
||||
*
|
||||
* @brief The file contains USB stack CDC layer implementation.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Includes
|
||||
*****************************************************************************/
|
||||
#include "usb_cdc.h" /* USB CDC Class Header File */
|
||||
/*****************************************************************************
|
||||
* Constant and Macro's
|
||||
*****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Global Variables
|
||||
****************************************************************************/
|
||||
#ifdef _MC9S08JS16_H
|
||||
#pragma DATA_SEG APP_DATA
|
||||
#endif
|
||||
|
||||
/* CDC Class Callback Function Pointer */
|
||||
static USB_CLASS_CALLBACK g_cdc_class_callback = NULL;
|
||||
|
||||
/* CDC Class Vendor Callback Function Pointer */
|
||||
static USB_REQ_FUNC g_vendor_req_callback = NULL;
|
||||
|
||||
/* CDC endpoint info array */
|
||||
#ifndef COMPOSITE_DEV
|
||||
static USB_CLASS_CDC_ENDPOINT g_cdc_ep[CDC_DESC_ENDPOINT_COUNT];
|
||||
#else
|
||||
static USB_CLASS_CDC_ENDPOINT g_cdc_ep[COMPOSITE_DESC_ENDPOINT_COUNT];
|
||||
#endif
|
||||
/*****************************************************************************
|
||||
* Local Types - None
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* Local Functions Prototypes
|
||||
*****************************************************************************/
|
||||
#if CIC_NOTIF_ELEM_SUPPORT
|
||||
void USB_Class_CDC_Service_Cic_Notify(PTR_USB_DEV_EVENT_STRUCT event);
|
||||
#endif
|
||||
#if !DIC_ISOCHRONOUS_SETTING
|
||||
void USB_Class_CDC_Service_Dic_Bulk_In(PTR_USB_DEV_EVENT_STRUCT event);
|
||||
void USB_Class_CDC_Service_Dic_Bulk_Out(PTR_USB_DEV_EVENT_STRUCT event);
|
||||
#else
|
||||
static void USB_Class_CDC_Service_Dic_Iso_In(PTR_USB_DEV_EVENT_STRUCT event);
|
||||
static void USB_Class_CDC_Service_Dic_Iso_Out(PTR_USB_DEV_EVENT_STRUCT event);
|
||||
#endif
|
||||
#ifndef COMPOSITE_DEV
|
||||
static uint_8 USB_Other_Requests(
|
||||
uint_8 controller_ID,
|
||||
USB_SETUP_STRUCT * setup_packet,
|
||||
uint_8_ptr *data,
|
||||
USB_PACKET_SIZE *size);
|
||||
#endif
|
||||
void USB_Class_CDC_Event(
|
||||
uint_8 controller_ID,
|
||||
uint_8 event,
|
||||
void* val);
|
||||
|
||||
/*****************************************************************************
|
||||
* Local Variables - None
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* Local Functions
|
||||
*****************************************************************************/
|
||||
#if CIC_NOTIF_ELEM_SUPPORT
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Class_CDC_Service_Cic_Notify
|
||||
*
|
||||
* @brief The function is callback function of CIC Notification endpoint
|
||||
*
|
||||
* @param event : Pointer to USB Event Structure
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
******************************************************************************
|
||||
* Called by Lower layer when data on CIC Endpoint is sent
|
||||
*****************************************************************************/
|
||||
void USB_Class_CDC_Service_Cic_Notify (
|
||||
PTR_USB_DEV_EVENT_STRUCT event /* [IN] Pointer to USB Event Structure */
|
||||
)
|
||||
{
|
||||
#if IMPLEMENT_QUEUING
|
||||
uint_8 index;
|
||||
uint_8 producer, consumer;
|
||||
USB_ENDPOINTS *usb_ep_data = (USB_ENDPOINTS *)
|
||||
USB_Desc_Get_Endpoints(event->controller_ID);
|
||||
|
||||
USB_CLASS_CDC_QUEUE queue;
|
||||
|
||||
/* map the endpoint num to the index of the endpoint structure */
|
||||
for(index = 0; index < usb_ep_data->count; index++)
|
||||
{
|
||||
if(usb_ep_data->ep[index].ep_num == event->ep_num)
|
||||
break;
|
||||
}
|
||||
|
||||
producer = g_cdc_ep[index].bin_producer;
|
||||
|
||||
/* if there are no errors de-queue the queue and decrement the no. of
|
||||
transfers left, else send the same data again */
|
||||
if(event->errors == 0)
|
||||
{
|
||||
g_cdc_ep[index].bin_consumer++;
|
||||
}
|
||||
|
||||
consumer = g_cdc_ep[index].bin_consumer;
|
||||
|
||||
if(consumer != producer)
|
||||
{/*if bin is not empty */
|
||||
|
||||
queue = g_cdc_ep[index].queue[consumer%MAX_QUEUE_ELEMS];
|
||||
|
||||
(void)USB_Class_Send_Data(queue.controller_ID, queue.channel,
|
||||
queue.app_data.data_ptr, queue.app_data.data_size);
|
||||
}
|
||||
#endif
|
||||
|
||||
if(g_cdc_class_callback != NULL)
|
||||
{
|
||||
uint_8 event_type = USB_APP_SEND_COMPLETE;
|
||||
|
||||
if(event->errors != 0)
|
||||
{
|
||||
event_type = USB_APP_ERROR;
|
||||
}
|
||||
g_cdc_class_callback(event->controller_ID, event_type,
|
||||
(uint_8*)(&(event->errors)));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !DIC_ISOCHRONOUS_SETTING
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Class_CDC_Service_Dic_Bulk_In
|
||||
*
|
||||
* @brief The function is callback function of DIC Bulk In Endpoint
|
||||
*
|
||||
* @param event : Pointer to USB Event Structure
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
******************************************************************************
|
||||
* Called by Lower Layer when Data on DIC SEND Interface is sent
|
||||
*****************************************************************************/
|
||||
void USB_Class_CDC_Service_Dic_Bulk_In (
|
||||
PTR_USB_DEV_EVENT_STRUCT event /* [IN] Pointer to USB Event Structure */
|
||||
)
|
||||
{
|
||||
APP_DATA_STRUCT bulk_in_recv;
|
||||
|
||||
#if IMPLEMENT_QUEUING
|
||||
uint_8 index;
|
||||
uint_8 producer, consumer;
|
||||
USB_ENDPOINTS *usb_ep_data = (USB_ENDPOINTS *)
|
||||
USB_Desc_Get_Endpoints(event->controller_ID);
|
||||
|
||||
USB_CLASS_CDC_QUEUE queue;
|
||||
|
||||
bulk_in_recv.data_ptr = event->buffer_ptr;
|
||||
bulk_in_recv.data_size = event->len;
|
||||
|
||||
/* map the endpoint num to the index of the endpoint structure */
|
||||
for(index = 0; index < usb_ep_data->count; index++)
|
||||
{
|
||||
if(usb_ep_data->ep[index].ep_num == event->ep_num)
|
||||
break;
|
||||
}
|
||||
|
||||
producer = g_cdc_ep[index].bin_producer;
|
||||
|
||||
/* if there are no errors de-queue the queue and decrement the no. of
|
||||
transfers left, else send the same data again */
|
||||
if(event->errors == 0)
|
||||
{
|
||||
g_cdc_ep[index].bin_consumer++;
|
||||
}
|
||||
|
||||
consumer = g_cdc_ep[index].bin_consumer;
|
||||
|
||||
if(consumer != producer)
|
||||
{/*if bin is not empty */
|
||||
|
||||
queue = g_cdc_ep[index].queue[consumer%MAX_QUEUE_ELEMS];
|
||||
|
||||
(void)USB_Class_Send_Data(queue.controller_ID, queue.channel,
|
||||
queue.app_data.data_ptr, queue.app_data.data_size);
|
||||
}
|
||||
#endif
|
||||
if(g_cdc_class_callback != NULL)
|
||||
{
|
||||
if(event->errors != 0)
|
||||
{
|
||||
g_cdc_class_callback(event->controller_ID, USB_APP_ERROR,
|
||||
(uint_8*)(&(event->errors)));
|
||||
}
|
||||
else
|
||||
{
|
||||
g_cdc_class_callback(event->controller_ID, USB_APP_SEND_COMPLETE,
|
||||
(void*)&bulk_in_recv);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Class_CDC_Service_Dic_Bulk_Out
|
||||
*
|
||||
* @brief The function is callback function of DIC Bulk Out Endpoint
|
||||
*
|
||||
* @param event : Pointer to USB Event Structure
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
******************************************************************************
|
||||
* Called by Lower Layer when Data on DIC RECV Interface is received
|
||||
*****************************************************************************/
|
||||
void USB_Class_CDC_Service_Dic_Bulk_Out (
|
||||
PTR_USB_DEV_EVENT_STRUCT event /* [IN] Pointer to USB Event Structure */
|
||||
)
|
||||
{ APP_DATA_STRUCT bulk_out_recv;
|
||||
|
||||
bulk_out_recv.data_ptr = event->buffer_ptr;
|
||||
bulk_out_recv.data_size = event->len;
|
||||
|
||||
if(g_cdc_class_callback != NULL)
|
||||
{
|
||||
if(event->errors != 0)
|
||||
{
|
||||
g_cdc_class_callback(event->controller_ID, USB_APP_ERROR,
|
||||
(uint_8*)(&(event->errors)));
|
||||
}
|
||||
else
|
||||
{
|
||||
g_cdc_class_callback(event->controller_ID, USB_APP_DATA_RECEIVED,
|
||||
(void*)&bulk_out_recv);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Class_CDC_Service_Dic_Iso_In
|
||||
*
|
||||
* @brief The function is callback function of DIC Isochronous In Endpoint
|
||||
*
|
||||
* @param event : Pointer to USB Event Structure
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
******************************************************************************
|
||||
* Called by Lower Layer when Data on DIC SEND Interface is sent
|
||||
*****************************************************************************/
|
||||
static void USB_Class_CDC_Service_Dic_Iso_In (
|
||||
PTR_USB_EVENT_STRUCT event /* [IN] Pointer to USB Event Structure */
|
||||
)
|
||||
{
|
||||
APP_DATA_STRUCT iso_in_recv;
|
||||
|
||||
#if IMPLEMENT_QUEUING
|
||||
uint_8 index;
|
||||
uint_8 producer, consumer;
|
||||
USB_ENDPOINTS *usb_ep_data = (USB_ENDPOINTS *)
|
||||
USB_Desc_Get_Endpoints(event->controller_ID);
|
||||
|
||||
USB_CLASS_CDC_QUEUE queue;
|
||||
|
||||
/* map the endpoint num to the index of the endpoint structure */
|
||||
for(index = 0; index < usb_ep_data->count; index++)
|
||||
{
|
||||
if(usb_ep_data->ep[index].ep_num == event->ep_num)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
producer = g_cdc_ep[index].bin_producer;
|
||||
|
||||
/* if there are no errors de-queue the queue and decrement the no. of
|
||||
transfers left, else send the same data again */
|
||||
if(event->errors == 0)
|
||||
{
|
||||
g_cdc_ep[index].bin_consumer++;
|
||||
}
|
||||
|
||||
consumer = g_cdc_ep[index].bin_consumer;
|
||||
|
||||
if(consumer != producer)
|
||||
{/*if bin is not empty */
|
||||
|
||||
queue = g_cdc_ep[index].queue[consumer%MAX_QUEUE_ELEMS];
|
||||
|
||||
(void)USB_Class_Send_Data(queue.controller_ID, queue.channel,
|
||||
queue.app_data.data_ptr, queue.app_data.data_size);
|
||||
}
|
||||
#endif
|
||||
|
||||
iso_in_recv.data_ptr = event->buffer_ptr;
|
||||
iso_in_recv.data_size = event->len;
|
||||
|
||||
if(g_cdc_class_callback != NULL)
|
||||
{
|
||||
if(event->errors != 0)
|
||||
{
|
||||
g_cdc_class_callback(event->controller_ID, USB_APP_ERROR,
|
||||
(uint_8*)(&(event->errors)));
|
||||
}
|
||||
else
|
||||
{
|
||||
g_cdc_class_callback(event->controller_ID, USB_APP_SEND_COMPLETE,
|
||||
(void*)&iso_in_recv);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Class_CDC_Service_Dic_Iso_Out
|
||||
*
|
||||
* @brief This is a callback function of DIC Isochronous Out Endpoint
|
||||
*
|
||||
* @param event : Pointer to USB Event Structure
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
******************************************************************************
|
||||
* Called by Lower Layer when Data on DIC RECV Interface is received
|
||||
*****************************************************************************/
|
||||
static void USB_Class_CDC_Service_Dic_Iso_Out (
|
||||
PTR_USB_EVENT_STRUCT event /* [IN] Pointer to USB Event Structure */
|
||||
)
|
||||
{
|
||||
APP_DATA_STRUCT iso_out_recv;
|
||||
|
||||
iso_out_recv.data_ptr = event->buffer_ptr;
|
||||
iso_out_recv.data_size = event->len;
|
||||
|
||||
if(g_cdc_class_callback != NULL)
|
||||
{
|
||||
if(event->errors != 0)
|
||||
{
|
||||
g_cdc_class_callback(event->controller_ID, USB_APP_ERROR,
|
||||
(uint_8*)(&(event->errors)));
|
||||
}
|
||||
else
|
||||
{
|
||||
g_cdc_class_callback(event->controller_ID, USB_APP_DATA_RECEIVED,
|
||||
(void*)&iso_out_recv);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Class_CDC_Event
|
||||
*
|
||||
* @brief The function initializes CDC endpoints
|
||||
*
|
||||
* @param controller_ID : Controller ID
|
||||
* @param event : Event Type
|
||||
* @param val : Pointer to configuration Value
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
******************************************************************************
|
||||
*
|
||||
*****************************************************************************/
|
||||
void USB_Class_CDC_Event (
|
||||
uint_8 controller_ID, /* [IN] Controller ID */
|
||||
uint_8 event, /* [IN] Event Type */
|
||||
void* val /* [OUT] Pointer to configuration Value */
|
||||
)
|
||||
{
|
||||
uint_8 index;
|
||||
USB_ENDPOINTS *usb_ep_data = (USB_ENDPOINTS *)
|
||||
USB_Desc_Get_Endpoints(controller_ID);
|
||||
|
||||
if(event == USB_APP_ENUM_COMPLETE)
|
||||
{
|
||||
uint_8 count = 0,ep_count = 0;
|
||||
uint_8 index_num = 0;
|
||||
|
||||
#ifdef COMPOSITE_DEV
|
||||
DEV_ARCHITECTURE_STRUCT_PTR dev_arc_ptr;
|
||||
CLASS_ARC_STRUCT_PTR dev_class_ptr;
|
||||
dev_arc_ptr = (DEV_ARCHITECTURE_STRUCT *)USB_Desc_Get_Class_Architecture(controller_ID);
|
||||
for(count = 0; count < dev_arc_ptr->cl_count; count++)
|
||||
{
|
||||
dev_class_ptr = (CLASS_ARC_STRUCT_PTR)dev_arc_ptr->value[count];
|
||||
/* Initializes sub_classes */
|
||||
ep_count = dev_class_ptr->value[0];
|
||||
if(dev_class_ptr->class_type == 0x02/*CDC_CC*/)
|
||||
break;
|
||||
index_num +=dev_class_ptr->value[0];
|
||||
}
|
||||
#else
|
||||
ep_count = usb_ep_data->count;
|
||||
#endif
|
||||
|
||||
for(count=index_num; count<ep_count+index_num; count++)
|
||||
{
|
||||
USB_EP_STRUCT_PTR ep_struct_ptr=
|
||||
(USB_EP_STRUCT_PTR) (unsigned long) (&usb_ep_data->ep[count]); // cast to unsigned long before properly casting to prevent gcc from complaining about cast from const to non-const
|
||||
(void)_usb_device_deinit_endpoint(&controller_ID,
|
||||
ep_struct_ptr->ep_num, ep_struct_ptr->direction);
|
||||
}
|
||||
|
||||
/* intialize all non control endpoints */
|
||||
for(count=index_num; count<ep_count+index_num; count++)
|
||||
{
|
||||
USB_EP_STRUCT_PTR ep_struct=
|
||||
(USB_EP_STRUCT_PTR) (unsigned long) (&usb_ep_data->ep[count]); // cast to unsigned long before properly casting to prevent gcc from complaining about cast from const to non-const
|
||||
|
||||
(void)_usb_device_init_endpoint(&controller_ID, ep_struct->ep_num,
|
||||
ep_struct->size, ep_struct->direction, ep_struct->type, FALSE);
|
||||
|
||||
/* register callback service for Non Control EndPoints */
|
||||
switch(ep_struct->type)
|
||||
{
|
||||
#if CIC_NOTIF_ELEM_SUPPORT
|
||||
case USB_INTERRUPT_PIPE :
|
||||
(void)_usb_device_register_service(controller_ID,
|
||||
(uint_8)(USB_SERVICE_EP0+ep_struct->ep_num),
|
||||
USB_Class_CDC_Service_Cic_Notify);
|
||||
break;
|
||||
#endif
|
||||
#if !DIC_ISOCHRONOUS_SETTING
|
||||
case USB_BULK_PIPE :
|
||||
#ifdef MULTIPLE_DEVICES
|
||||
if(ep_struct->direction == USB_RECV)
|
||||
{
|
||||
(void)_usb_device_register_service(controller_ID,
|
||||
(uint_8)(USB_SERVICE_EP0+ep_struct->ep_num),
|
||||
USB_Class_CDC_Service_Dic_Bulk_Out);
|
||||
}
|
||||
else
|
||||
{
|
||||
(void)_usb_device_register_service(controller_ID,
|
||||
(uint_8)(USB_SERVICE_EP0+ep_struct->ep_num),
|
||||
USB_Class_CDC_Service_Dic_Bulk_In);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
#else
|
||||
case USB_ISOCHRONOUS_PIPE :
|
||||
if(ep_struct->direction == USB_RECV)
|
||||
{
|
||||
(void)_usb_device_register_service(controller_ID,
|
||||
(uint_8)(USB_SERVICE_EP0+ep_struct->ep_num),
|
||||
USB_Class_CDC_Service_Dic_Iso_Out);
|
||||
}
|
||||
else
|
||||
{
|
||||
(void)_usb_device_register_service(controller_ID,
|
||||
(uint_8)(USB_SERVICE_EP0+ep_struct->ep_num),
|
||||
USB_Class_CDC_Service_Dic_Iso_In);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
/* set the EndPoint Status as Idle in the device layer */
|
||||
(void)_usb_device_set_status(&controller_ID,
|
||||
(uint_8)(USB_STATUS_ENDPOINT | ep_struct->ep_num |
|
||||
(ep_struct->direction << USB_COMPONENT_DIRECTION_SHIFT)),
|
||||
(uint_8)USB_STATUS_IDLE);
|
||||
}
|
||||
}
|
||||
else if(event == USB_APP_BUS_RESET)
|
||||
{
|
||||
#if IMPLEMENT_QUEUING
|
||||
for(index = 0; index < usb_ep_data->count; index++)
|
||||
{
|
||||
g_cdc_ep[index].bin_consumer = 0x00;
|
||||
g_cdc_ep[index].bin_producer = 0x00;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if(g_cdc_class_callback != NULL)
|
||||
{
|
||||
g_cdc_class_callback(controller_ID, event, val);
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Other_Requests
|
||||
*
|
||||
* @brief The function provides flexibilty to add class and vendor specific
|
||||
* requests
|
||||
*
|
||||
* @param controller_ID : Controller ID
|
||||
* @param setup_packet : Setup packet received
|
||||
* @param data: : Data to be send back
|
||||
* @param size: : Size to be returned
|
||||
*
|
||||
* @return status:
|
||||
* USB_OK : When Successfull
|
||||
* Others : When Error
|
||||
*
|
||||
******************************************************************************
|
||||
* Handles CDC Class requests and forwards vendor specific request to the
|
||||
* application
|
||||
*****************************************************************************/
|
||||
#ifndef COMPOSITE_DEV
|
||||
static uint_8 USB_Other_Requests
|
||||
#else
|
||||
uint_8 USB_CDC_Other_Requests
|
||||
#endif
|
||||
(
|
||||
uint_8 controller_ID, /* [IN] Controller ID */
|
||||
USB_SETUP_STRUCT * setup_packet,/* [IN] Pointer to Setup Packet Received */
|
||||
uint_8_ptr *data, /* [OUT] Pointer to Data Buffer to be sent */
|
||||
USB_PACKET_SIZE *size /* [OUT] Size of Data buffer */
|
||||
)
|
||||
{
|
||||
uint_8 status = USBERR_INVALID_REQ_TYPE;
|
||||
if((setup_packet->request_type & USB_REQUEST_CLASS_MASK) ==
|
||||
USB_REQUEST_CLASS_CLASS)
|
||||
{
|
||||
/* class request so handle it here */
|
||||
status=USB_OK;
|
||||
|
||||
/* call for class/subclass specific requests */
|
||||
switch(setup_packet->request)
|
||||
{
|
||||
case SEND_ENCAPSULATED_COMMAND :
|
||||
/* Add code to transfer Request and Acknowledgement */
|
||||
*size=0;
|
||||
break;
|
||||
case GET_ENCAPSULATED_RESPONSE :
|
||||
/*
|
||||
Add code for handling Transfer Response/Requests and
|
||||
Notification
|
||||
*/
|
||||
*size=0;
|
||||
break;
|
||||
case SET_COMM_FEATURE :
|
||||
status = USB_Class_CDC_PSTN_Set_Comm_Feature(controller_ID,
|
||||
setup_packet, data, size);
|
||||
break;
|
||||
case GET_COMM_FEATURE :
|
||||
status = USB_Class_CDC_PSTN_Get_Comm_Feature(controller_ID,
|
||||
setup_packet, data, size);
|
||||
break;
|
||||
case CLEAR_COMM_FEATURE : /* Verify this implementation */
|
||||
*size = COMM_FEATURE_DATA_SIZE;
|
||||
**data = 0x00; *(++(*data)) = 0x00;/* clear both feature bytes */
|
||||
status = USB_Class_CDC_PSTN_Set_Comm_Feature(controller_ID,
|
||||
setup_packet, data, size);
|
||||
break;
|
||||
case GET_LINE_CODING :
|
||||
status = USB_Class_CDC_PSTN_Get_Line_Coding(controller_ID,
|
||||
setup_packet, data, size);
|
||||
break;
|
||||
case SET_LINE_CODING :
|
||||
status = USB_Class_CDC_PSTN_Set_Line_Coding(controller_ID,
|
||||
setup_packet, data, size);
|
||||
break;
|
||||
case SET_CONTROL_LINE_STATE :
|
||||
status = USB_Class_CDC_PSTN_Set_Ctrl_Line_State(controller_ID,
|
||||
setup_packet, data, size);
|
||||
break;
|
||||
case SEND_BREAK :
|
||||
status = USB_Class_CDC_PSTN_Send_Break(controller_ID,
|
||||
setup_packet, data, size);
|
||||
break;
|
||||
default:
|
||||
*size=0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if((setup_packet->request_type & USB_REQUEST_CLASS_MASK) ==
|
||||
USB_REQUEST_CLASS_VENDOR)
|
||||
{
|
||||
/* vendor specific request */
|
||||
if(g_vendor_req_callback != NULL)
|
||||
{
|
||||
status = g_vendor_req_callback(controller_ID, setup_packet, data,
|
||||
size);
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Global Functions
|
||||
*****************************************************************************/
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Class_CDC_Init
|
||||
*
|
||||
* @brief The function initializes the Device and Controller layer
|
||||
*
|
||||
* @param controller_ID: Controller ID
|
||||
* @param cdc_class_callback: CDC Class Callback
|
||||
* @param vendor_req_callback: vendor specific class request callback
|
||||
* @param param_callback: PSTN Callback
|
||||
*
|
||||
* @return status
|
||||
* USB_OK : When Successfull
|
||||
* Others : Errors
|
||||
******************************************************************************
|
||||
* This function initializes the CDC Class layer and layers it is dependent upon
|
||||
*****************************************************************************/
|
||||
uint_8 USB_Class_CDC_Init (
|
||||
uint_8 controller_ID, /* [IN] Controller ID */
|
||||
USB_CLASS_CALLBACK cdc_class_callback, /* [IN] CDC Class Callback */
|
||||
USB_REQ_FUNC vendor_req_callback, /* [IN] Vendor Request Callback */
|
||||
USB_CLASS_CALLBACK pstn_callback, /* [IN] PSTN Callback */
|
||||
uint_8 bVregEn /* Enables or disables internal regulator */
|
||||
)
|
||||
{
|
||||
uint_8 index,status = USB_OK;
|
||||
USB_ENDPOINTS *usb_ep_data =
|
||||
(USB_ENDPOINTS *)USB_Desc_Get_Endpoints(controller_ID);
|
||||
#ifndef COMPOSITE_DEV
|
||||
/* Initialize the device layer*/
|
||||
status = _usb_device_init(controller_ID, NULL,
|
||||
(uint_8)(usb_ep_data->count+1), bVregEn);
|
||||
/* +1 is for Control Endpoint */
|
||||
|
||||
if(status == USB_OK)
|
||||
{
|
||||
/* Initialize the generic class functions */
|
||||
status = USB_Class_Init(controller_ID,USB_Class_CDC_Event,
|
||||
USB_Other_Requests);
|
||||
#endif
|
||||
#if IMPLEMENT_QUEUING
|
||||
for(index = 0; index < usb_ep_data->count; index++)
|
||||
{
|
||||
g_cdc_ep[index].endpoint = usb_ep_data->ep[index].ep_num;
|
||||
g_cdc_ep[index].type = usb_ep_data->ep[index].type;
|
||||
g_cdc_ep[index].bin_consumer = 0x00;
|
||||
g_cdc_ep[index].bin_producer = 0x00;
|
||||
}
|
||||
#endif
|
||||
#if PSTN_SUBCLASS_NOTIF_SUPPORT
|
||||
/* Initialize the pstn subclass functions */
|
||||
status = USB_Class_CDC_Pstn_Init(controller_ID,pstn_callback);
|
||||
#endif
|
||||
if(status == USB_OK)
|
||||
{
|
||||
/* save the callback pointer */
|
||||
g_cdc_class_callback = cdc_class_callback;
|
||||
|
||||
/* save the callback pointer */
|
||||
g_vendor_req_callback = vendor_req_callback;
|
||||
}
|
||||
#ifndef COMPOSITE_DEV
|
||||
}
|
||||
#endif
|
||||
return status;
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Class_CDC_DeInit
|
||||
*
|
||||
* @brief The function de-initializes the Device and Controller layer
|
||||
*
|
||||
* @param controller_ID : Controller ID
|
||||
*
|
||||
* @return status:
|
||||
* USB_OK : When Successfull
|
||||
* Others : When Error
|
||||
*
|
||||
******************************************************************************
|
||||
*This function de-initializes the CDC Class layer
|
||||
*****************************************************************************/
|
||||
uint_8 USB_Class_CDC_DeInit
|
||||
(
|
||||
uint_8 controller_ID /* [IN] Controller ID */
|
||||
)
|
||||
{
|
||||
uint_8 status = USB_OK;
|
||||
#ifdef COMPOSITE_DEV
|
||||
UNUSED(controller_ID);
|
||||
#endif
|
||||
/* save the callback pointer */
|
||||
g_cdc_class_callback = NULL;
|
||||
|
||||
/* free the vendor request callback pointer */
|
||||
g_vendor_req_callback = NULL;
|
||||
|
||||
#ifndef COMPOSITE_DEV
|
||||
/* call common class deinit function */
|
||||
status = USB_Class_DeInit(controller_ID);
|
||||
|
||||
if(status == USB_OK)
|
||||
/* Call device deinit function */
|
||||
status = _usb_device_deinit();
|
||||
#endif
|
||||
return status;
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Class_CDC_Send_Data
|
||||
*
|
||||
* @brief This function is used to send data from CDC Class over send endpoints
|
||||
*
|
||||
* @param controller_ID : Controller ID
|
||||
* @param ep_num : Endpoint number
|
||||
* @param app_buff : Buffer to send
|
||||
* @param size : Length of the transfer
|
||||
*
|
||||
* @return status
|
||||
* USB_OK : When Successfull
|
||||
* Others : Errors
|
||||
******************************************************************************
|
||||
* Helper function. Sends DATA over CIC and DIC Interfaces to Host
|
||||
*****************************************************************************/
|
||||
uint_8 USB_Class_CDC_Send_Data (
|
||||
uint_8 controller_ID, /* [IN] Controller ID */
|
||||
uint_8 ep_num, /* [IN] Endpoint Number */
|
||||
uint_8_ptr app_buff, /* Pointer to Application Buffer */
|
||||
USB_PACKET_SIZE size /* Size of Application Buffer */
|
||||
)
|
||||
{
|
||||
uint_8 status = USB_OK;
|
||||
|
||||
#if IMPLEMENT_QUEUING
|
||||
uint_8 index;
|
||||
uint_8 producer, consumer;
|
||||
|
||||
USB_ENDPOINTS *usb_ep_data = (USB_ENDPOINTS *)
|
||||
USB_Desc_Get_Endpoints(controller_ID);
|
||||
|
||||
/* map the endpoint num to the index of the endpoint structure */
|
||||
for(index = 0; index < usb_ep_data->count; index++)
|
||||
{
|
||||
if(usb_ep_data->ep[index].ep_num == ep_num)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
producer = g_cdc_ep[index].bin_producer;
|
||||
consumer = g_cdc_ep[index].bin_consumer;
|
||||
|
||||
if(((uint_8)(producer - consumer)) != (uint_8)(MAX_QUEUE_ELEMS))
|
||||
{
|
||||
/* the bin is not full*/
|
||||
|
||||
uint_8 queue_num = (uint_8)(producer % MAX_QUEUE_ELEMS);
|
||||
|
||||
/* put all send request parameters in the endpoint data structure */
|
||||
g_cdc_ep[index].queue[queue_num].controller_ID = controller_ID;
|
||||
g_cdc_ep[index].queue[queue_num].channel = ep_num;
|
||||
g_cdc_ep[index].queue[queue_num].app_data.data_ptr = app_buff;
|
||||
g_cdc_ep[index].queue[queue_num].app_data.data_size = size;
|
||||
|
||||
/* increment producer bin by 1*/
|
||||
g_cdc_ep[index].bin_producer = ++producer;
|
||||
|
||||
if((uint_8)(producer - consumer) == (uint_8)1)
|
||||
{
|
||||
#endif
|
||||
status = USB_Class_Send_Data(controller_ID, ep_num, app_buff,size);
|
||||
#if IMPLEMENT_QUEUING
|
||||
}
|
||||
}
|
||||
else /* bin is full */
|
||||
{
|
||||
status = USBERR_DEVICE_BUSY;
|
||||
}
|
||||
#endif
|
||||
return status;
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
@@ -0,0 +1,202 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Freescale Semiconductor Inc.
|
||||
* (c) Copyright 2004-2009 Freescale Semiconductor, Inc.
|
||||
* ALL RIGHTS RESERVED.
|
||||
*
|
||||
******************************************************************************
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY FREESCALE "AS IS" AND ANY EXPRESSED OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL FREESCALE OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
**************************************************************************//*!
|
||||
*
|
||||
* @file usb_cdc.h
|
||||
*
|
||||
* @author
|
||||
*
|
||||
* @version
|
||||
*
|
||||
* @date May-28-2009
|
||||
*
|
||||
* @brief The file contains USB stack CDC class layer API header function.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef _USB_CDC_H
|
||||
#define _USB_CDC_H
|
||||
|
||||
/******************************************************************************
|
||||
* Includes
|
||||
*****************************************************************************/
|
||||
#include "types.h"
|
||||
#include "usb_descriptor.h"
|
||||
#include "usb_class.h"
|
||||
#include "usb_cdc_pstn.h"
|
||||
#include "usb_devapi.h"
|
||||
#ifdef COMPOSITE_DEV
|
||||
#include "usb_composite.h"
|
||||
#endif
|
||||
|
||||
/******************************************************************************
|
||||
* Constants - None
|
||||
*****************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Macro's
|
||||
*****************************************************************************/
|
||||
/* Class specific request Codes */
|
||||
#define SEND_ENCAPSULATED_COMMAND (0x00)
|
||||
#define GET_ENCAPSULATED_RESPONSE (0x01)
|
||||
#define SET_COMM_FEATURE (0x02)
|
||||
#define GET_COMM_FEATURE (0x03)
|
||||
#define CLEAR_COMM_FEATURE (0x04)
|
||||
#define SET_AUX_LINE_STATE (0x10)
|
||||
#define SET_HOOK_STATE (0x11)
|
||||
#define PULSE_SETUP (0x12)
|
||||
#define SEND_PULSE (0x13)
|
||||
#define SET_PULSE_TIME (0x14)
|
||||
#define RING_AUX_JACK (0x15)
|
||||
#define SET_LINE_CODING (0x20)
|
||||
#define GET_LINE_CODING (0x21)
|
||||
#define SET_CONTROL_LINE_STATE (0x22)
|
||||
#define SEND_BREAK (0x23)
|
||||
#define SET_RINGER_PARAMS (0x30)
|
||||
#define GET_RINGER_PARAMS (0x31)
|
||||
#define SET_OPERATION_PARAM (0x32)
|
||||
#define GET_OPERATION_PARAM (0x33)
|
||||
#define SET_LINE_PARAMS (0x34)
|
||||
#define GET_LINE_PARAMS (0x35)
|
||||
#define DIAL_DIGITS (0x36)
|
||||
#define SET_UNIT_PARAMETER (0x37)
|
||||
#define GET_UNIT_PARAMETER (0x38)
|
||||
#define CLEAR_UNIT_PARAMETER (0x39)
|
||||
#define GET_PROFILE (0x3A)
|
||||
#define SET_ETHERNET_MULTICAST_FILTERS (0x40)
|
||||
#define SET_ETHERNET_POW_PATTER_FILTER (0x41)
|
||||
#define GET_ETHERNET_POW_PATTER_FILTER (0x42)
|
||||
#define SET_ETHERNET_PACKET_FILTER (0x43)
|
||||
#define GET_ETHERNET_STATISTIC (0x44)
|
||||
#define SET_ATM_DATA_FORMAT (0x50)
|
||||
#define GET_ATM_DEVICE_STATISTICS (0x51)
|
||||
#define SET_ATM_DEFAULT_VC (0x52)
|
||||
#define GET_ATM_VC_STATISTICS (0x53)
|
||||
#define MDLM_SPECIFIC_REQUESTS_MASK (0x7F)
|
||||
|
||||
/* Class Specific Notification Codes */
|
||||
#define NETWORK_CONNECTION_NOTIF (0x00)
|
||||
#define RESPONSE_AVAIL_NOTIF (0x01)
|
||||
#define AUX_JACK_HOOK_STATE_NOTIF (0x08)
|
||||
#define RING_DETECT_NOTIF (0x09)
|
||||
#define SERIAL_STATE_NOTIF (0x20)
|
||||
#define CALL_STATE_CHANGE_NOTIF (0x28)
|
||||
#define LINE_STATE_CHANGE_NOTIF (0x29)
|
||||
#define CONNECTION_SPEED_CHANGE_NOTIF (0x2A)
|
||||
#define MDLM_SPECIFIC_NOTIF_MASK (0x5F)
|
||||
|
||||
/* Events to the Application */ /* 0 to 4 are reserved for class events */
|
||||
#define USB_APP_CDC_CARRIER_DEACTIVATED (0x21)
|
||||
#define USB_APP_CDC_CARRIER_ACTIVATED (0x22)
|
||||
|
||||
/* other macros */
|
||||
#define NOTIF_PACKET_SIZE (0x08)
|
||||
#define NOTIF_REQUEST_TYPE (0xA1)
|
||||
|
||||
/* macros for queuing */
|
||||
#define MAX_QUEUE_ELEMS (4)
|
||||
|
||||
#if CIC_NOTIF_ELEM_SUPPORT
|
||||
#define CIC_SEND_ENDPOINT CIC_NOTIF_ENDPOINT
|
||||
#endif
|
||||
|
||||
#if DIC_ISOCHRONOUS_SETTING
|
||||
#define DIC_SEND_ENDPOINT DIC_ISO_IN_ENDPOINT
|
||||
#define DIC_RECV_ENDPOINT DIC_ISO_OUT_ENDPOINT
|
||||
#else
|
||||
#define DIC_SEND_ENDPOINT DIC_BULK_IN_ENDPOINT
|
||||
#define DIC_RECV_ENDPOINT DIC_BULK_OUT_ENDPOINT
|
||||
#endif
|
||||
|
||||
/******************************************************************************
|
||||
* Types
|
||||
*****************************************************************************/
|
||||
#ifndef COMPOSITE_DEV
|
||||
typedef struct _app_data_struct
|
||||
{
|
||||
uint_8_ptr data_ptr; /* pointer to buffer */
|
||||
USB_PACKET_SIZE data_size; /* buffer size of endpoint */
|
||||
}APP_DATA_STRUCT;
|
||||
#endif
|
||||
|
||||
/* structure to hold a request in the endpoint queue */
|
||||
typedef struct _usb_class_cdc_queue
|
||||
{
|
||||
uint_8 controller_ID; /* Controller ID */
|
||||
uint_8 channel; /* Endpoint Number */
|
||||
APP_DATA_STRUCT app_data; /* Application Data Structure */
|
||||
}USB_CLASS_CDC_QUEUE, *PTR_USB_CLASS_CDC_QUEUE;
|
||||
|
||||
/* USB class cdc endpoint data */
|
||||
typedef struct _usb_class_cdc_endpoint
|
||||
{
|
||||
uint_8 endpoint; /* endpoint num */
|
||||
uint_8 type; /* type of endpoint (interrupt, bulk or isochronous) */
|
||||
uint_8 bin_consumer;/* the num of queued elements */
|
||||
uint_8 bin_producer;/* the num of de-queued elements */
|
||||
USB_CLASS_CDC_QUEUE queue[MAX_QUEUE_ELEMS]; /* queue data */
|
||||
}USB_CLASS_CDC_ENDPOINT;
|
||||
|
||||
/******************************************************************************
|
||||
* Global Functions
|
||||
*****************************************************************************/
|
||||
extern uint_8 USB_Class_CDC_Init (
|
||||
uint_8 controller_ID, /* [IN] Controller ID */
|
||||
USB_CLASS_CALLBACK cdc_class_callback, /* [IN] CDC Class Callback */
|
||||
USB_REQ_FUNC vendor_req_callback, /* [IN] Vendor Request Callback */
|
||||
USB_CLASS_CALLBACK pstn_callback, /* [IN] PSTN Callback */
|
||||
uint_8 bVregEn /* Enables or disables internal regulator */
|
||||
);
|
||||
|
||||
#ifdef COMPOSITE_DEV
|
||||
extern uint_8 USB_CDC_Other_Requests(uint_8 controller_ID,
|
||||
USB_SETUP_STRUCT * setup_packet,
|
||||
uint_8_ptr *data,
|
||||
USB_PACKET_SIZE *size);
|
||||
#endif
|
||||
|
||||
extern uint_8 USB_Class_CDC_DeInit
|
||||
(
|
||||
uint_8 controller_ID
|
||||
);
|
||||
|
||||
extern uint_8 USB_Class_CDC_Send_Data (
|
||||
uint_8 controller_ID,
|
||||
uint_8 ep_num,
|
||||
uint_8_ptr buff_ptr,
|
||||
USB_PACKET_SIZE size
|
||||
);
|
||||
|
||||
#if CIC_NOTIF_ELEM_SUPPORT
|
||||
#define USB_Class_CDC_Interface_CIC_Send_Data(a,b,c) \
|
||||
USB_Class_CDC_Send_Data(a,CIC_SEND_ENDPOINT,b,c)
|
||||
#endif
|
||||
|
||||
#define USB_Class_CDC_Interface_DIC_Send_Data(a,b,c) \
|
||||
USB_Class_CDC_Send_Data(a,DIC_SEND_ENDPOINT,b,c)
|
||||
#define USB_Class_CDC_Interface_DIC_Recv_Data(a,b,c) \
|
||||
_usb_device_recv_data(a,DIC_RECV_ENDPOINT,b,c)
|
||||
#define USB_Class_CDC_Interface_DIC_Get_Send_Buffer(a,b,c) \
|
||||
_usb_device_get_send_buffer(a,DIC_SEND_ENDPOINT,b,c)
|
||||
|
||||
#define USB_Class_CDC_Periodic_Task USB_Class_Periodic_Task
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,398 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Freescale Semiconductor Inc.
|
||||
* (c) Copyright 2004-2009 Freescale Semiconductor, Inc.
|
||||
* ALL RIGHTS RESERVED.
|
||||
*
|
||||
******************************************************************************
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY FREESCALE "AS IS" AND ANY EXPRESSED OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL FREESCALE OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
**************************************************************************//*!
|
||||
*
|
||||
* @file usb_cdc_pstn.c
|
||||
*
|
||||
* @author
|
||||
*
|
||||
* @version
|
||||
*
|
||||
* @date May-28-2009
|
||||
*
|
||||
* @brief The file contains USB CDC_PSTN Sub Class implementation.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Includes
|
||||
*****************************************************************************/
|
||||
#include "usb_cdc_pstn.h" /* USB CDC PSTN Sub Class Header File */
|
||||
|
||||
/*****************************************************************************
|
||||
* Constant and Macro's
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* Global Functions Prototypes
|
||||
*****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Global Variables
|
||||
****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* Local Types - None
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* Local Functions Prototypes
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* Local Variables
|
||||
*****************************************************************************/
|
||||
/* PSTN subclass callback pointer */
|
||||
static USB_CLASS_CALLBACK g_pstn_callback = NULL;
|
||||
/* data terminal equipment present or not */
|
||||
static boolean g_dte_present = FALSE;
|
||||
static uint_8 g_dte_status = 0; /* Status of DATA TERMINAL EQUIPMENT */
|
||||
static uint_16 g_break_duration = 0; /* Length of time in milliseconds of the
|
||||
break signal */
|
||||
static uint_8 g_current_interface = 0;
|
||||
static UART_BITMAP g_uart_bitmap;
|
||||
|
||||
#if CIC_NOTIF_ELEM_SUPPORT
|
||||
static uint_8 g_serial_state_buf[NOTIF_PACKET_SIZE+UART_BITMAP_SIZE] =
|
||||
{
|
||||
NOTIF_REQUEST_TYPE,SERIAL_STATE_NOTIF,
|
||||
0x00,0x00,/*wValue*/
|
||||
0x00,0x00,/*interface - modifies*/
|
||||
UART_BITMAP_SIZE,0x00,/* wlength*/
|
||||
0x00,0x00 /*data initialized - modifies*/
|
||||
};/*uart bitmap*/
|
||||
#endif
|
||||
/*****************************************************************************
|
||||
* Local Functions
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* Global Functions
|
||||
*****************************************************************************/
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Class_CDC_Pstn_Init
|
||||
*
|
||||
* @brief The function initializes the PSTN Module
|
||||
*
|
||||
* @param controller_ID : Controller ID
|
||||
* @param callback : PSTN Callback
|
||||
*
|
||||
* @return error
|
||||
* USB_OK : Always
|
||||
******************************************************************************
|
||||
* PSTN Sub Class Initialization routine
|
||||
*****************************************************************************/
|
||||
uint_8 USB_Class_CDC_Pstn_Init (
|
||||
uint_8 controller_ID, /* [IN] Controller ID */
|
||||
USB_CLASS_CALLBACK callback /* [IN] PSTN Callback */
|
||||
)
|
||||
{
|
||||
uint_8 error = USB_OK;
|
||||
UNUSED (controller_ID);
|
||||
|
||||
/* save input parameters */
|
||||
g_pstn_callback = callback;
|
||||
return error;
|
||||
}
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Class_CDC_PSTN_Get_Line_Coding
|
||||
*
|
||||
* @brief This function is called in response to GetLineCoding request
|
||||
*
|
||||
* @param controller_ID : Controller ID
|
||||
* @param setup_packet : Pointer to setup packet
|
||||
* @param data : Pointer to Data to be send
|
||||
* @param size : Pointer to Size of Data
|
||||
*
|
||||
* @return status:
|
||||
* USB_OK : When Successfull
|
||||
* USBERR_INVALID_REQ_TYPE: When request for
|
||||
* invalid Interface is presented
|
||||
******************************************************************************
|
||||
* Calls application to receive Line Coding Information
|
||||
*****************************************************************************/
|
||||
uint_8 USB_Class_CDC_PSTN_Get_Line_Coding (
|
||||
uint_8 controller_ID, /* [IN] Controller ID */
|
||||
USB_SETUP_STRUCT * setup_packet, /* [IN] Pointer to setup packet */
|
||||
uint_8_ptr *data, /* [OUT] Pointer to Data to be send */
|
||||
USB_PACKET_SIZE *size /* [OUT] Pointer to Size of Data */
|
||||
)
|
||||
{
|
||||
uint_8 status;
|
||||
UNUSED (size);
|
||||
g_current_interface = (uint_8)setup_packet->index ;
|
||||
status = USB_Desc_Get_Line_Coding(controller_ID, g_current_interface,
|
||||
data);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Class_CDC_PSTN_Set_Line_Coding
|
||||
*
|
||||
* @brief This function is called in response to SetLineCoding request
|
||||
*
|
||||
* @param controller_ID : Controller ID
|
||||
* @param setup_packet : Pointer to setup packet
|
||||
* @param data : Pointer to Data
|
||||
* @param size : Pointer to Size of Data
|
||||
*
|
||||
* @return status:
|
||||
* USB_OK : When Successfull
|
||||
* USBERR_INVALID_REQ_TYPE : When request for invalid
|
||||
* Interface is presented
|
||||
******************************************************************************
|
||||
* Calls Applciation to update Line Coding Information
|
||||
*****************************************************************************/
|
||||
uint_8 USB_Class_CDC_PSTN_Set_Line_Coding (
|
||||
uint_8 controller_ID, /* [IN] Controller ID */
|
||||
USB_SETUP_STRUCT * setup_packet, /* [IN] Pointer to setup packet */
|
||||
uint_8_ptr *data, /* [OUT] Pointer to Data */
|
||||
USB_PACKET_SIZE *size /* [OUT] Pointer to Size of Data */
|
||||
)
|
||||
{
|
||||
uint_8 status;
|
||||
UNUSED(data);
|
||||
|
||||
*size = 0;
|
||||
|
||||
g_current_interface = (uint_8)setup_packet->index ;
|
||||
status = USB_Desc_Set_Line_Coding(controller_ID, g_current_interface,
|
||||
(uint_8_ptr *)&setup_packet);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Class_CDC_PSTN_Set_Ctrl_Line_State
|
||||
*
|
||||
* @brief This function is called in response to Set Control Line State
|
||||
*
|
||||
* @param controller_ID : Controller ID
|
||||
* @param setup_packet : Pointer to setup packet
|
||||
* @param data : Pointer to Data
|
||||
* @param size : Pointer to Size of Data
|
||||
*
|
||||
* @return status:
|
||||
* USB_OK : Always
|
||||
******************************************************************************
|
||||
* Updates Control Line State
|
||||
*****************************************************************************/
|
||||
uint_8 USB_Class_CDC_PSTN_Set_Ctrl_Line_State (
|
||||
uint_8 controller_ID, /* [IN] Controller ID */
|
||||
USB_SETUP_STRUCT * setup_packet, /* [IN] Pointer to setup packet */
|
||||
uint_8_ptr *data, /* [OUT] Pointer to Data */
|
||||
USB_PACKET_SIZE *size /* [OUT] Pointer to Size of Data */
|
||||
)
|
||||
{
|
||||
UNUSED(data);
|
||||
*size = 0;
|
||||
|
||||
g_dte_status = (uint_8)setup_packet->value ;
|
||||
g_uart_bitmap._byte = 0x00; /* initialize */
|
||||
/* activate/deactivate Tx carrier */
|
||||
g_uart_bitmap.Bitmap_Uart.bTxCarrier = (g_dte_status &
|
||||
CARRIER_ACTIVATION_CHECK) ? 1 : 0 ;
|
||||
/* activate carrier and DTE */
|
||||
g_uart_bitmap.Bitmap_Uart.bRxCarrier = (g_dte_status &
|
||||
CARRIER_ACTIVATION_CHECK) ? 1 : 0 ;
|
||||
|
||||
/* Indicates to DCE if DTE is present or not */
|
||||
g_dte_present = (boolean)((g_dte_status & DTE_PRESENCE_CHECK) ?
|
||||
TRUE : FALSE);
|
||||
UNUSED(g_dte_present);
|
||||
#if CIC_NOTIF_ELEM_SUPPORT
|
||||
/* Send Notification to Host - Parameter on Device side has changed */
|
||||
USB_Class_CDC_PSTN_Send_Serial_State(controller_ID);
|
||||
#endif
|
||||
if(g_pstn_callback != NULL)
|
||||
{
|
||||
if(g_dte_status & CARRIER_ACTIVATION_CHECK)
|
||||
{
|
||||
g_pstn_callback(controller_ID, USB_APP_CDC_CARRIER_ACTIVATED,
|
||||
NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_pstn_callback(controller_ID, USB_APP_CDC_CARRIER_DEACTIVATED,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
return USB_OK;
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Class_CDC_PSTN_Send_Break
|
||||
*
|
||||
* @brief This function is called in response to Set Config request
|
||||
*
|
||||
* @param controller_ID : Controller ID
|
||||
* @param setup_packet : Pointer to setup packet
|
||||
* @param data : Pointer to Data
|
||||
* @param size : Pointer to Size of Data
|
||||
*
|
||||
* @return status:
|
||||
* USB_OK : Always
|
||||
******************************************************************************
|
||||
* Updates Break Duration Information from Host
|
||||
*****************************************************************************/
|
||||
uint_8 USB_Class_CDC_PSTN_Send_Break (
|
||||
uint_8 controller_ID, /* [IN] Controller ID */
|
||||
USB_SETUP_STRUCT * setup_packet, /* [IN] Pointer to setup packet */
|
||||
uint_8_ptr *data, /* [OUT] Pointer to Data */
|
||||
USB_PACKET_SIZE *size /* [OUT] Pointer to Size of Data */
|
||||
)
|
||||
{
|
||||
UNUSED (controller_ID);
|
||||
UNUSED (data);
|
||||
*size = 0;
|
||||
|
||||
g_break_duration = setup_packet->value;
|
||||
UNUSED(g_break_duration);
|
||||
|
||||
return USB_OK;
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Class_CDC_PSTN_Get_Comm_Feature
|
||||
*
|
||||
* @brief This function is called in response to GetCommFeature request
|
||||
*
|
||||
* @param controller_ID : Controller ID
|
||||
* @param setup_packet : Pointer to setup packet
|
||||
* @param data : Pointer to Data to be send
|
||||
* @param size : Pointer to Size of Data
|
||||
*
|
||||
* @return status:
|
||||
* USB_OK : When Successfull
|
||||
* USBERR_INVALID_REQ_TYPE : When request for invalid
|
||||
* Interface is presented
|
||||
******************************************************************************
|
||||
* Returns the status of the get comm feature request
|
||||
*****************************************************************************/
|
||||
uint_8 USB_Class_CDC_PSTN_Get_Comm_Feature (
|
||||
uint_8 controller_ID, /* [IN] Controller ID */
|
||||
USB_SETUP_STRUCT * setup_packet, /* [IN] Pointer to setup packet */
|
||||
uint_8_ptr *data, /* [OUT] Pointer to Data to send */
|
||||
USB_PACKET_SIZE *size /* [OUT] Pointer to Size of Data */
|
||||
)
|
||||
{ uint_8 status;
|
||||
|
||||
status = USB_OK;
|
||||
*size = COMM_FEATURE_DATA_SIZE;
|
||||
g_current_interface = (uint_8)setup_packet->index ;
|
||||
if(setup_packet->value == ABSTRACT_STATE_FEATURE)
|
||||
{
|
||||
status = USB_Desc_Get_Abstract_State(controller_ID,
|
||||
g_current_interface, data);
|
||||
}
|
||||
else if(setup_packet->value == COUNTRY_SETTING_FEATURE)
|
||||
{
|
||||
status = USB_Desc_Get_Country_Setting(controller_ID,
|
||||
g_current_interface, data);
|
||||
}
|
||||
else
|
||||
{
|
||||
*size = 0; /* for Reserved/Invalid Feature Selector Value */
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Class_CDC_PSTN_Set_Comm_Feature
|
||||
*
|
||||
* @brief This function is called in response to SetCommFeature request
|
||||
*
|
||||
* @param controller_ID : Controller ID
|
||||
* @param setup_packet : Pointer to setup packet
|
||||
* @param data : Pointer to Data
|
||||
* @param size : Pointer to Size of Data
|
||||
*
|
||||
* @return status:
|
||||
* USB_OK : When Successfull
|
||||
* USBERR_INVALID_REQ_TYPE : When request for invalid
|
||||
* Interface is presented
|
||||
******************************************************************************
|
||||
* Sets the comm feature specified by Host
|
||||
*****************************************************************************/
|
||||
uint_8 USB_Class_CDC_PSTN_Set_Comm_Feature (
|
||||
uint_8 controller_ID, /* [IN] Controller ID */
|
||||
USB_SETUP_STRUCT * setup_packet, /* [IN] Pointer to setup packet */
|
||||
uint_8_ptr *data, /* [OUT] Pointer to Data */
|
||||
USB_PACKET_SIZE *size /* [OUT] Pointer to Size of Data */
|
||||
)
|
||||
{
|
||||
uint_8 status;
|
||||
status = USB_OK;
|
||||
*size = COMM_FEATURE_DATA_SIZE;
|
||||
g_current_interface = (uint_8)setup_packet->index ;
|
||||
if(setup_packet->value == ABSTRACT_STATE_FEATURE)
|
||||
{
|
||||
status = USB_Desc_Set_Abstract_State(controller_ID,
|
||||
g_current_interface, data);
|
||||
}
|
||||
else if(setup_packet->value == COUNTRY_SETTING_FEATURE)
|
||||
{
|
||||
status = USB_Desc_Set_Country_Setting(controller_ID,
|
||||
g_current_interface, data);
|
||||
}
|
||||
else
|
||||
{
|
||||
*size = 0; /* for Reserved/Invalid Feature Selector Value */
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
#if CIC_NOTIF_ELEM_SUPPORT
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Class_CDC_PSTN_Send_Serial_State
|
||||
*
|
||||
* @brief This function is called to send serial state notification
|
||||
*
|
||||
* @param controller_ID : Controller ID
|
||||
*
|
||||
* @return NONE
|
||||
******************************************************************************
|
||||
* Returns the Serial State
|
||||
*****************************************************************************/
|
||||
void USB_Class_CDC_PSTN_Send_Serial_State (
|
||||
uint_8 controller_ID /* [IN] Controller ID */
|
||||
)
|
||||
{
|
||||
/* update array for current interface */
|
||||
g_serial_state_buf[4] = g_current_interface;
|
||||
/* Lower byte of UART BITMAP */
|
||||
g_serial_state_buf[NOTIF_PACKET_SIZE+UART_BITMAP_SIZE-2] =
|
||||
g_uart_bitmap._byte;
|
||||
(void)USB_Class_CDC_Interface_CIC_Send_Data(controller_ID,
|
||||
g_serial_state_buf, (NOTIF_PACKET_SIZE + UART_BITMAP_SIZE));
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Freescale Semiconductor Inc.
|
||||
* (c) Copyright 2004-2009 Freescale Semiconductor, Inc.
|
||||
* ALL RIGHTS RESERVED.
|
||||
*
|
||||
******************************************************************************
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY FREESCALE "AS IS" AND ANY EXPRESSED OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL FREESCALE OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
**************************************************************************//*!
|
||||
*
|
||||
* @file usb_cdc_pstn.h
|
||||
*
|
||||
* @author
|
||||
*
|
||||
* @version
|
||||
*
|
||||
* @date May-28-2009
|
||||
*
|
||||
* @brief The file contains USB CDC_PSTN Sub Class API header function
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef _USB_CDC_PSTN_H
|
||||
#define _USB_CDC_PSTN_H
|
||||
|
||||
/******************************************************************************
|
||||
* Includes
|
||||
*****************************************************************************/
|
||||
#include "usb_cdc.h" /* USB CDC Class Header File */
|
||||
/******************************************************************************
|
||||
* Constants - None
|
||||
*****************************************************************************/
|
||||
#ifdef __MCF52xxx_H__
|
||||
#pragma reverse_bitfields on
|
||||
#endif
|
||||
typedef struct _BITMAP_UART
|
||||
{
|
||||
uint_8 bRxCarrier : 1; /* Receive Carrier Activation Flag */
|
||||
uint_8 bTxCarrier : 1; /* Transmit Carrier Activation Flag */
|
||||
uint_8 bBreak : 1; /* Break Flag */
|
||||
uint_8 bRingSignal : 1; /* Ring Signal Flag */
|
||||
uint_8 bFraming : 1; /* Frame Flag */
|
||||
uint_8 bParity : 1; /* Parity Flag */
|
||||
uint_8 bOverRun : 1; /* OverRun Flag */
|
||||
uint_8 reserved1 : 1; /* Reserved */
|
||||
}BITMAP_UART;
|
||||
#ifdef __MCF52xxx_H__
|
||||
#pragma reverse_bitfields off
|
||||
#endif
|
||||
|
||||
|
||||
typedef union _UART_BITMAP
|
||||
{
|
||||
uint_8 _byte;
|
||||
BITMAP_UART Bitmap_Uart;
|
||||
}UART_BITMAP; /* UART STATE BITMAP */
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* Macro's
|
||||
*****************************************************************************/
|
||||
#define UART_BITMAP_SIZE (0x02)
|
||||
#define ABSTRACT_STATE_FEATURE (0x01)
|
||||
#define COUNTRY_SETTING_FEATURE (0x02)
|
||||
#define CARRIER_ACTIVATION_CHECK (0x02)
|
||||
#define DTE_PRESENCE_CHECK (0x01)
|
||||
|
||||
extern uint_8 USB_Class_CDC_Pstn_Init (
|
||||
uint_8 controller_ID,
|
||||
USB_CLASS_CALLBACK callback
|
||||
);
|
||||
|
||||
extern uint_8 USB_Class_CDC_PSTN_Get_Line_Coding (
|
||||
uint_8 controller_ID,
|
||||
USB_SETUP_STRUCT * setup_packet,
|
||||
uint_8_ptr *data,
|
||||
USB_PACKET_SIZE *size);
|
||||
|
||||
extern uint_8 USB_Class_CDC_PSTN_Set_Line_Coding (
|
||||
uint_8 controller_ID,
|
||||
USB_SETUP_STRUCT * setup_packet,
|
||||
uint_8_ptr *data,
|
||||
USB_PACKET_SIZE *size);
|
||||
|
||||
extern uint_8 USB_Class_CDC_PSTN_Set_Ctrl_Line_State (
|
||||
uint_8 controller_ID,
|
||||
USB_SETUP_STRUCT * setup_packet,
|
||||
uint_8_ptr *data,
|
||||
USB_PACKET_SIZE *size);
|
||||
|
||||
extern uint_8 USB_Class_CDC_PSTN_Send_Break (
|
||||
uint_8 controller_ID,
|
||||
USB_SETUP_STRUCT * setup_packet,
|
||||
uint_8_ptr *data,
|
||||
USB_PACKET_SIZE *size);
|
||||
|
||||
extern uint_8 USB_Class_CDC_PSTN_Get_Comm_Feature (
|
||||
uint_8 controller_ID,
|
||||
USB_SETUP_STRUCT * setup_packet,
|
||||
uint_8_ptr *data,
|
||||
USB_PACKET_SIZE *size);
|
||||
|
||||
extern uint_8 USB_Class_CDC_PSTN_Set_Comm_Feature (
|
||||
uint_8 controller_ID,
|
||||
USB_SETUP_STRUCT * setup_packet,
|
||||
uint_8_ptr *data,
|
||||
USB_PACKET_SIZE *size);
|
||||
|
||||
#if CIC_NOTIF_ELEM_SUPPORT
|
||||
extern void USB_Class_CDC_PSTN_Send_Serial_State (uint_8 controller_ID);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,493 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Freescale Semiconductor Inc.
|
||||
* (c) Copyright 2004-2010 Freescale Semiconductor, Inc.
|
||||
* ALL RIGHTS RESERVED.
|
||||
*
|
||||
******************************************************************************
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY FREESCALE "AS IS" AND ANY EXPRESSED OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL FREESCALE OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
**************************************************************************//*!
|
||||
*
|
||||
* @file usb_class.c
|
||||
*
|
||||
* @author
|
||||
*
|
||||
* @version
|
||||
*
|
||||
* @date
|
||||
*
|
||||
* @brief The file contains USB stack Class module implementation.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Includes
|
||||
*****************************************************************************/
|
||||
#include "usb_class.h" /* USB class Header File */
|
||||
#include "usb_devapi.h" /* USB device Header file */
|
||||
#include "usb_framework.h" /* USB framework module header file */
|
||||
#include "hidef.h" /* for EnableInterrupts; macro */
|
||||
|
||||
#if 0 /* << EST */
|
||||
#if (defined _MCF51MM256_H) || (defined _MCF51JE256_H)
|
||||
#include "exceptions.h"
|
||||
#endif
|
||||
#else
|
||||
/* device is Kinetis K20D72 << EST */
|
||||
#endif
|
||||
/*****************************************************************************
|
||||
* Constant and Macro's
|
||||
*****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Global Variables
|
||||
****************************************************************************/
|
||||
/* Class callback pointer */
|
||||
static USB_CLASS_CALLBACK g_class_callback = NULL;
|
||||
/* save the device state before device goes to suspend state */
|
||||
static uint_8 g_device_state_before_suspend;
|
||||
/*****************************************************************************
|
||||
* Local Types - None
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* Local Functions Prototypes
|
||||
*****************************************************************************/
|
||||
void USB_Suspend_Service (PTR_USB_DEV_EVENT_STRUCT event );
|
||||
void USB_Resume_Service (PTR_USB_DEV_EVENT_STRUCT event );
|
||||
void USB_Stall_Service (PTR_USB_DEV_EVENT_STRUCT event );
|
||||
void USB_Sof_Service (PTR_USB_DEV_EVENT_STRUCT event );
|
||||
void USB_Reset_Service (PTR_USB_DEV_EVENT_STRUCT event );
|
||||
void USB_Error_Service (PTR_USB_DEV_EVENT_STRUCT event );
|
||||
|
||||
/*****************************************************************************
|
||||
* Local Variables
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* Local Functions - None
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* Global Functions
|
||||
*****************************************************************************/
|
||||
#if 0 /* << EST */
|
||||
#if (defined(_MC9S08MM128_H) || defined(_MC9S08JE128_H))
|
||||
#pragma CODE_SEG DEFAULT
|
||||
#endif
|
||||
#else
|
||||
/* device is Kinetis K20D72 << EST */
|
||||
#endif
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Suspend_Service
|
||||
*
|
||||
* @brief The function is called when host suspends the USB port
|
||||
*
|
||||
* @param event : Pointer to USB Event Structure
|
||||
*
|
||||
* @return None
|
||||
******************************************************************************
|
||||
* Sets the device state as USB_STATE_SUSPEND
|
||||
*****************************************************************************/
|
||||
void USB_Suspend_Service (
|
||||
PTR_USB_DEV_EVENT_STRUCT event /* [IN] Pointer to USB Event Structure */
|
||||
)
|
||||
{
|
||||
/* Get the status of the device before suspend, so that on resume we
|
||||
can get back to the same state */
|
||||
(void)_usb_device_get_status(&(event->controller_ID),
|
||||
USB_STATUS_DEVICE_STATE, &g_device_state_before_suspend);
|
||||
/* Set the device state in the Device Layer to SUSPEND */
|
||||
(void)_usb_device_set_status(&(event->controller_ID), USB_STATUS_DEVICE_STATE,
|
||||
USB_STATE_SUSPEND);
|
||||
|
||||
/* let the application know that bus suspend has taken place */
|
||||
g_class_callback(event->controller_ID, USB_APP_BUS_SUSPEND, NULL);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Resume_Service
|
||||
*
|
||||
* @brief The function is called when host resumes the USB port
|
||||
*
|
||||
* @param event : Pointer to USB Event Structure
|
||||
*
|
||||
* @return None
|
||||
******************************************************************************
|
||||
* Restore the state of the device before suspend
|
||||
*****************************************************************************/
|
||||
void USB_Resume_Service (
|
||||
PTR_USB_DEV_EVENT_STRUCT event /* [IN] Pointer to USB Event Structure */
|
||||
)
|
||||
{
|
||||
uint_8 device_state;
|
||||
(void)_usb_device_get_status(&(event->controller_ID), USB_STATUS_DEVICE_STATE,
|
||||
&device_state);
|
||||
if(device_state == USB_STATE_SUSPEND)
|
||||
{
|
||||
/*
|
||||
Set the device state in the Device Layer to the state
|
||||
before suspend
|
||||
*/
|
||||
(void)_usb_device_set_status(&(event->controller_ID),
|
||||
USB_STATUS_DEVICE_STATE, g_device_state_before_suspend);
|
||||
}
|
||||
|
||||
/* let the application know that bus resume has taken place */
|
||||
g_class_callback(event->controller_ID, USB_APP_BUS_RESUME, NULL);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Stall_Service
|
||||
*
|
||||
* @brief The function is called when endpoint is stalled
|
||||
*
|
||||
* @param event: Pointer to USB Event Structure
|
||||
*
|
||||
* @return None
|
||||
******************************************************************************
|
||||
* This function sends STALL Packet for the endpoint to be stalled. Also, sets
|
||||
* the status of Endpoint as STALLED
|
||||
*****************************************************************************/
|
||||
void USB_Stall_Service (
|
||||
PTR_USB_DEV_EVENT_STRUCT event /* [IN] Pointer to USB Event Structure */
|
||||
)
|
||||
{
|
||||
if(event->ep_num == CONTROL_ENDPOINT)
|
||||
{
|
||||
/* Update the Endpoint Status in the Device Layer to Idle */
|
||||
(void)_usb_device_set_status(&(event->controller_ID),
|
||||
(uint_8)(USB_STATUS_ENDPOINT | CONTROL_ENDPOINT |
|
||||
(event->direction << USB_COMPONENT_DIRECTION_SHIFT)),
|
||||
(uint_16)USB_STATUS_IDLE);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Sof_Service
|
||||
*
|
||||
* @brief The function is called when SOF flag is set (from ISR)
|
||||
*
|
||||
* @param event: Pointer to USB Event Structure
|
||||
*
|
||||
* @return None
|
||||
******************************************************************************
|
||||
* This function is called when SOF token is received by controller. Updates
|
||||
* SOF Count status.
|
||||
*****************************************************************************/
|
||||
void USB_Sof_Service (
|
||||
PTR_USB_DEV_EVENT_STRUCT event /* [IN] Pointer to USB Event Structure */
|
||||
)
|
||||
{
|
||||
uint_16 sof_count;
|
||||
|
||||
/* update SOF */
|
||||
sof_count = event->buffer_ptr[0];
|
||||
sof_count <<= SOF_HIGH_BYTE_SHIFT;
|
||||
sof_count |= event->buffer_ptr[1];
|
||||
|
||||
/* write SOF to status */
|
||||
(void)_usb_device_set_status(&(event->controller_ID), USB_STATUS_SOF_COUNT,
|
||||
(uint_8)sof_count);
|
||||
return;
|
||||
}
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Reset_Service
|
||||
*
|
||||
* @brief The function is called upon a bus reset event.
|
||||
Initializes the control endpoint.
|
||||
*
|
||||
* @param event: Pointer to USB Event Structure
|
||||
*
|
||||
* @return None
|
||||
******************************************************************************
|
||||
* Reset Callback function. This function re-initializes CONTROL Endpoint
|
||||
*****************************************************************************/
|
||||
void USB_Reset_Service (
|
||||
PTR_USB_DEV_EVENT_STRUCT event /* [IN] Pointer to USB Event Structure */
|
||||
)
|
||||
{
|
||||
|
||||
USB_EP_STRUCT ep_struct;
|
||||
uint_8 err;
|
||||
|
||||
/* Initialize the endpoint 0 in both directions */
|
||||
ep_struct.direction = USB_SEND;
|
||||
ep_struct.ep_num = CONTROL_ENDPOINT;
|
||||
ep_struct.size = CONTROL_MAX_PACKET_SIZE;
|
||||
ep_struct.type = USB_CONTROL_PIPE;
|
||||
|
||||
/* Deinit Endpoint in case its already initialized */
|
||||
err = _usb_device_deinit_endpoint(&(event->controller_ID),
|
||||
ep_struct.ep_num, ep_struct.direction);
|
||||
/* now initialize the endpoint */
|
||||
err = _usb_device_init_endpoint(&(event->controller_ID),
|
||||
ep_struct.ep_num, (uint_16)ep_struct.size, ep_struct.direction, ep_struct.type, TRUE);
|
||||
|
||||
ep_struct.direction = USB_RECV;
|
||||
/* Deinit Endpoint in case its already initialized */
|
||||
(void)_usb_device_deinit_endpoint(&(event->controller_ID),
|
||||
ep_struct.ep_num, ep_struct.direction);
|
||||
/* now initialize the endpoint */
|
||||
(void)_usb_device_init_endpoint(&(event->controller_ID),
|
||||
ep_struct.ep_num, (uint_16)ep_struct.size, ep_struct.direction, ep_struct.type, TRUE);
|
||||
|
||||
/* set the default device state */
|
||||
(void)_usb_device_set_status(&(event->controller_ID), USB_STATUS_DEVICE_STATE,
|
||||
USB_STATE_DEFAULT);
|
||||
|
||||
/* set the default device state */
|
||||
(void)_usb_device_set_status(&(event->controller_ID), USB_STATUS_DEVICE,
|
||||
SELF_POWERED >> SELF_POWER_BIT_SHIFT);
|
||||
|
||||
/* set the EndPoint Status as Idle in the device layer */
|
||||
(void)_usb_device_set_status(&(event->controller_ID),
|
||||
(uint_8)(USB_STATUS_ENDPOINT | CONTROL_ENDPOINT |
|
||||
(USB_SEND << USB_COMPONENT_DIRECTION_SHIFT)),
|
||||
USB_STATUS_IDLE);
|
||||
/* let the application know that bus reset has taken place */
|
||||
g_class_callback(event->controller_ID, USB_APP_BUS_RESET, NULL);
|
||||
|
||||
UNUSED(err);
|
||||
return;
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Error_Service
|
||||
*
|
||||
* @brief The function is called when an error has been detected
|
||||
*
|
||||
* @param event: Pointer to USB Event Structure
|
||||
*
|
||||
* @return None
|
||||
******************************************************************************
|
||||
* Calls application with the error code received from the lower layer
|
||||
*****************************************************************************/
|
||||
void USB_Error_Service (
|
||||
PTR_USB_DEV_EVENT_STRUCT event /* [IN] Pointer to USB Event Structure */
|
||||
)
|
||||
{
|
||||
/* notify the application of the error */
|
||||
g_class_callback(event->controller_ID, USB_APP_ERROR,
|
||||
(uint_8*)(&(event->errors)));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Class_Init
|
||||
*
|
||||
* @brief The function initializes the Class Module
|
||||
*
|
||||
* @param controller_ID : Controller ID
|
||||
* @param class_callback : Class callback
|
||||
* @param other_req_callback : Other Requests Callback
|
||||
*
|
||||
* @return status
|
||||
* USB_OK : When Successfull
|
||||
* Others : Errors
|
||||
******************************************************************************
|
||||
* Initializes USB Class Module
|
||||
*****************************************************************************/
|
||||
uint_8 USB_Class_Init (
|
||||
uint_8 controller_ID, /* [IN] Controller ID */
|
||||
USB_CLASS_CALLBACK class_callback, /* [IN] Class Callback */
|
||||
USB_REQ_FUNC other_req_callback /* [IN] Other Requests Callback */
|
||||
)
|
||||
{
|
||||
uint_8 status = USB_Framework_Init(controller_ID,class_callback,
|
||||
other_req_callback);
|
||||
|
||||
/* save callback address */
|
||||
g_class_callback = class_callback;
|
||||
|
||||
if(status == USB_OK)
|
||||
{
|
||||
/* Register all the services here */
|
||||
status |= _usb_device_register_service(controller_ID,
|
||||
USB_SERVICE_BUS_RESET, USB_Reset_Service);
|
||||
status |= _usb_device_register_service(controller_ID,
|
||||
USB_SERVICE_SOF,USB_Sof_Service);
|
||||
status |= _usb_device_register_service(controller_ID,
|
||||
USB_SERVICE_SLEEP,USB_Suspend_Service);
|
||||
status |= _usb_device_register_service(controller_ID,
|
||||
USB_SERVICE_RESUME,USB_Resume_Service);
|
||||
status |= _usb_device_register_service(controller_ID,
|
||||
USB_SERVICE_STALL,USB_Stall_Service);
|
||||
status |= _usb_device_register_service(controller_ID,
|
||||
USB_SERVICE_ERROR,USB_Error_Service);
|
||||
|
||||
/* set the device state as powered */
|
||||
(void)_usb_device_set_status(&controller_ID,
|
||||
USB_STATUS_DEVICE_STATE,USB_STATE_POWERED);
|
||||
g_device_state_before_suspend = USB_STATE_POWERED;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Class_DeInit
|
||||
*
|
||||
* @brief The function De-initializes the Class Module
|
||||
*
|
||||
* @param controller_ID : Controller ID
|
||||
*
|
||||
* @return status
|
||||
* USB_OK : When Successfull
|
||||
* Others : Errors
|
||||
******************************************************************************
|
||||
* De-initializes USB Class Module
|
||||
*****************************************************************************/
|
||||
uint_8 USB_Class_DeInit
|
||||
(
|
||||
uint_8 controller_ID /* [IN] Controller ID */
|
||||
)
|
||||
{
|
||||
uint_8 status = USB_OK;
|
||||
/* Free class_callback */
|
||||
g_class_callback = NULL;
|
||||
|
||||
/* Unegister all the services here */
|
||||
status |= _usb_device_unregister_service(&controller_ID,USB_SERVICE_BUS_RESET);
|
||||
status |= _usb_device_unregister_service(&controller_ID,USB_SERVICE_SOF);
|
||||
status |= _usb_device_unregister_service(&controller_ID,USB_SERVICE_SLEEP);
|
||||
status |= _usb_device_unregister_service(&controller_ID,USB_SERVICE_RESUME);
|
||||
status |= _usb_device_unregister_service(&controller_ID,USB_SERVICE_STALL);
|
||||
status |= _usb_device_unregister_service(&controller_ID,USB_SERVICE_ERROR);
|
||||
|
||||
if(status == USB_OK)
|
||||
/* Call Framework deinit function */
|
||||
status = USB_Framework_DeInit(controller_ID);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Class_Initiate_Resume
|
||||
*
|
||||
* @brief The function initiates resume procedure
|
||||
*
|
||||
* @param controller_ID : Controller ID
|
||||
*
|
||||
* @return device_state
|
||||
******************************************************************************/
|
||||
uint_8 USB_Class_Initiate_Resume(
|
||||
uint_8 controller_ID /* [IN] Controller ID */
|
||||
)
|
||||
{
|
||||
uint_8 device_state, state;
|
||||
|
||||
(void)_usb_device_get_status(&controller_ID, USB_STATUS_DEVICE_STATE,
|
||||
&device_state);
|
||||
(void)_usb_device_get_status(&controller_ID, USB_STATUS_DEVICE, &state);
|
||||
if((device_state == USB_STATE_SUSPEND) &&
|
||||
(state & REMOTE_WAKEUP_STATUS_MASK ) &&
|
||||
(USB_Frame_Remote_Wakeup(controller_ID) == TRUE))
|
||||
{
|
||||
DisableInterrupts;
|
||||
#if 0
|
||||
#if (defined _MCF51MM256_H) || (defined _MCF51JE256_H)
|
||||
usb_int_dis();
|
||||
#endif
|
||||
#else /* << EST */
|
||||
/* device is Kinetis K20D72 << EST */
|
||||
#endif
|
||||
/* Resume the bus */
|
||||
_usb_device_assert_resume(&controller_ID);
|
||||
|
||||
device_state = USB_STATE_CONFIG;
|
||||
/* Set the device state in the Device Layer to DEFAULT */
|
||||
(void)_usb_device_set_status(&controller_ID, USB_STATUS_DEVICE_STATE,
|
||||
USB_STATE_CONFIG);
|
||||
EnableInterrupts;;
|
||||
#if (defined _MCF51MM256_H) || (defined _MCF51JE256_H)
|
||||
usb_int_en();
|
||||
#endif
|
||||
}
|
||||
return device_state;
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Class_Send_Data
|
||||
*
|
||||
* @brief The function calls the device to send data upon receiving an IN token
|
||||
*
|
||||
* @param controller_ID : Controller ID
|
||||
* @param ep_num : Endpoint number
|
||||
* @param buff_ptr : Buffer to send
|
||||
* @param size : Length of transfer
|
||||
*
|
||||
* @return status
|
||||
* USB_OK : When Successfull
|
||||
* Others : Errors
|
||||
******************************************************************************
|
||||
* Used by Application to send Data on USB Bus if not suspended
|
||||
*****************************************************************************/
|
||||
uint_8 USB_Class_Send_Data (
|
||||
uint_8 controller_ID, /* [IN] Controller ID */
|
||||
uint_8 ep_num, /* [IN] Endpoint number */
|
||||
uint_8_ptr buff_ptr, /* [IN] Buffer to send */
|
||||
USB_PACKET_SIZE size /* [IN] Length of the transfer */
|
||||
)
|
||||
{
|
||||
|
||||
uint_8 status = USB_OK;
|
||||
uint_8 device_state;
|
||||
|
||||
device_state = USB_Class_Initiate_Resume(controller_ID);
|
||||
|
||||
if(device_state != USB_STATE_SUSPEND)
|
||||
{ /* if not suspended */
|
||||
status = _usb_device_send_data(&controller_ID, ep_num, buff_ptr, size);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Class_Periodic_Task
|
||||
*
|
||||
* @brief The function calls for periodic tasks
|
||||
*
|
||||
* @param None
|
||||
*
|
||||
* @return None
|
||||
******************************************************************************
|
||||
* Called to check for any pending requests
|
||||
*****************************************************************************/
|
||||
void USB_Class_Periodic_Task (void)
|
||||
{
|
||||
#ifdef DELAYED_PROCESSING
|
||||
USB_Framework_Periodic_Task();
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -0,0 +1,151 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Freescale Semiconductor Inc.
|
||||
* (c) Copyright 2004-2009 Freescale Semiconductor, Inc.
|
||||
* ALL RIGHTS RESERVED.
|
||||
*
|
||||
******************************************************************************
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY FREESCALE "AS IS" AND ANY EXPRESSED OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL FREESCALE OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
**************************************************************************//*!
|
||||
*
|
||||
* @file usb_class.h
|
||||
*
|
||||
* @author
|
||||
*
|
||||
* @version
|
||||
*
|
||||
* @date May-28-2009
|
||||
*
|
||||
* @brief The file contains USB stack class layer API header function.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef _USB_CLASS_H
|
||||
#define _USB_CLASS_H
|
||||
|
||||
|
||||
/*#define DELAYED_PROCESSING 1 This define is used to delay the control
|
||||
processing and not have it executed as part
|
||||
of the interrupt routine */
|
||||
/******************************************************************************
|
||||
* Includes
|
||||
*****************************************************************************/
|
||||
#include "types.h"
|
||||
#include "usb_devapi.h"
|
||||
|
||||
/******************************************************************************
|
||||
* Constants - None
|
||||
*****************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Macro's
|
||||
*****************************************************************************/
|
||||
#define SOF_HIGH_BYTE_SHIFT (8)
|
||||
#define GET_STATUS_DEVICE_MASK (0x0003)
|
||||
#ifdef OTG_BUILD
|
||||
#define GET_STATUS_OTG_MASK (0x0001)
|
||||
#endif
|
||||
#define REMOTE_WAKEUP_STATUS_MASK (0x0002)
|
||||
#define BUS_POWERED (0x80)
|
||||
#define SELF_POWERED (0x40)
|
||||
#define SELF_POWER_BIT_SHIFT (6)
|
||||
|
||||
/* Events to the Application */
|
||||
#define USB_APP_BUS_RESET (0)
|
||||
#define USB_APP_CONFIG_CHANGED (1)
|
||||
#define USB_APP_ENUM_COMPLETE (2)
|
||||
#define USB_APP_SEND_COMPLETE (3)
|
||||
#define USB_APP_DATA_RECEIVED (4)
|
||||
#define USB_APP_ERROR (5)
|
||||
#define USB_APP_GET_DATA_BUFF (6)
|
||||
#define USB_APP_EP_STALLED (7)
|
||||
#define USB_APP_EP_UNSTALLED (8)
|
||||
#define USB_APP_GET_TRANSFER_SIZE (9)
|
||||
#define USB_APP_BUS_SUSPEND (0x0A)
|
||||
#define USB_APP_BUS_RESUME (0x0B)
|
||||
|
||||
/* max packet size for the control endpoint */
|
||||
|
||||
/* USB Specs define CONTROL_MAX_PACKET_SIZE for High Speed device as only 64,
|
||||
whereas for FS its allowed to be 8, 16, 32 or 64 */
|
||||
|
||||
#if HIGH_SPEED_DEVICE
|
||||
#define CONTROL_MAX_PACKET_SIZE (64) /* max supported value is 64*/
|
||||
#else
|
||||
#define CONTROL_MAX_PACKET_SIZE (16) /* max supported value is 16*/
|
||||
#endif
|
||||
|
||||
/* identification values and masks to identify request types */
|
||||
#define USB_REQUEST_CLASS_MASK (0x60)
|
||||
#define USB_REQUEST_CLASS_STRD (0x00)
|
||||
#define USB_REQUEST_CLASS_CLASS (0x20)
|
||||
#define USB_REQUEST_CLASS_VENDOR (0x40)
|
||||
|
||||
/******************************************************************************
|
||||
* Types
|
||||
*****************************************************************************/
|
||||
/* eight byte usb setup packet structure */
|
||||
typedef struct _USB_SETUP_STRUCT {
|
||||
uint_8 request_type; /* bmRequestType */
|
||||
uint_8 request; /* Request code */
|
||||
uint_16 value; /* wValue */
|
||||
uint_16 index; /* wIndex */
|
||||
uint_16 length; /* Length of the data */
|
||||
} USB_SETUP_STRUCT;
|
||||
|
||||
/* callback function pointer structure for Application to handle events */
|
||||
typedef void(_CODE_PTR_ USB_CLASS_CALLBACK)(uint_8, uint_8, void*);
|
||||
|
||||
/* callback function pointer structure to handle USB framework request */
|
||||
typedef uint_8 (_CODE_PTR_ USB_REQ_FUNC)(uint_8, USB_SETUP_STRUCT *,
|
||||
uint_8_ptr*,
|
||||
USB_PACKET_SIZE*);
|
||||
|
||||
/*callback function pointer structure for application to provide class params*/
|
||||
typedef uint_8 (_CODE_PTR_ USB_CLASS_SPECIFIC_HANDLER_FUNC)(
|
||||
uint_8,
|
||||
uint_16,
|
||||
uint_16, // Application needs to know which Interface is being communicated with
|
||||
uint_8_ptr*,
|
||||
USB_PACKET_SIZE*);
|
||||
|
||||
/******************************************************************************
|
||||
* Global Functions
|
||||
*****************************************************************************/
|
||||
extern uint_8 USB_Class_Init (
|
||||
uint_8 controller_ID,
|
||||
USB_CLASS_CALLBACK class_callback,
|
||||
USB_REQ_FUNC other_req_callback
|
||||
);
|
||||
|
||||
extern uint_8 USB_Class_DeInit
|
||||
(
|
||||
uint_8 controller_ID
|
||||
);
|
||||
|
||||
extern uint_8 USB_Class_Initiate_Resume(
|
||||
uint_8 controller_ID
|
||||
);
|
||||
|
||||
extern uint_8 USB_Class_Send_Data (
|
||||
uint_8 controller_ID,
|
||||
uint_8 ep_num,
|
||||
uint_8_ptr buff_ptr,
|
||||
USB_PACKET_SIZE size
|
||||
);
|
||||
|
||||
extern void USB_Class_Periodic_Task(void);
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,311 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Freescale Semiconductor Inc.
|
||||
* (c) Copyright 2004-2010 Freescale Semiconductor, Inc.
|
||||
* ALL RIGHTS RESERVED.
|
||||
*
|
||||
******************************************************************************
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY FREESCALE "AS IS" AND ANY EXPRESSED OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL FREESCALE OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
**************************************************************************//*!
|
||||
*
|
||||
* @file usb_dci_kinetis.h
|
||||
*
|
||||
* @author
|
||||
*
|
||||
* @version
|
||||
*
|
||||
* @date
|
||||
*
|
||||
* @brief The file contains Macro's and functions needed by the DCI layer.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef _USB_DCI_H
|
||||
#define _USB_DCI_H
|
||||
/******************************************************************************
|
||||
* Includes
|
||||
*****************************************************************************/
|
||||
#include "types.h"
|
||||
#include "hal/derivative.h"
|
||||
#include "usb_devapi.h"
|
||||
|
||||
/******************************************************************************
|
||||
* Constants - None
|
||||
*****************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Macro's
|
||||
*****************************************************************************/
|
||||
#define BYTES_1024 (1024)
|
||||
#define BYTES_512 (512)
|
||||
#define ENDPT_EP_STALL_MASK (0x02)
|
||||
#define FRAME_HIGH_BYTE_SHIFT (8)
|
||||
|
||||
#ifdef USB_LOWPOWERMODE
|
||||
typedef enum _stopmode
|
||||
{
|
||||
STOP_MODE1 = 1, /* STOP MODE 1 */
|
||||
STOP_MODE2 = 2, /* STOP MODE 2 */
|
||||
STOP_MODE3 = 3, /* STOP MODE 3 */
|
||||
STOP_MODE4 = 4 /* STOP MODE 4 */
|
||||
}STOP_MODE;
|
||||
#endif
|
||||
|
||||
/* USBTRC0 Initialization Parameters */
|
||||
#define _USBPHYEN (0x01) /* Use internal transceiver */
|
||||
#define _USBPUEN (0x40) /* Use internal pull-up resistor */
|
||||
#define _USBREGEN (0x04) /* Use the internal regulator */
|
||||
#define _USBRESET (0x80)
|
||||
|
||||
#define UCFG_VAL (_USBPUEN|_USBREGEN)
|
||||
|
||||
#define CTL_RESET_VAL (0) /* value programmed to the CTL
|
||||
register in RESET */
|
||||
|
||||
#define EP_CTRL (0x0C) /* Cfg Control pipe for this endpoint */
|
||||
// HIGH_SPEED_DEVICE
|
||||
#if !HIGH_SPEED_DEVICE
|
||||
#define EP_OUT (0x08) /* Cfg OUT only pipe for this endpoint*/
|
||||
#define EP_IN (0x04) /* Cfg IN only pipe for this endpoint */
|
||||
#endif
|
||||
#define HSHK_EN (0x01) /* Enable handshake packet */
|
||||
/* Handshake should be disable for
|
||||
isochorous transfer */
|
||||
#define EP_CTL_DIS (0x10)
|
||||
|
||||
#define EP_DISABLE (0)
|
||||
|
||||
#define TRANSFER_INDEX(x) (x>>1)
|
||||
|
||||
#define MAX_EP_BUFFER_SIZE USB_MAX_EP_BUFFER_SIZE /*Max Endpoint Buffer Size*/
|
||||
|
||||
/* Macro's to check whether corresponding INT_STAT bit is set */
|
||||
#define BUS_RESET_FLAG(x) ((x) & 1)
|
||||
#define ERROR_FLAG(x) ((x) & 2)
|
||||
#define SOF_TOKEN_FLAG(x) ((x) & 4)
|
||||
#define SLEEP_FLAG(x) ((x) & 0x10)
|
||||
#define RESUME_FLAG(x) ((x) & 0x20)
|
||||
#define STALL_FLAG(x) ((x) & 0x80)
|
||||
#define TOKEN_COMPL_FLAG(x) ((x) & 8)
|
||||
|
||||
/* Setup the controller for Remote Wakeup */
|
||||
#define USB_DCI_WAKEUP \
|
||||
{ \
|
||||
USB0_ISTAT |= USB_ISTAT_RESUME_MASK; \
|
||||
USB0_INTEN &= ~USB_INTEN_RESUMEEN_MASK; \
|
||||
USB0_CTL &= ~USB_CTL_TXSUSPENDTOKENBUSY_MASK; \
|
||||
}
|
||||
|
||||
/* control endpoint transfer types */
|
||||
#define USB_TRF_UNKNOWN (0xFF)
|
||||
|
||||
|
||||
#define BDT_MIN_BUFFER_SIZE (16) /* space occupied by smallest
|
||||
buffer in BDT */
|
||||
|
||||
#define BDT_MIN_BUFFER_ADDR_INC (4) /* min offset increment
|
||||
correspoding to min buffer
|
||||
size */
|
||||
|
||||
#define BDT_OFFSET_SHIFT (4) /* bdt offset shift */
|
||||
|
||||
#define INVALID_BDT_INDEX (0xFF)/* invalid bdt index */
|
||||
|
||||
#define ENDPOINT_NUMBER_SHIFT (4) /* endpoint shift & mask to */
|
||||
#define ENDPOINT_NUMBER_MASK (0xF0)/* use in setting and getting
|
||||
status */
|
||||
|
||||
#define ENDPOINT_DIRECTION_SHIFT (3) /* direction shift & mask to */
|
||||
#define ENDPOINT_DIRECTION_MASK (0x08)/* be used for STAT byte
|
||||
in BDT */
|
||||
|
||||
#define SEND_CONTROL_ENDPOINT_BDT_INDEX (2) /* BDT Index for Control Endpoint
|
||||
SEND direction */
|
||||
#define RECV_CONTROL_ENDPOINT_BDT_INDEX (0) /* BDT Index for Control Endpoint
|
||||
RECV direction */
|
||||
|
||||
#define EPCTL_STALL (0x02)/* Stall bit in Endpoint
|
||||
Control Reg */
|
||||
|
||||
#define USB_SETUP_TOKEN (0x0d)/* Setup Token PID */
|
||||
#define USB_SETUP_DIRECTION (0x80)/* Data xfer direction
|
||||
for Setup packet */
|
||||
|
||||
#define INT_STAT_CLEAR_ALL (0xBF)/* Value to clear
|
||||
all Interrupts */
|
||||
#define ERR_STAT_CLEAR_ALL (0xBF)/* Value to clear
|
||||
all Errors */
|
||||
#define ERR_ENB_ENABLE_ALL (0xBF)/* Value to enable
|
||||
all Error Interrupts */
|
||||
#define INTENB_BUS_RESET_VAL (0x9F)/* Value to enable
|
||||
Interrupts in Bus Reset */
|
||||
#define INTENB_DISABLE_ALL_VAL (0x00)/* Value to disable all
|
||||
Interrupts */
|
||||
|
||||
#define MAX_USB_RAM_BUFFER_INDEX (14) /* MAX possible RAM buffer
|
||||
Index */
|
||||
|
||||
#define EP_START_BUFFER_ADDR (0x08)/* First USB_RAM buffer offset*/
|
||||
|
||||
#define ASSERT_RESUME_DELAY_COUNT (20000)/* Delay for assert resume, 48MHz clock */
|
||||
|
||||
#define NO_ERRORS (0) /* Init value for error */
|
||||
|
||||
#define USB_RAM_EVEN_BUFFER (0)
|
||||
#define USB_RAM_ODD_BUFFER (1)
|
||||
|
||||
#define SWAP16(val) (val)
|
||||
|
||||
#define SWAP32(val) (val)
|
||||
|
||||
/******************************************************************************
|
||||
* Types
|
||||
*****************************************************************************/
|
||||
#ifdef LONG_SEND_TRANSACTION
|
||||
#define LONG_TRANSACTION
|
||||
#endif
|
||||
|
||||
#ifdef LONG_RECEIVE_TRANSACTION
|
||||
#define LONG_TRANSACTION
|
||||
#endif
|
||||
|
||||
typedef union {
|
||||
uint_8 Byte;
|
||||
struct {
|
||||
uint_8 EP_HSHK :1; /* When set this bet enables an endpoint to perform handshaking during a transaction to this endpoint. This bit will generally be set unless the endpoint is Isochronous */
|
||||
uint_8 EP_STALL :1; /* When set this bit indicates that the endpoint is stalled */
|
||||
uint_8 EP_TX_EN :1; /* This bit, when set, enables the endpoint for TX transfers */
|
||||
uint_8 EP_RX_EN :1; /* This bit, when set, enables the endpoint for RX transfers */
|
||||
uint_8 EP_CTRL_DIS :1; /* This bit, when set, disables control (SETUP) transfers. When cleared, control transfers are enabled. This applies if and only if the EP_RX_EN and EP_TX_EN bits are also set */
|
||||
uint_8 :1;
|
||||
uint_8 RETRY_DIS :1; /* This is a Host mode only bit and is only present in the control register for endpoint 0 (ENDPT0) */
|
||||
uint_8 HOST_WO_HUB :1; /* This is a Host mode only bit and is only present in the control register for endpoint 0 (ENDPT0) */
|
||||
} Bits;
|
||||
} ENDPT0STR;
|
||||
|
||||
/* << EST pushing current packing */
|
||||
#pragma pack(push)
|
||||
#pragma pack(1)
|
||||
/* This structure is used to hold endpoint paramaetes and the
|
||||
transaction parameters on the IO's happening on them */
|
||||
typedef struct _BDT_ELEM
|
||||
{
|
||||
uint_16 len; /* endpoint max buffer len */
|
||||
uint_32 addr; /* endpoint buffer addr in USB_RAM */
|
||||
#ifdef LONG_TRANSACTION
|
||||
uint_8_ptr app_buffer; /* application buffer pointer */
|
||||
USB_PACKET_SIZE app_len; /* application buffer len */
|
||||
USB_PACKET_SIZE curr_offset; /* current offset for long transactions */
|
||||
#endif
|
||||
uint_8 flag; /* zero termination flag */
|
||||
uint_8 bdtmap_index; /* Corresponding to the buffer */
|
||||
uint_8 direction; /* Direction (Send/Receive) */
|
||||
uint_8 type; /* Type of Endpoint */
|
||||
} BDT_ELEM, *P_BDT_ELEM;
|
||||
#if defined(__CWCC__)
|
||||
#pragma options align = reset
|
||||
#elif defined(__IAR_SYSTEMS_ICC__)
|
||||
#pragma pack()
|
||||
#else /* gcc */
|
||||
/* << EST restoring previous packing */
|
||||
#pragma pack(pop)
|
||||
#endif
|
||||
|
||||
|
||||
uint_8 USB_DCI_DeInit(void);
|
||||
|
||||
/*****************************************************************************
|
||||
* Global Functions
|
||||
*****************************************************************************/
|
||||
//extern uint_8 USB_Device_Call_Service(
|
||||
// uint_8 type,
|
||||
// PTR_USB_DEV_EVENT_STRUCT event
|
||||
//);
|
||||
|
||||
#ifndef OTG_BUILD
|
||||
void USB_ISR(void);
|
||||
#endif
|
||||
|
||||
#if HIGH_SPEED_DEVICE
|
||||
/* Device Queue Head and Device Transfer Descriptor Related Defination */
|
||||
#define SIZE_OF_QHD 0x40
|
||||
#define SIZE_OF_DTD0 0x20
|
||||
#define SIZE_OF_DTD1 0x20
|
||||
#define dTD_SIZE_EPIN (SIZE_OF_DTD0 + SIZE_OF_DTD1) //0x40
|
||||
#define dTD_SIZE_EPOUT (SIZE_OF_DTD0 + SIZE_OF_DTD1) //0x40
|
||||
#define BUFFER_USED_PER_EP ((SIZE_OF_QHD + dTD_SIZE_EPIN) +(SIZE_OF_QHD + dTD_SIZE_EPOUT)) //0x100
|
||||
#define ZLT_ENABLE 0
|
||||
#define ZLT_DISABLE 1
|
||||
#define IOS_NOTSET 0
|
||||
#define IOS_SET 1
|
||||
#define IOC_NOTSET 0
|
||||
#define IOC_SET 1
|
||||
#define TERMINATE 1
|
||||
#define NOT_TERMINATE 0
|
||||
#define NO_STATUS 0
|
||||
#define ACTIVE 0x00000080
|
||||
#define EPOUT_COMPLETE 0x00000001
|
||||
#define EPIN_COMPLETE 0x00010000
|
||||
#define EPOUT_PRIME 0x00000001
|
||||
#define EPIN_PRIME 0x00010000
|
||||
#define EPOUT_ENABLE 0x00000080
|
||||
#define EPIN_ENABLE 0x00800000
|
||||
#define STALL_RX 0x00000001
|
||||
#define STALL_TX 0x00010000
|
||||
|
||||
/* Maximum packet size defination */
|
||||
#define MPS_8 8
|
||||
#define MPS_64 64
|
||||
|
||||
/* enum for endpoint numbers */
|
||||
enum {
|
||||
EP0,
|
||||
EP1,
|
||||
EP2,
|
||||
EP3,
|
||||
EP4,
|
||||
EP5
|
||||
};
|
||||
|
||||
enum {
|
||||
OUT,
|
||||
IN
|
||||
};
|
||||
|
||||
/* enum for data transfer type on endpoints */
|
||||
enum {
|
||||
CONTROL,
|
||||
ISOCHRONOUS,
|
||||
BULK,
|
||||
INTERRUPT
|
||||
};
|
||||
|
||||
/* Status of all transaction on USB */
|
||||
typedef enum {
|
||||
USB_SUCCESS,
|
||||
USB_FAILURE,
|
||||
USB_INVALID = -1 /* Always Keep this entry in last */
|
||||
} usb_status_t;
|
||||
|
||||
/* USB Device State which are handled by DCD */
|
||||
typedef enum {
|
||||
USB_DEV_DUMMY_STATE,
|
||||
USB_DEV_DEFAULT_STATE,
|
||||
USB_DEV_ADDRESSED_STATE,
|
||||
USB_DEV_CONFIGURED_STATE
|
||||
} usb_state_t;
|
||||
#endif // HIGH_SPEED_DEVICE
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,262 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Freescale Semiconductor Inc.
|
||||
* (c) Copyright 2004-2009 Freescale Semiconductor, Inc.
|
||||
* ALL RIGHTS RESERVED.
|
||||
*
|
||||
******************************************************************************
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY FREESCALE "AS IS" AND ANY EXPRESSED OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL FREESCALE OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
**************************************************************************//*!
|
||||
*
|
||||
* @file usb_dciapi.h
|
||||
*
|
||||
* @author
|
||||
*
|
||||
* @version
|
||||
*
|
||||
* @date Jun-05-2009
|
||||
*
|
||||
* @brief The file contains DCI api function definetions .
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef _USB_DCIAPI_H
|
||||
#define _USB_DCIAPI_H
|
||||
|
||||
/******************************************************************************
|
||||
* Includes
|
||||
*****************************************************************************/
|
||||
#include "types.h"
|
||||
#include "usb_devapi.h"
|
||||
|
||||
/******************************************************************************
|
||||
* Constants - None
|
||||
*****************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Macro's
|
||||
*****************************************************************************/
|
||||
#define MAX_SUPPORTED_ENDPOINTS (USB_SERVICE_MAX_EP + 1)
|
||||
/* Maximum endpoints supported */
|
||||
#define MIN_SUPPORTED_ENDPOINTS (1) /* Minimum endpoints supported */
|
||||
#define DOUBLE_BUFFERED_ENPOINT_NUMBER (0) /* First double buffered endpoint */
|
||||
|
||||
#ifdef MCU_MK70F12
|
||||
#define NUM_USB_CONTROLLERS (2)
|
||||
#else
|
||||
#define NUM_USB_CONTROLLERS (1)
|
||||
#endif
|
||||
|
||||
/******************************************************************************
|
||||
* Types
|
||||
*****************************************************************************/
|
||||
typedef enum USB_Controllers_t
|
||||
{
|
||||
MAX3353,
|
||||
ULPI
|
||||
}USB_Controllers_t;
|
||||
|
||||
#if HIGH_SPEED_DEVICE
|
||||
typedef struct dqh_setup_t {
|
||||
unsigned int dqh_word0;
|
||||
unsigned int dqh_word1;
|
||||
unsigned int dqh_word2;
|
||||
unsigned int dqh_word3;
|
||||
unsigned int dqh_word4;
|
||||
unsigned int dqh_word5;
|
||||
unsigned int dqh_word6;
|
||||
unsigned int dqh_word7;
|
||||
unsigned int dqh_word8;
|
||||
unsigned int dqh_word9;
|
||||
unsigned int dqh_word10;
|
||||
unsigned int dqh_word11;
|
||||
} dqh_setup_t;
|
||||
|
||||
typedef struct dtd_setup_t {
|
||||
unsigned int dtd_word0;
|
||||
unsigned int dtd_word1;
|
||||
unsigned int dtd_word2;
|
||||
unsigned int dtd_word3;
|
||||
unsigned int dtd_word4;
|
||||
unsigned int dtd_word5;
|
||||
unsigned int dtd_word6;
|
||||
unsigned int dtd_word7;
|
||||
} dtd_setup_t;
|
||||
|
||||
typedef struct dqh_t {
|
||||
unsigned int dqh_base;
|
||||
unsigned int next_link_ptr;
|
||||
unsigned int buffer_ptr0;
|
||||
unsigned int buffer_ptr1;
|
||||
unsigned int buffer_ptr2;
|
||||
unsigned int buffer_ptr3;
|
||||
unsigned int buffer_ptr4;
|
||||
unsigned short total_bytes;
|
||||
unsigned short mps;
|
||||
unsigned short current_offset;
|
||||
unsigned char zlt;
|
||||
unsigned char ios;
|
||||
unsigned char terminate;
|
||||
unsigned char ioc;
|
||||
unsigned char status;
|
||||
unsigned char mult;
|
||||
} dqh_t;
|
||||
|
||||
typedef struct dtd_t {
|
||||
unsigned int dtd_base;
|
||||
unsigned int next_link_ptr;
|
||||
unsigned int buffer_ptr0;
|
||||
unsigned int buffer_ptr1;
|
||||
unsigned int buffer_ptr2;
|
||||
unsigned int buffer_ptr3;
|
||||
unsigned int buffer_ptr4;
|
||||
unsigned short total_bytes;
|
||||
unsigned short current_offset;
|
||||
unsigned char terminate;
|
||||
unsigned char ioc;
|
||||
unsigned char status;
|
||||
} dtd_t;
|
||||
|
||||
typedef struct {
|
||||
unsigned int ep_dqh_base_addrs; /* Base Address of Queue Header */
|
||||
unsigned int ep_dtd_base_addrs; /* Base Address of Transfer Descriptor */
|
||||
unsigned int ep0_buffer_addrs; /* Buffer Addres for EP0 IN */
|
||||
unsigned int buffer1_address; /* Buffer1 address for bulk transfer */
|
||||
unsigned int buffer1_status; /* Status of Buffer1 */
|
||||
unsigned int buffer2_address; /* Buffer2 address for bulk transfer */
|
||||
unsigned int buffer2_status; /* Status of Buffer2 */
|
||||
} buffer_map_t;
|
||||
|
||||
/* USB standard device request*/
|
||||
typedef struct usb_standrd_device_request {
|
||||
unsigned char bmRequestType;
|
||||
unsigned char bRequest;
|
||||
unsigned short wValue;
|
||||
unsigned short wIndex;
|
||||
unsigned short wLength;
|
||||
} usb_standard_device_request_t;
|
||||
|
||||
#endif // HIGH_SPEED_DEVICE
|
||||
|
||||
/*****************************************************************************
|
||||
* Global Functions
|
||||
*****************************************************************************/
|
||||
extern uint_8 USB_DCI_Init(
|
||||
uint_8 controller_ID,
|
||||
uint_8 bVregEn
|
||||
);
|
||||
|
||||
extern uint_8 USB_DCI_Init_EndPoint(
|
||||
uint_8 controller_ID,
|
||||
USB_EP_STRUCT_PTR ep_ptr,
|
||||
boolean flag
|
||||
);
|
||||
|
||||
extern uint_8 USB_DCI_Cancel_Transfer(
|
||||
uint_8 controller_ID,
|
||||
uint_8 ep_num,
|
||||
uint_8 direction
|
||||
);
|
||||
|
||||
extern uint_8 USB_DCI_Deinit_EndPoint(
|
||||
uint_8 controller_ID,
|
||||
uint_8 ep_num,
|
||||
uint_8 direction
|
||||
);
|
||||
|
||||
extern void USB_DCI_Stall_EndPoint(
|
||||
uint_8 controller_ID,
|
||||
uint_8 ep_num,
|
||||
uint_8 direction
|
||||
);
|
||||
|
||||
extern void USB_DCI_Unstall_EndPoint(
|
||||
uint_8 controller_ID,
|
||||
uint_8 ep_num,
|
||||
uint_8 direction
|
||||
);
|
||||
|
||||
extern void USB_DCI_Get_Setup_Data(
|
||||
uint_8 controller_ID,
|
||||
uint_8 ep_num,
|
||||
uint8_ptr buff_ptr
|
||||
);
|
||||
|
||||
extern uint_8 USB_DCI_Get_Transfer_Status(
|
||||
uint_8 controller_ID,
|
||||
uint_8 ep_num,
|
||||
uint_8 direction
|
||||
);
|
||||
|
||||
extern void USB_DCI_Clear_DATA0_Endpoint(
|
||||
uint_8 ep_num,
|
||||
uint_8 direction
|
||||
);
|
||||
|
||||
extern uint_8 USB_DCI_Recv_Data(
|
||||
uint_8 controller_ID,
|
||||
uint_8 ep_num,
|
||||
uint8_ptr buff_ptr,
|
||||
USB_PACKET_SIZE size
|
||||
);
|
||||
|
||||
extern uint_8 USB_DCI_Send_Data(
|
||||
uint_8 controller_ID,
|
||||
uint_8 ep_num,
|
||||
uint8_ptr buff_ptr,
|
||||
USB_PACKET_SIZE size
|
||||
);
|
||||
|
||||
extern void USB_DCI_Set_Address(
|
||||
uint_8 controller_ID,
|
||||
uint_8 address
|
||||
);
|
||||
|
||||
extern void USB_DCI_Shutdown(
|
||||
uint_8 controller_ID
|
||||
);
|
||||
|
||||
extern void USB_DCI_Assert_Resume(
|
||||
uint_8 controller_ID
|
||||
);
|
||||
|
||||
extern void Clear_Mem(uint_8* start_addr,uint_32 count, uint_8 val);
|
||||
|
||||
#define USB_DCI_Cancel_Transfer _usb_device_cancel_transfer
|
||||
|
||||
#define USB_DCI_Recv_Data _usb_device_recv_data
|
||||
|
||||
#define USB_DCI_Send_Data _usb_device_send_data
|
||||
|
||||
#define USB_DCI_Shutdown _usb_device_shutdown
|
||||
|
||||
#define USB_DCI_Stall_EndPoint _usb_device_stall_endpoint
|
||||
|
||||
#define USB_DCI_Unstall_EndPoint _usb_device_unstall_endpoint
|
||||
|
||||
#define USB_DCI_Get_Transfer_Status _usb_device_get_transfer_status
|
||||
|
||||
#define USB_DCI_Clear_DATA0_Endpoint _usb_device_clear_data0_endpoint
|
||||
|
||||
#define USB_DCI_Get_Setup_Data _usb_device_read_setup_data
|
||||
|
||||
#define USB_DCI_Set_Address _usb_device_set_address
|
||||
|
||||
#define USB_DCI_Assert_Resume _usb_device_assert_resume
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,889 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Freescale Semiconductor Inc.
|
||||
* (c) Copyright 2004-2009 Freescale Semiconductor, Inc.
|
||||
* ALL RIGHTS RESERVED.
|
||||
*
|
||||
**************************************************************************//*!
|
||||
*
|
||||
* @file usb_descriptor.c
|
||||
*
|
||||
* @author
|
||||
*
|
||||
* @version
|
||||
*
|
||||
* @date May-28-2009
|
||||
*
|
||||
* @brief This file contains USB descriptors for Virtual COM Loopback
|
||||
* Application
|
||||
*****************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Includes
|
||||
*****************************************************************************/
|
||||
#include "hal/derivative.h"
|
||||
#include "types.h"
|
||||
#include "usb_class.h"
|
||||
#include "usb_descriptor.h"
|
||||
|
||||
#if (defined __MCF52xxx_H__)||(defined __MK_xxx_H__)
|
||||
/* Put CFV2 descriptors in RAM */
|
||||
#define USB_DESC_CONST
|
||||
#else
|
||||
#define USB_DESC_CONST const
|
||||
#endif
|
||||
|
||||
/*****************************************************************************
|
||||
* Constant and Macro's
|
||||
*****************************************************************************/
|
||||
/* structure containing details of all the endpoints used by this device */
|
||||
USB_DESC_CONST USB_ENDPOINTS usb_desc_ep =
|
||||
{
|
||||
CDC_DESC_ENDPOINT_COUNT,
|
||||
{
|
||||
#if DATA_CLASS_SUPPORT
|
||||
#if DIC_ISOCHRONOUS_SETTING
|
||||
{
|
||||
DIC_ISO_IN_ENDPOINT,
|
||||
USB_ISOCHRONOUS_PIPE,
|
||||
USB_SEND,
|
||||
DIC_ISO_IN_ENDP_PACKET_SIZE
|
||||
},
|
||||
{
|
||||
DIC_ISO_OUT_ENDPOINT,
|
||||
USB_ISOCHRONOUS_PIPE,
|
||||
USB_RECV,
|
||||
DIC_ISO_OUT_ENDP_PACKET_SIZE
|
||||
}
|
||||
#else
|
||||
{
|
||||
DIC_BULK_IN_ENDPOINT,
|
||||
USB_BULK_PIPE,
|
||||
USB_SEND,
|
||||
DIC_BULK_IN_ENDP_PACKET_SIZE
|
||||
},
|
||||
{
|
||||
DIC_BULK_OUT_ENDPOINT,
|
||||
USB_BULK_PIPE,
|
||||
USB_RECV,
|
||||
DIC_BULK_OUT_ENDP_PACKET_SIZE
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#if CIC_NOTIF_ELEM_SUPPORT
|
||||
,
|
||||
{
|
||||
CIC_NOTIF_ENDPOINT,
|
||||
USB_INTERRUPT_PIPE,
|
||||
USB_SEND,
|
||||
CIC_NOTIF_ENDP_PACKET_SIZE
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
uint_8 USB_DESC_CONST g_device_descriptor[DEVICE_DESCRIPTOR_SIZE] =
|
||||
{
|
||||
DEVICE_DESCRIPTOR_SIZE, /* Device Descriptor Size */
|
||||
USB_DEVICE_DESCRIPTOR, /* Device Type of descriptor */
|
||||
0x00, 0x02, /* BCD USB version */
|
||||
0x02, /* Device Class is indicated in
|
||||
the interface descriptors */
|
||||
0x00, /* Device Subclass is indicated
|
||||
in the interface descriptors */
|
||||
0x00, /* Device Protocol */
|
||||
CONTROL_MAX_PACKET_SIZE, /* Max Packet size */
|
||||
(0x2A3C&0xFF),((0x2A3C>>8)&0xFF), /* Vendor ID "Trinamic" */
|
||||
(0x0700&0xFF),((0x0700>>8)&0xFF), /* "TRINAMIC Evaluation Device" */
|
||||
0x02,0x00, /* BCD Device version */
|
||||
0x01, /* Manufacturer string index */
|
||||
0x02, /* Product string index */
|
||||
0x00, /* Serial number string index */
|
||||
0x01 /* Number of configurations */
|
||||
};
|
||||
|
||||
uint_8 USB_DESC_CONST g_config_descriptor[CONFIG_DESC_SIZE] =
|
||||
{
|
||||
CONFIG_ONLY_DESC_SIZE, /* Configuration Descriptor Size */
|
||||
USB_CONFIG_DESCRIPTOR, /* "Configuration" type of descriptor */
|
||||
CONFIG_DESC_SIZE, 0x00, /* Total length of the Configuration descriptor */
|
||||
(uint_8)(1+DATA_CLASS_SUPPORT),/*NumInterfaces*/
|
||||
0x01, /* Configuration Value */
|
||||
0x00, /* Configuration Description String Index*/
|
||||
BUS_POWERED|SELF_POWERED|(REMOTE_WAKEUP_SUPPORT<<REMOTE_WAKEUP_SHIFT),
|
||||
/* Attributes.support RemoteWakeup and self power*/
|
||||
0x32, /* Current draw from bus -- 100mA*/
|
||||
|
||||
/* CIC INTERFACE DESCRIPTOR */
|
||||
IFACE_ONLY_DESC_SIZE,
|
||||
USB_IFACE_DESCRIPTOR,
|
||||
0x00, /* bInterfaceNumber */
|
||||
0x00, /* bAlternateSetting */
|
||||
CIC_ENDP_COUNT, /* management and notification(optional)element present */
|
||||
0x02, /* Communication Interface Class */
|
||||
CIC_SUBCLASS_CODE,
|
||||
CIC_PROTOCOL_CODE,
|
||||
0x00, /* Interface Description String Index*/
|
||||
|
||||
/* CDC Class-Specific descriptor */
|
||||
0x05, /* size of Functional Desc in bytes */
|
||||
USB_CS_INTERFACE, /* descriptor type*/
|
||||
HEADER_FUNC_DESC,
|
||||
0x10, 0x01, /* USB Class Definitions for CDC spec release number in BCD */
|
||||
|
||||
0x05, /* Size of this descriptor */
|
||||
USB_CS_INTERFACE, /* descriptor type*/
|
||||
CALL_MANAGEMENT_FUNC_DESC,
|
||||
0x01,/*may use 0x03 */ /* device handales call management itself(D0 set)
|
||||
and will process commands multiplexed over the data interface */
|
||||
0x01, /* Indicates multiplexed commands are
|
||||
handled via data interface */
|
||||
|
||||
0x04, /* Size of this descriptor */
|
||||
USB_CS_INTERFACE, /* descriptor type*/
|
||||
ABSTRACT_CONTROL_FUNC_DESC,
|
||||
0x06, /*may use 0x0F */ /* Device Supports all commands for ACM - CDC
|
||||
PSTN SubClass bmCapabilities */
|
||||
|
||||
0x05, /* size of Functional Desc in bytes */
|
||||
USB_CS_INTERFACE, /* descriptor type*/
|
||||
UNION_FUNC_DESC,
|
||||
0x00, /* Interface Number of Control */
|
||||
0x01 /* Interface Number of Subordinate (Data Class) Interface */
|
||||
|
||||
#if CIC_NOTIF_ELEM_SUPPORT /*Endpoint descriptor */
|
||||
, /* Comma Added if NOTIF ELEM IS TO BE ADDED */
|
||||
ENDP_ONLY_DESC_SIZE,
|
||||
USB_ENDPOINT_DESCRIPTOR,
|
||||
CIC_NOTIF_ENDPOINT|(USB_SEND << 7),
|
||||
USB_INTERRUPT_PIPE,
|
||||
CIC_NOTIF_ENDP_PACKET_SIZE, 0x00,
|
||||
0x0A
|
||||
#endif
|
||||
|
||||
#if DATA_CLASS_SUPPORT
|
||||
, /* Comma Added if DATA_CLASS_DESC IS TO BE ADDED */
|
||||
IFACE_ONLY_DESC_SIZE,
|
||||
USB_IFACE_DESCRIPTOR,
|
||||
(uint_8)(0x00+DATA_CLASS_SUPPORT), /* bInterfaceNumber */
|
||||
0x00, /* bAlternateSetting */
|
||||
DIC_ENDP_COUNT, /* notification element included */
|
||||
0x0A, /* DATA Interface Class */
|
||||
0x00, /* Data Interface SubClass Code */
|
||||
DIC_PROTOCOL_CODE,
|
||||
0x00, /* Interface Description String Index*/
|
||||
|
||||
#if ! DIC_ISOCHRONOUS_SETTING
|
||||
/*Endpoint descriptor */
|
||||
ENDP_ONLY_DESC_SIZE,
|
||||
USB_ENDPOINT_DESCRIPTOR,
|
||||
DIC_BULK_IN_ENDPOINT|(USB_SEND << 7),
|
||||
USB_BULK_PIPE,
|
||||
DIC_BULK_IN_ENDP_PACKET_SIZE, 0x00,
|
||||
0x00,/* This value is ignored for Bulk ENDPOINT */
|
||||
|
||||
/*Endpoint descriptor */
|
||||
ENDP_ONLY_DESC_SIZE,
|
||||
USB_ENDPOINT_DESCRIPTOR,
|
||||
DIC_BULK_OUT_ENDPOINT|(USB_RECV << 7),
|
||||
USB_BULK_PIPE,
|
||||
DIC_BULK_OUT_ENDP_PACKET_SIZE, 0x00,
|
||||
0x00 /* This value is ignored for Bulk ENDPOINT */
|
||||
#else
|
||||
/*Endpoint descriptor */
|
||||
ENDP_ONLY_DESC_SIZE,
|
||||
USB_ENDPOINT_DESCRIPTOR,
|
||||
DIC_ISO_IN_ENDPOINT|(USB_SEND << 7),
|
||||
USB_ISOCHRONOUS_PIPE,
|
||||
DIC_ISO_IN_ENDP_PACKET_SIZE, 0x00,
|
||||
0x01,/* This value is for Iso ENDPOINT */
|
||||
|
||||
/*Endpoint descriptor */
|
||||
ENDP_ONLY_DESC_SIZE,
|
||||
USB_ENDPOINT_DESCRIPTOR,
|
||||
DIC_ISO_OUT_ENDPOINT|(USB_RECV << 7),
|
||||
USB_ISOCHRONOUS_PIPE,
|
||||
DIC_ISO_OUT_ENDP_PACKET_SIZE, 0x00,
|
||||
0x01 /* This value is for Iso ENDPOINT */
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
|
||||
uint_8 USB_DESC_CONST USB_STR_0[USB_STR_0_SIZE+USB_STR_DESC_SIZE] =
|
||||
{sizeof(USB_STR_0),
|
||||
USB_STRING_DESCRIPTOR,
|
||||
0x09,
|
||||
0x04/*equiavlent to 0x0409*/
|
||||
};
|
||||
|
||||
uint_8 USB_DESC_CONST USB_STR_1[USB_STR_1_SIZE+USB_STR_DESC_SIZE]
|
||||
= { sizeof(USB_STR_1),
|
||||
USB_STRING_DESCRIPTOR,
|
||||
|
||||
'T',0,
|
||||
'R',0,
|
||||
'I',0,
|
||||
'N',0,
|
||||
'A',0,
|
||||
'M',0,
|
||||
'I',0,
|
||||
'C',0,
|
||||
' ',0,
|
||||
'M',0,
|
||||
'o',0,
|
||||
't',0,
|
||||
'i',0,
|
||||
'o',0,
|
||||
'n',0,
|
||||
' ',0,
|
||||
'C',0,
|
||||
'o',0,
|
||||
'n',0,
|
||||
't',0,
|
||||
'r',0,
|
||||
'o',0,
|
||||
'l',0,
|
||||
' ',0,
|
||||
' ',0,
|
||||
' ',0,
|
||||
' ',0,
|
||||
' ',0
|
||||
};
|
||||
|
||||
|
||||
uint_8 USB_DESC_CONST USB_STR_2[USB_STR_2_SIZE+USB_STR_DESC_SIZE]
|
||||
= { sizeof(USB_STR_2),
|
||||
USB_STRING_DESCRIPTOR,
|
||||
|
||||
'E',0,
|
||||
'v',0,
|
||||
'a',0,
|
||||
'l',0,
|
||||
'u',0,
|
||||
'a',0,
|
||||
't',0,
|
||||
'i',0,
|
||||
'o',0,
|
||||
'n',0,
|
||||
' ',0,
|
||||
'D',0,
|
||||
'e',0,
|
||||
'v',0,
|
||||
'i',0,
|
||||
'c',0,
|
||||
'e',0,
|
||||
' ',0
|
||||
};
|
||||
|
||||
uint_8 USB_DESC_CONST USB_STR_n[USB_STR_n_SIZE+USB_STR_DESC_SIZE]
|
||||
= { sizeof(USB_STR_n),
|
||||
USB_STRING_DESCRIPTOR,
|
||||
'B',0,
|
||||
'A',0,
|
||||
'D',0,
|
||||
' ',0,
|
||||
'S',0,
|
||||
'T',0,
|
||||
'R',0,
|
||||
'I',0,
|
||||
'N',0,
|
||||
'G',0,
|
||||
' ',0,
|
||||
'I',0,
|
||||
'N',0,
|
||||
'D',0,
|
||||
'E',0,
|
||||
'X',0
|
||||
};
|
||||
|
||||
|
||||
USB_PACKET_SIZE const g_std_desc_size[USB_MAX_STD_DESCRIPTORS+1] =
|
||||
{0,
|
||||
DEVICE_DESCRIPTOR_SIZE,
|
||||
CONFIG_DESC_SIZE,
|
||||
0, /* string */
|
||||
0, /* Interface */
|
||||
0, /* Endpoint */
|
||||
0, /* Device Qualifier */
|
||||
0 /* other speed config */
|
||||
};
|
||||
|
||||
uint_8_ptr const g_std_descriptors[USB_MAX_STD_DESCRIPTORS+1] =
|
||||
{
|
||||
NULL,
|
||||
(uint_8_ptr)g_device_descriptor,
|
||||
(uint_8_ptr)g_config_descriptor,
|
||||
NULL, /* string */
|
||||
NULL, /* Interface */
|
||||
NULL, /* Endpoint */
|
||||
NULL, /* Device Qualifier */
|
||||
NULL /* other speed config*/
|
||||
};
|
||||
|
||||
uint_8 const g_string_desc_size[USB_MAX_STRING_DESCRIPTORS+1] =
|
||||
{
|
||||
sizeof(USB_STR_0),
|
||||
sizeof(USB_STR_1),
|
||||
sizeof(USB_STR_2),
|
||||
sizeof(USB_STR_n)
|
||||
};
|
||||
|
||||
uint_8_ptr const g_string_descriptors[USB_MAX_STRING_DESCRIPTORS+1] =
|
||||
{
|
||||
(uint_8_ptr)USB_STR_0,
|
||||
(uint_8_ptr)USB_STR_1,
|
||||
(uint_8_ptr)USB_STR_2,
|
||||
(uint_8_ptr)USB_STR_n
|
||||
};
|
||||
|
||||
#ifdef __HC08__ /* << EST */
|
||||
#pragma MESSAGE DISABLE C4800 /* implicit cast in assignment */
|
||||
#endif
|
||||
USB_ALL_LANGUAGES g_languages = { USB_STR_0, sizeof(USB_STR_0),
|
||||
{
|
||||
{
|
||||
(uint_16)0x0409,
|
||||
(const uint_8 **) (unsigned long) g_string_descriptors, // cast to unsigned long before properly casting to prevent gcc from complaining about cast from const to non-const
|
||||
g_string_desc_size
|
||||
}
|
||||
}
|
||||
};
|
||||
#ifdef __HC08__ /* << EST */
|
||||
#pragma MESSAGE DEFAULT C4800
|
||||
#endif
|
||||
|
||||
uint_8 const g_valid_config_values[USB_MAX_CONFIG_SUPPORTED+1]={0,1};
|
||||
|
||||
/****************************************************************************
|
||||
* Global Variables
|
||||
****************************************************************************/
|
||||
#ifdef _MC9S08JS16_H
|
||||
#pragma DATA_SEG APP_DATA
|
||||
#endif
|
||||
|
||||
static uint_8 g_line_coding[USB_MAX_SUPPORTED_INTERFACES][LINE_CODING_SIZE] =
|
||||
{
|
||||
{ (LINE_CODE_DTERATE_IFACE0>> 0) & 0x000000FF,
|
||||
(LINE_CODE_DTERATE_IFACE0>> 8) & 0x000000FF,
|
||||
(LINE_CODE_DTERATE_IFACE0>>16) & 0x000000FF,
|
||||
(LINE_CODE_DTERATE_IFACE0>>24) & 0x000000FF,
|
||||
/*e.g. 0x00,0xC2,0x01,0x00 : 0x0001C200 is 115200 bits per second */
|
||||
LINE_CODE_CHARFORMAT_IFACE0,
|
||||
LINE_CODE_PARITYTYPE_IFACE0,
|
||||
LINE_CODE_DATABITS_IFACE0
|
||||
}
|
||||
};
|
||||
|
||||
static uint_8 g_abstract_state[USB_MAX_SUPPORTED_INTERFACES][COMM_FEATURE_DATA_SIZE] =
|
||||
{
|
||||
{ (STATUS_ABSTRACT_STATE_IFACE0>>0) & 0x00FF,
|
||||
(STATUS_ABSTRACT_STATE_IFACE0>>8) & 0x00FF
|
||||
}
|
||||
};
|
||||
|
||||
static uint_8 g_country_code[USB_MAX_SUPPORTED_INTERFACES][COMM_FEATURE_DATA_SIZE] =
|
||||
{
|
||||
{ (COUNTRY_SETTING_IFACE0>>0) & 0x00FF,
|
||||
(COUNTRY_SETTING_IFACE0>>8) & 0x00FF
|
||||
}
|
||||
};
|
||||
|
||||
static uint_8 g_alternate_interface[USB_MAX_SUPPORTED_INTERFACES];
|
||||
|
||||
/*****************************************************************************
|
||||
* Local Types - None
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* Local Functions Prototypes
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* Local Variables - None
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Local Functions - None
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* Global Functions
|
||||
*****************************************************************************/
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Desc_Get_Descriptor
|
||||
*
|
||||
* @brief The function returns the correponding descriptor
|
||||
*
|
||||
* @param controller_ID : Controller ID
|
||||
* @param type : type of descriptor requested
|
||||
* @param sub_type : string index for string descriptor
|
||||
* @param index : string descriptor language Id
|
||||
* @param descriptor : output descriptor pointer
|
||||
* @param size : size of descriptor returned
|
||||
*
|
||||
* @return USB_OK When Successfull
|
||||
* USBERR_INVALID_REQ_TYPE when Error
|
||||
*****************************************************************************
|
||||
* This function is used to pass the pointer to the requested descriptor
|
||||
*****************************************************************************/
|
||||
uint_8 USB_Desc_Get_Descriptor (
|
||||
uint_8 controller_ID, /* [IN] Controller ID */
|
||||
uint_8 type, /* [IN] type of descriptor requested */
|
||||
uint_8 str_num, /* [IN] string index for string descriptor */
|
||||
uint_16 index, /* [IN] string descriptor language Id */
|
||||
uint_8_ptr *descriptor, /* [OUT] output descriptor pointer */
|
||||
USB_PACKET_SIZE *size /* [OUT] size of descriptor returned */
|
||||
)
|
||||
{
|
||||
UNUSED (controller_ID);
|
||||
|
||||
/* string descriptors are handled saperately */
|
||||
if(type == USB_STRING_DESCRIPTOR)
|
||||
{
|
||||
if(index == 0)
|
||||
{
|
||||
/* return the string and size of all languages */
|
||||
*descriptor = (uint_8_ptr) (unsigned long) g_languages.languages_supported_string; // cast to unsigned long before properly casting to prevent gcc from complaining about cast from const to non-const
|
||||
*size = g_languages.languages_supported_size;
|
||||
} else
|
||||
{
|
||||
uint_8 lang_id=0;
|
||||
uint_8 lang_index=USB_MAX_LANGUAGES_SUPPORTED;
|
||||
|
||||
for(;lang_id< USB_MAX_LANGUAGES_SUPPORTED;lang_id++)
|
||||
{
|
||||
/* check whether we have a string for this language */
|
||||
if(index == g_languages.usb_language[lang_id].language_id)
|
||||
{ /* check for max descriptors */
|
||||
if(str_num < USB_MAX_STRING_DESCRIPTORS)
|
||||
{ /* setup index for the string to be returned */
|
||||
lang_index=str_num;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* set return val for descriptor and size */
|
||||
*descriptor = (uint_8_ptr) (unsigned long) g_languages.usb_language[lang_id]. // cast to unsigned long before properly casting to prevent gcc from complaining about cast from const to non-const
|
||||
lang_desc[lang_index];
|
||||
*size = g_languages.usb_language[lang_id].
|
||||
lang_desc_size[lang_index];
|
||||
}
|
||||
|
||||
}
|
||||
else if(type < USB_MAX_STD_DESCRIPTORS+1)
|
||||
{
|
||||
/* Set return val for descriptor and size */
|
||||
*descriptor = (uint_8_ptr) (unsigned long) g_std_descriptors [type]; // cast to unsigned long before properly casting to prevent gcc from complaining about cast from const to non-const
|
||||
|
||||
/* if there is no descriptor then return error */
|
||||
if(*descriptor == NULL)
|
||||
{
|
||||
return USBERR_INVALID_REQ_TYPE;
|
||||
}
|
||||
|
||||
*size = g_std_desc_size[type];
|
||||
}
|
||||
else /* invalid descriptor */
|
||||
{
|
||||
return USBERR_INVALID_REQ_TYPE;
|
||||
}
|
||||
|
||||
return USB_OK;
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Desc_Get_Interface
|
||||
*
|
||||
* @brief The function returns the alternate interface
|
||||
*
|
||||
* @param controller_ID : Controller Id
|
||||
* @param interface : Interface number
|
||||
* @param alt_interface : Output alternate interface
|
||||
*
|
||||
* @return USB_OK When Successfull
|
||||
* USBERR_INVALID_REQ_TYPE when Error
|
||||
*****************************************************************************
|
||||
* This function is called by the framework module to get the current interface
|
||||
*****************************************************************************/
|
||||
uint_8 USB_Desc_Get_Interface (
|
||||
uint_8 controller_ID, /* [IN] Controller ID */
|
||||
uint_8 interface, /* [IN] interface number */
|
||||
uint_8_ptr alt_interface /* [OUT] output alternate interface */
|
||||
)
|
||||
{
|
||||
UNUSED (controller_ID);
|
||||
/* if interface valid */
|
||||
if(interface < USB_MAX_SUPPORTED_INTERFACES)
|
||||
{
|
||||
/* get alternate interface*/
|
||||
*alt_interface = g_alternate_interface[interface];
|
||||
return USB_OK;
|
||||
}
|
||||
|
||||
return USBERR_INVALID_REQ_TYPE;
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Desc_Set_Interface
|
||||
*
|
||||
* @brief The function sets the alternate interface
|
||||
*
|
||||
* @param controller_ID : Controller Id
|
||||
* @param interface : Interface number
|
||||
* @param alt_interface : Input alternate interface
|
||||
*
|
||||
* @return USB_OK When Successfull
|
||||
* USBERR_INVALID_REQ_TYPE when Error
|
||||
*****************************************************************************
|
||||
* This function is called by the framework module to set the interface
|
||||
*****************************************************************************/
|
||||
uint_8 USB_Desc_Set_Interface (
|
||||
uint_8 controller_ID, /* [IN] Controller ID */
|
||||
uint_8 interface, /* [IN] interface number */
|
||||
uint_8 alt_interface /* [IN] input alternate interface */
|
||||
)
|
||||
{
|
||||
UNUSED (controller_ID);
|
||||
/* if interface valid */
|
||||
if(interface < USB_MAX_SUPPORTED_INTERFACES)
|
||||
{
|
||||
/* set alternate interface*/
|
||||
g_alternate_interface[interface]=alt_interface;
|
||||
return USB_OK;
|
||||
}
|
||||
|
||||
return USBERR_INVALID_REQ_TYPE;
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Desc_Valid_Configation
|
||||
*
|
||||
* @brief The function checks whether the configuration parameter
|
||||
* input is valid or not
|
||||
*
|
||||
* @param controller_ID : Controller Id
|
||||
* @param config_val : Configuration value
|
||||
*
|
||||
* @return TRUE When Valid
|
||||
* FALSE When Error
|
||||
*****************************************************************************
|
||||
* This function checks whether the configuration is valid or not
|
||||
*****************************************************************************/
|
||||
boolean USB_Desc_Valid_Configation (
|
||||
uint_8 controller_ID,/*[IN] Controller ID */
|
||||
uint_16 config_val /*[IN] configuration value */
|
||||
)
|
||||
{
|
||||
uint_8 loop_index=0;
|
||||
UNUSED (controller_ID);
|
||||
|
||||
/* check with only supported val right now */
|
||||
while(loop_index < (USB_MAX_CONFIG_SUPPORTED+1))
|
||||
{
|
||||
if(config_val == g_valid_config_values[loop_index])
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
loop_index++;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Desc_Valid_Interface
|
||||
*
|
||||
* @brief The function checks whether the interface parameter
|
||||
* input is valid or not
|
||||
*
|
||||
* @param controller_ID : Controller Id
|
||||
* @param interface : Target interface
|
||||
*
|
||||
* @return TRUE When Valid
|
||||
* FALSE When Error
|
||||
*****************************************************************************
|
||||
* This function checks whether the interface is valid or not
|
||||
*****************************************************************************/
|
||||
boolean USB_Desc_Valid_Interface (
|
||||
uint_8 controller_ID, /*[IN] Controller ID */
|
||||
uint_8 interface /*[IN] target interface */
|
||||
)
|
||||
{
|
||||
uint_8 loop_index=0;
|
||||
UNUSED (controller_ID);
|
||||
|
||||
/* check with only supported val right now */
|
||||
while(loop_index < USB_MAX_SUPPORTED_INTERFACES)
|
||||
{
|
||||
if(interface == g_alternate_interface[loop_index])
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
loop_index++;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Desc_Remote_Wakeup
|
||||
*
|
||||
* @brief The function checks whether the remote wakeup is supported or not
|
||||
*
|
||||
* @param controller_ID : Controller ID
|
||||
*
|
||||
* @return REMOTE_WAKEUP_SUPPORT (TRUE) - if remote wakeup supported
|
||||
*****************************************************************************
|
||||
* This function returns remote wakeup is supported or not
|
||||
*****************************************************************************/
|
||||
boolean USB_Desc_Remote_Wakeup (
|
||||
uint_8 controller_ID /* [IN] Controller ID */
|
||||
)
|
||||
{
|
||||
UNUSED (controller_ID);
|
||||
return REMOTE_WAKEUP_SUPPORT;
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Desc_Get_Endpoints
|
||||
*
|
||||
* @brief The function returns with the list of all non control endpoints used
|
||||
*
|
||||
* @param controller_ID : Controller ID
|
||||
*
|
||||
* @return pointer to USB_ENDPOINTS
|
||||
*****************************************************************************
|
||||
* This function returns the information about all the non control endpoints
|
||||
* implemented
|
||||
*****************************************************************************/
|
||||
void* USB_Desc_Get_Endpoints (
|
||||
uint_8 controller_ID /* [IN] Controller ID */
|
||||
)
|
||||
{
|
||||
UNUSED (controller_ID);
|
||||
return (void*) (unsigned long) &usb_desc_ep; // cast to unsigned long before properly casting to prevent gcc from complaining about cast from const to non-const
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Desc_Get_Line_Coding
|
||||
*
|
||||
* @brief The function returns the Line Coding/Configuraion
|
||||
*
|
||||
* @param controller_ID : Controller ID
|
||||
* @param interface : Interface number
|
||||
* @param coding_data : Output line coding data
|
||||
*
|
||||
* @return USB_OK When Successfull
|
||||
* USBERR_INVALID_REQ_TYPE when Error
|
||||
*****************************************************************************
|
||||
* Returns current Line Coding Parameters
|
||||
*****************************************************************************/
|
||||
uint_8 USB_Desc_Get_Line_Coding (
|
||||
uint_8 controller_ID, /* [IN] Controller ID */
|
||||
uint_8 interface, /* [IN] Interface Number */
|
||||
uint_8_ptr *coding_data /* [OUT] Line Coding Data */
|
||||
)
|
||||
{
|
||||
UNUSED (controller_ID);
|
||||
/* if interface valid */
|
||||
if(interface < USB_MAX_SUPPORTED_INTERFACES)
|
||||
{
|
||||
/* get line coding data*/
|
||||
*coding_data = g_line_coding[interface];
|
||||
return USB_OK;
|
||||
}
|
||||
|
||||
return USBERR_INVALID_REQ_TYPE;
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Desc_Set_Line_Coding
|
||||
*
|
||||
* @brief The function sets the Line Coding/Configuraion
|
||||
*
|
||||
* @param controller_ID : Controller ID
|
||||
* @param interface : Interface number
|
||||
* @param coding_data : Output line coding data
|
||||
*
|
||||
* @return USB_OK When Successfull
|
||||
* USBERR_INVALID_REQ_TYPE when Error
|
||||
*****************************************************************************
|
||||
* Sets Line Coding Structure with the HOST specified values
|
||||
*****************************************************************************/
|
||||
uint_8 USB_Desc_Set_Line_Coding (
|
||||
uint_8 controller_ID, /* [IN] Controller ID */
|
||||
uint_8 interface, /* [IN] Interface Number */
|
||||
uint_8_ptr *coding_data /* [IN] Line Coding Data */
|
||||
)
|
||||
{
|
||||
uint_8 count;
|
||||
UNUSED (controller_ID);
|
||||
|
||||
/* if interface valid */
|
||||
if(interface < USB_MAX_SUPPORTED_INTERFACES)
|
||||
{
|
||||
/* set line coding data*/
|
||||
for(count = 0; count < LINE_CODING_SIZE; count++)
|
||||
{
|
||||
g_line_coding[interface][count] = *((*coding_data +
|
||||
USB_SETUP_PKT_SIZE) + count);
|
||||
}
|
||||
return USB_OK;
|
||||
}
|
||||
|
||||
return USBERR_INVALID_REQ_TYPE;
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Desc_Get_Abstract_State
|
||||
*
|
||||
* @brief The function gets the current setting for communication feature
|
||||
* (ABSTRACT_STATE)
|
||||
* @param controller_ID : Controller ID
|
||||
* @param interface : Interface number
|
||||
* @param feature_data : Output comm feature data
|
||||
*
|
||||
* @return USB_OK When Successfull
|
||||
* USBERR_INVALID_REQ_TYPE when Error
|
||||
*****************************************************************************
|
||||
* Returns ABSTRACT STATE Communication Feature to the Host
|
||||
*****************************************************************************/
|
||||
uint_8 USB_Desc_Get_Abstract_State (
|
||||
uint_8 controller_ID, /* [IN] Controller ID */
|
||||
uint_8 interface, /* [IN] Interface Number */
|
||||
uint_8_ptr *feature_data /* [OUT] Output Comm Feature Data */
|
||||
)
|
||||
{
|
||||
UNUSED (controller_ID);
|
||||
/* if interface valid */
|
||||
if(interface < USB_MAX_SUPPORTED_INTERFACES)
|
||||
{
|
||||
/* get line coding data*/
|
||||
*feature_data = g_abstract_state[interface];
|
||||
return USB_OK;
|
||||
}
|
||||
|
||||
return USBERR_INVALID_REQ_TYPE;
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Desc_Get_Country_Setting
|
||||
*
|
||||
* @brief The function gets the current setting for communication feature
|
||||
* (COUNTRY_CODE)
|
||||
* @param controller_ID : Controller ID
|
||||
* @param interface : Interface number
|
||||
* @param feature_data : Output comm feature data
|
||||
*
|
||||
* @return USB_OK When Successfull
|
||||
* USBERR_INVALID_REQ_TYPE when Error
|
||||
*****************************************************************************
|
||||
* Returns the country Code to the Host
|
||||
*****************************************************************************/
|
||||
uint_8 USB_Desc_Get_Country_Setting (
|
||||
uint_8 controller_ID, /* [IN] Controller ID */
|
||||
uint_8 interface, /* [IN] Interface Number */
|
||||
uint_8_ptr *feature_data /* [OUT] Output Comm Feature Data */
|
||||
)
|
||||
{
|
||||
UNUSED (controller_ID);
|
||||
/* if interface valid */
|
||||
if(interface < USB_MAX_SUPPORTED_INTERFACES)
|
||||
{
|
||||
/* get line coding data*/
|
||||
*feature_data = g_country_code[interface];
|
||||
return USB_OK;
|
||||
}
|
||||
|
||||
return USBERR_INVALID_REQ_TYPE;
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Desc_Set_Abstract_State
|
||||
*
|
||||
* @brief The function gets the current setting for communication feature
|
||||
* (ABSTRACT_STATE)
|
||||
* @param controller_ID : Controller ID
|
||||
* @param interface : Interface number
|
||||
* @param feature_data : Output comm feature data
|
||||
*
|
||||
* @return USB_OK When Successfull
|
||||
* USBERR_INVALID_REQ_TYPE when Error
|
||||
*****************************************************************************
|
||||
* Sets the ABSTRACT State specified by the Host
|
||||
*****************************************************************************/
|
||||
uint_8 USB_Desc_Set_Abstract_State (
|
||||
uint_8 controller_ID, /* [IN] Controller ID */
|
||||
uint_8 interface, /* [IN] Interface Number */
|
||||
uint_8_ptr *feature_data /* [OUT] Output Comm Feature Data */
|
||||
)
|
||||
{
|
||||
uint_8 count;
|
||||
UNUSED (controller_ID);
|
||||
|
||||
/* if interface valid */
|
||||
if(interface < USB_MAX_SUPPORTED_INTERFACES)
|
||||
{
|
||||
/* set Abstract State Feature*/
|
||||
for(count = 0; count < COMM_FEATURE_DATA_SIZE; count++)
|
||||
{
|
||||
g_abstract_state[interface][count] = *(*feature_data + count);
|
||||
}
|
||||
return USB_OK;
|
||||
}
|
||||
|
||||
return USBERR_INVALID_REQ_TYPE;
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Desc_Set_Country_Setting
|
||||
*
|
||||
* @brief The function gets the current setting for communication feature
|
||||
* (COUNTRY_CODE)
|
||||
* @param controller_ID : Controller ID
|
||||
* @param interface : Interface number
|
||||
* @param feature_data : Output comm feature data
|
||||
*
|
||||
* @return USB_OK When Successfull
|
||||
* USBERR_INVALID_REQ_TYPE when Error
|
||||
*****************************************************************************
|
||||
* Sets the country code specified by the HOST
|
||||
*****************************************************************************/
|
||||
uint_8 USB_Desc_Set_Country_Setting(
|
||||
uint_8 controller_ID, /* [IN] Controller ID */
|
||||
uint_8 interface, /* [IN] Interface Number */
|
||||
uint_8_ptr *feature_data /* [OUT] Output Comm Feature Data */
|
||||
)
|
||||
{
|
||||
uint_8 count;
|
||||
UNUSED (controller_ID);
|
||||
|
||||
/* if interface valid */
|
||||
if(interface < USB_MAX_SUPPORTED_INTERFACES)
|
||||
{
|
||||
for(count = 0; count < COMM_FEATURE_DATA_SIZE; count++)
|
||||
{
|
||||
g_country_code[interface][count] = *(*feature_data + count);
|
||||
}
|
||||
return USB_OK;
|
||||
}
|
||||
|
||||
return USBERR_INVALID_REQ_TYPE;
|
||||
}
|
||||
@@ -0,0 +1,301 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Freescale Semiconductor Inc.
|
||||
* (c) Copyright 2004-2009 Freescale Semiconductor, Inc.
|
||||
* ALL RIGHTS RESERVED.
|
||||
*
|
||||
**************************************************************************//*!
|
||||
*
|
||||
* @file usb_descriptor.h
|
||||
*
|
||||
* @author
|
||||
*
|
||||
* @version
|
||||
*
|
||||
* @date May-28-2009
|
||||
*
|
||||
* @brief The file is a header file for USB Descriptors required for Virtual
|
||||
* COM Loopback Application
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef _USB_DESCRIPTOR_H
|
||||
#define _USB_DESCRIPTOR_H
|
||||
|
||||
/******************************************************************************
|
||||
* Includes
|
||||
*****************************************************************************/
|
||||
#include "types.h"
|
||||
#include "usb_class.h"
|
||||
|
||||
/******************************************************************************
|
||||
* Constants - None
|
||||
*****************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Macro's
|
||||
*****************************************************************************/
|
||||
#define REMOTE_WAKEUP_SUPPORT (FALSE)
|
||||
#define DATA_CLASS_SUPPORT (TRUE)
|
||||
#define CIC_NOTIF_ELEM_SUPPORT (TRUE) /* Mandatory */
|
||||
#define DIC_ISOCHRONOUS_SETTING (FALSE)
|
||||
|
||||
#define IMPLEMENT_QUEUING (TRUE)
|
||||
|
||||
/* Communication Class SubClass Codes */
|
||||
#define DIRECT_LINE_CONTROL_MODEL (0x01)
|
||||
#define ABSTRACT_CONTROL_MODEL (0x02)
|
||||
#define TELEPHONE_CONTROL_MODEL (0x03)
|
||||
#define MULTI_CHANNEL_CONTROL_MODEL (0x04)
|
||||
#define CAPI_CONTROL_MOPDEL (0x05)
|
||||
#define ETHERNET_NETWORKING_CONTROL_MODEL (0x06)
|
||||
#define ATM_NETWORKING_CONTROL_MODEL (0x07)
|
||||
#define WIRELESS_HANDSET_CONTROL_MODEL (0x08)
|
||||
#define DEVICE_MANAGEMENT (0x09)
|
||||
#define MOBILE_DIRECT_LINE_MODEL (0x0A)
|
||||
#define OBEX (0x0B)
|
||||
#define ETHERNET_EMULATION_MODEL (0x0C)
|
||||
|
||||
/* Communication Class Protocol Codes */
|
||||
#define NO_CLASS_SPECIFIC_PROTOCOL (0x00)
|
||||
#define AT_250_PROTOCOL (0x01)
|
||||
#define AT_PCCA_101_PROTOCOL (0x02)
|
||||
#define AT_PCCA_101_ANNEX_O (0x03)
|
||||
#define AT_GSM_7_07 (0x04)
|
||||
#define AT_3GPP_27_007 (0x05)
|
||||
#define AT_TIA_CDMA (0x06)
|
||||
#define ETHERNET_EMULATION_PROTOCOL (0x07)
|
||||
#define EXTERNAL_PROTOCOL (0xFE)
|
||||
#define VENDOR_SPECIFIC (0xFF)
|
||||
|
||||
/* Data Class Protocol Codes */
|
||||
/* #define NO_CLASS_SPECIFIC_PROTOCOL (0x00) */
|
||||
#define PYHSICAL_INTERFACE_PROTOCOL (0x30)
|
||||
#define HDLC_PROTOCOL (0x31)
|
||||
#define TRANSPARENT_PROTOCOL (0x32)
|
||||
#define MANAGEMENT_PROTOCOL (0x50)
|
||||
#define DATA_LINK_Q931_PROTOCOL (0x51)
|
||||
#define DATA_LINK_Q921_PROTOCOL (0x52)
|
||||
#define DATA_COMPRESSION_V42BIS (0x90)
|
||||
#define EURO_ISDN_PROTOCOL (0x91)
|
||||
#define RATE_ADAPTION_ISDN_V24 (0x92)
|
||||
#define CAPI_COMMANDS (0x93)
|
||||
#define HOST_BASED_DRIVER (0xFD)
|
||||
#define CDC_UNIT_FUNCTIONAL (0xFE)
|
||||
/* #define VENDOR_SPECIFIC (0xFF) */
|
||||
|
||||
/* Descriptor SubType in Communications Class Functional Descriptors */
|
||||
#define HEADER_FUNC_DESC (0x00)
|
||||
#define CALL_MANAGEMENT_FUNC_DESC (0x01)
|
||||
#define ABSTRACT_CONTROL_FUNC_DESC (0x02)
|
||||
#define DIRECT_LINE_FUNC_DESC (0x03)
|
||||
#define TELEPHONE_RINGER_FUNC_DESC (0x04)
|
||||
#define TELEPHONE_REPORT_FUNC_DESC (0x05)
|
||||
#define UNION_FUNC_DESC (0x06)
|
||||
#define COUNTRY_SELECT_FUNC_DESC (0x07)
|
||||
#define TELEPHONE_MODES_FUNC_DESC (0x08)
|
||||
#define USB_TERMINAL_FUNC_DESC (0x09)
|
||||
#define NETWORK_CHANNEL_FUNC_DESC (0x0A)
|
||||
#define PROTOCOL_UNIT_FUNC_DESC (0x0B)
|
||||
#define EXTENSION_UNIT_FUNC_DESC (0x0C)
|
||||
#define MULTI_CHANNEL_FUNC_DESC (0x0D)
|
||||
#define CAPI_CONTROL_FUNC_DESC (0x0E)
|
||||
#define ETHERNET_NETWORKING_FUNC_DESC (0x0F)
|
||||
#define ATM_NETWORKING_FUNC_DESC (0x10)
|
||||
#define WIRELESS_CONTROL_FUNC_DESC (0x11)
|
||||
#define MOBILE_DIRECT_LINE_FUNC_DESC (0x12)
|
||||
#define MDLM_DETAIL_FUNC_DESC (0x13)
|
||||
#define DEVICE_MANAGEMENT_FUNC_DESC (0x14)
|
||||
#define OBEX_FUNC_DESC (0x15)
|
||||
#define COMMAND_SET_FUNC_DESC (0x16)
|
||||
#define COMMAND_SET_DETAIL_FUNC_DESC (0x17)
|
||||
#define TELEPHONE_CONTROL_FUNC_DESC (0x18)
|
||||
#define OBEX_SERVICE_ID_FUNC_DESC (0x19)
|
||||
|
||||
|
||||
#define CIC_SUBCLASS_CODE ABSTRACT_CONTROL_MODEL
|
||||
#define CIC_PROTOCOL_CODE NO_CLASS_SPECIFIC_PROTOCOL
|
||||
#define DIC_PROTOCOL_CODE NO_CLASS_SPECIFIC_PROTOCOL
|
||||
#define CIC_ENDP_COUNT (0+(CIC_NOTIF_ELEM_SUPPORT & 0x01) * 1)
|
||||
#define DIC_ENDP_COUNT (2)
|
||||
|
||||
#define CIC_NOTIF_ENDPOINT (3)
|
||||
#define CIC_NOTIF_ENDP_PACKET_SIZE (16)
|
||||
#define DIC_BULK_IN_ENDPOINT (1)
|
||||
#define DIC_BULK_IN_ENDP_PACKET_SIZE (16)/* max supported is 64 */
|
||||
#define DIC_BULK_OUT_ENDPOINT (2)
|
||||
#define DIC_BULK_OUT_ENDP_PACKET_SIZE (16)/* max supported is 64*/
|
||||
|
||||
#if DIC_ISOCHRONOUS_SETTING
|
||||
#define DIC_ISO_IN_ENDPOINT (1)
|
||||
#define DIC_ISO_IN_ENDP_PACKET_SIZE (64)
|
||||
#define DIC_ISO_OUT_ENDPOINT (2)
|
||||
#define DIC_ISO_OUT_ENDP_PACKET_SIZE (64)
|
||||
#endif
|
||||
#define REMOTE_WAKEUP_SHIFT (5)
|
||||
|
||||
/* Various descriptor sizes */
|
||||
#define DEVICE_DESCRIPTOR_SIZE (18)
|
||||
#define CONFIG_ONLY_DESC_SIZE (9)
|
||||
#define CONFIG_DESC_SIZE (CONFIG_ONLY_DESC_SIZE + 28 + \
|
||||
(CIC_NOTIF_ELEM_SUPPORT & 0x01) \
|
||||
* 7 + DATA_CLASS_SUPPORT * 23)
|
||||
#define DEVICE_QUALIFIER_DESCRIPTOR_SIZE (10)
|
||||
#define IFACE_ONLY_DESC_SIZE (9)
|
||||
#define ENDP_ONLY_DESC_SIZE (7)
|
||||
|
||||
/* Max descriptors provided by the Application */
|
||||
#define USB_MAX_STD_DESCRIPTORS (7)
|
||||
|
||||
/* Max configuration supported by the Application */
|
||||
#define USB_MAX_CONFIG_SUPPORTED (1)
|
||||
|
||||
/* Max string descriptors supported by the Application */
|
||||
#define USB_MAX_STRING_DESCRIPTORS (3)
|
||||
|
||||
/* Max language codes supported by the USB */
|
||||
#define USB_MAX_LANGUAGES_SUPPORTED (1)
|
||||
|
||||
/* string descriptors sizes */
|
||||
#define USB_STR_DESC_SIZE (2)
|
||||
#define USB_STR_0_SIZE (2)
|
||||
#define USB_STR_1_SIZE (56)
|
||||
#define USB_STR_2_SIZE (36)
|
||||
#define USB_STR_n_SIZE (32)
|
||||
|
||||
/* descriptors codes */
|
||||
#define USB_DEVICE_DESCRIPTOR (1)
|
||||
#define USB_CONFIG_DESCRIPTOR (2)
|
||||
#define USB_STRING_DESCRIPTOR (3)
|
||||
#define USB_IFACE_DESCRIPTOR (4)
|
||||
#define USB_ENDPOINT_DESCRIPTOR (5)
|
||||
#define USB_DEVQUAL_DESCRIPTOR (6)
|
||||
#define USB_CS_INTERFACE (0x24)
|
||||
#define USB_CS_ENDPOINT (0x25)
|
||||
|
||||
#define USB_MAX_SUPPORTED_INTERFACES (2)
|
||||
|
||||
/* Implementation Specific Macros */
|
||||
#define LINE_CODING_SIZE (0x07)
|
||||
#define COMM_FEATURE_DATA_SIZE (0x02)
|
||||
|
||||
#define LINE_CODE_DTERATE_IFACE0 (115200) /*e.g 9600 is 0x00002580 */
|
||||
#define LINE_CODE_CHARFORMAT_IFACE0 (0x00) /* 1 stop bit */
|
||||
#define LINE_CODE_PARITYTYPE_IFACE0 (0x00) /* No Parity */
|
||||
#define LINE_CODE_DATABITS_IFACE0 (0x08) /* Data Bits Format */
|
||||
|
||||
#define LINE_CODE_DTERATE_IFACE1 (9600) /*e.g. 115200 is 0x0001C200*/
|
||||
#define LINE_CODE_CHARFORMAT_IFACE1 (0x00) /* 1 stop bit */
|
||||
#define LINE_CODE_PARITYTYPE_IFACE1 (0x00) /* No Parity */
|
||||
#define LINE_CODE_DATABITS_IFACE1 (0x08) /* Data Bits Format */
|
||||
|
||||
#define STATUS_ABSTRACT_STATE_IFACE0 (0x0000) /* Disable Multiplexing
|
||||
ENDP in this interface will
|
||||
continue to accept/offer data*/
|
||||
#define STATUS_ABSTRACT_STATE_IFACE1 (0x0000) /* Disable Multiplexing
|
||||
ENDP in this interface will
|
||||
continue to accept/offer data*/
|
||||
#define COUNTRY_SETTING_IFACE0 (0x0000) /* Country Code in the format as
|
||||
defined in [ISO3166] */
|
||||
#define COUNTRY_SETTING_IFACE1 (0x0000) /* Country Code in the format as
|
||||
defined in [ISO3166] */
|
||||
|
||||
/* Notifications Support */
|
||||
#define PSTN_SUBCLASS_NOTIF_SUPPORT (TRUE)
|
||||
#define WMC_SUBCLASS_NOTIF_SUPPORT (FALSE)
|
||||
#define CDC_CLASS_NOTIF_SUPPORT (FALSE)
|
||||
|
||||
#define CDC_DESC_ENDPOINT_COUNT (CIC_ENDP_COUNT+(DATA_CLASS_SUPPORT & 0x01) \
|
||||
*DIC_ENDP_COUNT)
|
||||
|
||||
/******************************************************************************
|
||||
* Types
|
||||
*****************************************************************************/
|
||||
typedef const struct _USB_LANGUAGE
|
||||
{
|
||||
uint_16 const language_id; /* Language ID */
|
||||
uint_8 const ** lang_desc; /* Language Descriptor String */
|
||||
uint_8 const * lang_desc_size; /* Language Descriptor Size */
|
||||
} USB_LANGUAGE;
|
||||
|
||||
typedef const struct _USB_ALL_LANGUAGES
|
||||
{
|
||||
/* Pointer to Supported Language String */
|
||||
uint_8 const *languages_supported_string;
|
||||
/* Size of Supported Language String */
|
||||
uint_8 const languages_supported_size;
|
||||
/* Array of Supported Languages */
|
||||
USB_LANGUAGE usb_language[USB_MAX_SUPPORTED_INTERFACES];
|
||||
}USB_ALL_LANGUAGES;
|
||||
|
||||
typedef const struct _USB_ENDPOINTS
|
||||
{
|
||||
/* Number of non control Endpoints */
|
||||
uint_8 count;
|
||||
/* Array of Endpoints Structures */
|
||||
USB_EP_STRUCT ep[CDC_DESC_ENDPOINT_COUNT];
|
||||
}USB_ENDPOINTS;
|
||||
|
||||
/******************************************************************************
|
||||
* Global Functions
|
||||
*****************************************************************************/
|
||||
extern uint_8 USB_Desc_Get_Descriptor(
|
||||
uint_8 controller_ID,
|
||||
uint_8 type,
|
||||
uint_8 str_num,
|
||||
uint_16 index,
|
||||
uint_8_ptr *descriptor,
|
||||
USB_PACKET_SIZE *size);
|
||||
|
||||
extern uint_8 USB_Desc_Get_Interface(
|
||||
uint_8 controller_ID,
|
||||
uint_8 interface,
|
||||
uint_8_ptr alt_interface);
|
||||
|
||||
|
||||
extern uint_8 USB_Desc_Set_Interface(
|
||||
uint_8 controller_ID,
|
||||
uint_8 interface,
|
||||
uint_8 alt_interface);
|
||||
|
||||
extern boolean USB_Desc_Valid_Configation(
|
||||
uint_8 controller_ID,
|
||||
uint_16 config_val);
|
||||
|
||||
extern boolean USB_Desc_Valid_Interface(
|
||||
uint_8 controller_ID,
|
||||
uint_8 interface);
|
||||
|
||||
extern boolean USB_Desc_Remote_Wakeup(uint_8 controller_ID);
|
||||
|
||||
extern void* USB_Desc_Get_Endpoints(uint_8 controller_ID);
|
||||
|
||||
extern uint_8 USB_Desc_Get_Line_Coding(
|
||||
uint_8 controller_ID,
|
||||
uint_8 interface,
|
||||
uint_8_ptr *coding_data);
|
||||
|
||||
extern uint_8 USB_Desc_Set_Line_Coding(
|
||||
uint_8 controller_ID,
|
||||
uint_8 interface,
|
||||
uint_8_ptr *coding_data);
|
||||
|
||||
extern uint_8 USB_Desc_Get_Abstract_State(
|
||||
uint_8 controller_ID,
|
||||
uint_8 interface,
|
||||
uint_8_ptr *feature_data);
|
||||
extern uint_8 USB_Desc_Get_Country_Setting(
|
||||
uint_8 controller_ID,
|
||||
uint_8 interface,
|
||||
uint_8_ptr *feature_data);
|
||||
extern uint_8 USB_Desc_Set_Abstract_State(
|
||||
uint_8 controller_ID,
|
||||
uint_8 interface,
|
||||
uint_8_ptr *feature_data);
|
||||
extern uint_8 USB_Desc_Set_Country_Setting(
|
||||
uint_8 controller_ID,
|
||||
uint_8 interface,
|
||||
uint_8_ptr *feature_data);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,480 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Freescale Semiconductor Inc.
|
||||
* (c) Copyright 2004-2010 Freescale Semiconductor, Inc.
|
||||
* ALL RIGHTS RESERVED.
|
||||
*
|
||||
******************************************************************************
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY FREESCALE "AS IS" AND ANY EXPRESSED OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL FREESCALE OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
**************************************************************************//*!
|
||||
*
|
||||
* @file usb_devapi.h
|
||||
*
|
||||
* @author
|
||||
*
|
||||
* @version
|
||||
*
|
||||
* @date
|
||||
*
|
||||
* @brief This file contains S08 USB stack device layer API header function.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef _USB_DEVAPI_H
|
||||
#define _USB_DEVAPI_H
|
||||
|
||||
/******************************************************************************
|
||||
* Includes
|
||||
*****************************************************************************/
|
||||
#include "types.h" /* User Defined Data Types */
|
||||
#include "hidef.h" /* for EnableInterrupts; macro */
|
||||
#include <stdint.h>
|
||||
#include "hal/derivative.h" /* include peripheral declarations */
|
||||
#include "usb_user_config.h" /* User Configuration File << EST 'user_config.h' conflicts with MQX Lite */
|
||||
/******************************************************************************
|
||||
* Constants - None
|
||||
*****************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Macro's
|
||||
*****************************************************************************/
|
||||
#if 0 /* << EST */
|
||||
#ifndef _MC9S08JS16_H
|
||||
#define USB_MAX_EP_BUFFER_SIZE (512)
|
||||
#else
|
||||
#define USB_MAX_EP_BUFFER_SIZE (255)
|
||||
#endif
|
||||
#else
|
||||
/* device is Kinetis K20D72 << EST */
|
||||
#define USB_MAX_EP_BUFFER_SIZE (512)
|
||||
#endif
|
||||
#ifndef CONTROL_ENDPOINT
|
||||
#define CONTROL_ENDPOINT (0)
|
||||
#endif
|
||||
|
||||
#define USB_SETUP_PKT_SIZE (8) /* Setup Packet Size */
|
||||
|
||||
/* Error codes */
|
||||
#define USB_OK (0x00)
|
||||
#define USBERR_ALLOC (0x81)
|
||||
#define USBERR_BAD_STATUS (0x82)
|
||||
#define USBERR_CLOSED_SERVICE (0x83)
|
||||
#define USBERR_OPEN_SERVICE (0x84)
|
||||
#define USBERR_TRANSFER_IN_PROGRESS (0x85)
|
||||
#define USBERR_ENDPOINT_STALLED (0x86)
|
||||
#define USBERR_ALLOC_STATE (0x87)
|
||||
#define USBERR_DRIVER_INSTALL_FAILED (0x88)
|
||||
#define USBERR_DRIVER_NOT_INSTALLED (0x89)
|
||||
#define USBERR_INSTALL_ISR (0x8A)
|
||||
#define USBERR_INVALID_DEVICE_NUM (0x8B)
|
||||
#define USBERR_ALLOC_SERVICE (0x8C)
|
||||
#define USBERR_INIT_FAILED (0x8D)
|
||||
#define USBERR_SHUTDOWN (0x8E)
|
||||
#define USBERR_INVALID_PIPE_HANDLE (0x8F)
|
||||
#define USBERR_OPEN_PIPE_FAILED (0x90)
|
||||
#define USBERR_INIT_DATA (0x91)
|
||||
#define USBERR_SRP_REQ_INVALID_STATE (0x92)
|
||||
#define USBERR_TX_FAILED (0x93)
|
||||
#define USBERR_RX_FAILED (0x94)
|
||||
#define USBERR_EP_INIT_FAILED (0x95)
|
||||
#define USBERR_EP_DEINIT_FAILED (0x96)
|
||||
#define USBERR_TR_FAILED (0x97)
|
||||
#define USBERR_BANDWIDTH_ALLOC_FAILED (0x98)
|
||||
#define USBERR_INVALID_NUM_OF_ENDPOINTS (0x99)
|
||||
#define USBERR_NOT_SUPPORTED (0x9A)
|
||||
|
||||
#define USBERR_DEVICE_NOT_FOUND (0xC0)
|
||||
#define USBERR_DEVICE_BUSY (0xC1)
|
||||
#define USBERR_NO_DEVICE_CLASS (0xC3)
|
||||
#define USBERR_UNKNOWN_ERROR (0xC4)
|
||||
#define USBERR_INVALID_BMREQ_TYPE (0xC5)
|
||||
#define USBERR_GET_MEMORY_FAILED (0xC6)
|
||||
#define USBERR_INVALID_MEM_TYPE (0xC7)
|
||||
#define USBERR_NO_DESCRIPTOR (0xC8)
|
||||
#define USBERR_NULL_CALLBACK (0xC9)
|
||||
#define USBERR_NO_INTERFACE (0xCA)
|
||||
#define USBERR_INVALID_CFIG_NUM (0xCB)
|
||||
#define USBERR_INVALID_ANCHOR (0xCC)
|
||||
#define USBERR_INVALID_REQ_TYPE (0xCD)
|
||||
|
||||
/* Pipe Types */
|
||||
#define USB_CONTROL_PIPE (0x00)
|
||||
#define USB_ISOCHRONOUS_PIPE (0x01)
|
||||
#define USB_BULK_PIPE (0x02)
|
||||
#define USB_INTERRUPT_PIPE (0x03)
|
||||
|
||||
/* Device States */
|
||||
#define USB_STATE_UNKNOWN (0xFF)
|
||||
#define USB_STATE_PENDING_ADDRESS (0x04)
|
||||
#define USB_STATE_POWERED (0x03)
|
||||
#define USB_STATE_DEFAULT (0x02)
|
||||
#define USB_STATE_ADDRESS (0x01)
|
||||
#define USB_STATE_CONFIG (0x00)
|
||||
#define USB_STATE_SUSPEND (0x80)
|
||||
|
||||
/* Get_Status Request information for DEVICE */
|
||||
#define USB_SELF_POWERED (0x01)
|
||||
#define USB_REMOTE_WAKEUP (0x02)
|
||||
|
||||
/* Get_Status Request information for OTG (WINDEX = 0xF000) */
|
||||
#ifdef OTG_BUILD
|
||||
#define USB_OTG_HOST_REQUEST_FLAG (0x01)
|
||||
#endif
|
||||
|
||||
/* Bus Control values */
|
||||
#define USB_NO_OPERATION (0x00)
|
||||
#define USB_ASSERT_BUS_RESET (0x01)
|
||||
#define USB_DEASSERT_BUS_RESET (0x02)
|
||||
#define USB_ASSERT_RESUME (0x03)
|
||||
#define USB_DEASSERT_RESUME (0x04)
|
||||
#define USB_SUSPEND_SOF (0x05)
|
||||
#define USB_RESUME_SOF (0x06)
|
||||
|
||||
/* possible values of Status */
|
||||
#define USB_STATUS_IDLE (0)
|
||||
#define USB_STATUS_TRANSFER_ACCEPTED (6)
|
||||
#define USB_STATUS_TRANSFER_PENDING (2)
|
||||
#define USB_STATUS_TRANSFER_IN_PROGRESS (3)
|
||||
#define USB_STATUS_ERROR (4)
|
||||
#define USB_STATUS_DISABLED (5)
|
||||
#define USB_STATUS_STALLED (1)
|
||||
#define USB_STATUS_TRANSFER_QUEUED (7)
|
||||
|
||||
#define USB_STATUS_UNKNOWN (0xFF)
|
||||
|
||||
#define USB_CONTROL_ENDPOINT (0)
|
||||
|
||||
#define USB_RECV (0)
|
||||
#define USB_SEND (1)
|
||||
|
||||
#define USB_DEVICE_DONT_ZERO_TERMINATE (0x1)
|
||||
|
||||
#define USB_SETUP_DATA_XFER_DIRECTION (0x80)
|
||||
|
||||
#define USB_SPEED_FULL (0)
|
||||
#define USB_SPEED_LOW (1)
|
||||
#define USB_SPEED_HIGH (2)
|
||||
|
||||
#define USB_MAX_PKTS_PER_UFRAME (0x6)
|
||||
|
||||
#define USB_TEST_MODE_TEST_PACKET (0x0400)
|
||||
|
||||
/* Available service types */
|
||||
/* Services 0 through 15 are reserved for endpoints */
|
||||
#define USB_SERVICE_EP0 (0x00)
|
||||
#define USB_SERVICE_EP1 (0x01)
|
||||
#define USB_SERVICE_EP2 (0x02)
|
||||
#define USB_SERVICE_EP3 (0x03)
|
||||
#define USB_SERVICE_EP4 (0x04)
|
||||
#define USB_SERVICE_EP5 (0x05)
|
||||
#define USB_SERVICE_EP6 (0x06)
|
||||
#define USB_SERVICE_EP7 (0x07)
|
||||
#define USB_SERVICE_EP8 (0x08)
|
||||
#define USB_SERVICE_EP9 (0x09)
|
||||
#define USB_SERVICE_EP10 (0x0A)
|
||||
#define USB_SERVICE_EP11 (0x0B)
|
||||
#define USB_SERVICE_EP12 (0x0C)
|
||||
#define USB_SERVICE_EP13 (0x0d)
|
||||
#define USB_SERVICE_EP14 (0x0E)
|
||||
#define USB_SERVICE_EP15 (0x0F)
|
||||
|
||||
#define USB_SERVICE_BUS_RESET (0x10)
|
||||
#define USB_SERVICE_SUSPEND (0x11)
|
||||
#define USB_SERVICE_SOF (0x12)
|
||||
#define USB_SERVICE_RESUME (0x13)
|
||||
#define USB_SERVICE_SLEEP (0x14)
|
||||
#define USB_SERVICE_SPEED_DETECTION (0x15)
|
||||
#define USB_SERVICE_ERROR (0x16)
|
||||
#define USB_SERVICE_STALL (0x17)
|
||||
#define USB_SERVICE_MAX (0x18)
|
||||
|
||||
#if 0 /* << EST */
|
||||
#if (defined(_MCF51JM128_H) ||defined(_MCF51MM256_H) || (defined _MCF51JE256_H))
|
||||
#define USB_SERVICE_MAX_EP USB_SERVICE_EP15
|
||||
#else
|
||||
#ifdef DOUBLE_BUFFERING_USED
|
||||
#define USB_SERVICE_MAX_EP USB_SERVICE_EP6
|
||||
#else
|
||||
#define USB_SERVICE_MAX_EP USB_SERVICE_EP4
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
/* device is Kinetis K20D72 << EST */
|
||||
#ifdef DOUBLE_BUFFERING_USED
|
||||
#define USB_SERVICE_MAX_EP USB_SERVICE_EP6
|
||||
#else
|
||||
#define USB_SERVICE_MAX_EP USB_SERVICE_EP4
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Informational Request/Set Types */
|
||||
/* component parameter in USB_Device_Get/Set_Status */
|
||||
#define USB_COMPONENT_DIRECTION_SHIFT (7)
|
||||
#define USB_COMPONENT_DIRECTION_MASK (0x01)
|
||||
#define USB_STATUS_DEVICE_STATE (0x01)
|
||||
#define USB_STATUS_INTERFACE (0x02)
|
||||
#define USB_STATUS_ADDRESS (0x03)
|
||||
#define USB_STATUS_CURRENT_CONFIG (0x04)
|
||||
#define USB_STATUS_SOF_COUNT (0x05)
|
||||
#define USB_STATUS_DEVICE (0x06)
|
||||
|
||||
// Endpoint attributes
|
||||
#define EP_TRANSFER_TYPE_CONTROL (0x0<<0)
|
||||
#define EP_TRANSFER_TYPE_ISOCHRONOUS (0x1<<0)
|
||||
#define EP_TRANSFER_TYPE_BULK (0x2<<0)
|
||||
#define EP_TRANSFER_TYPE_INTERRUPT (0x3<<0)
|
||||
|
||||
/* Standard Request Code */
|
||||
#define GET_STATUS 0x0
|
||||
#define CLEAR_FEATURE 0x1
|
||||
#define SET_FEATURE 0x3
|
||||
#define SET_ADDRESS 0x5
|
||||
#define GET_DESCRIPTOR 0x6
|
||||
#define SET_DESCRIPTOR 0x7
|
||||
#define GET_CONFIGURATION 0x8
|
||||
#define SET_CONFIGURATION 0x9
|
||||
#define GET_INTERFACE 0xA
|
||||
#define SET_INTERFACE 0xB
|
||||
#define SYNCH_FRAME 0xC
|
||||
|
||||
#ifdef OTG_BUILD
|
||||
#define USB_STATUS_OTG (0x07)
|
||||
#define USB_STATUS_TEST_MODE (0x08)
|
||||
#else
|
||||
#define USB_STATUS_TEST_MODE (0x07)
|
||||
#endif
|
||||
|
||||
#define USB_STATUS_ENDPOINT (0x10)
|
||||
#define USB_STATUS_ENDPOINT_NUMBER_MASK (0x0F)
|
||||
|
||||
#define UNINITIALISED_VAL (0xFFFFFFFF)
|
||||
|
||||
#if 0 /* << EST */
|
||||
#if (defined MCU_MK40N512VMD100) || (defined MCU_MK53N512CMD100) || (defined MCU_MK60N512VMD100) || (defined MCU_MK70F12)
|
||||
#define USB_DEVICE_ASSERT_RESUME() USB0_CTL |= USB_CTL_RESUME_MASK;
|
||||
#define USB_DEVICE_DEASSERT_RESUME() USB0_CTL &= ~USB_CTL_RESUME_MASK;
|
||||
#elif (defined _MC9S08JE128_H) || (defined _MC9S08JM16_H) || defined(_MC9S08JM60_H) || (defined _MC9S08JS16_H) || (defined _MC9S08MM128_H)
|
||||
#define USB_DEVICE_ASSERT_RESUME() CTL_CRESUME = 1;
|
||||
#define USB_DEVICE_DEASSERT_RESUME() CTL_CRESUME = 0;
|
||||
#elif (defined _MCF51JE256_H) || (defined MCU_mcf51jf128) || defined(_MCF51MM256_H)
|
||||
#define USB_DEVICE_ASSERT_RESUME() USBTRC0_USBRESMEN = 1;
|
||||
#define USB_DEVICE_DEASSERT_RESUME() USBTRC0_USBRESMEN = 0;
|
||||
#elif (defined __MCF52221_H__) || defined(__MCF52259_H__)
|
||||
#define USB_DEVICE_ASSERT_RESUME() CTL |= MCF_USB_OTG_CTL_RESUME;
|
||||
#define USB_DEVICE_DEASSERT_RESUME() CTL &= ~MCF_USB_OTG_CTL_RESUME;
|
||||
#endif
|
||||
#else
|
||||
/* device is Kinetis K20D72 << EST */
|
||||
#endif
|
||||
|
||||
#define USB_PROCESS_PENDING() ((gu8ProcessPendingFlag != 0) || (gtUSBEPEventFlags != 0))
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* Types
|
||||
*****************************************************************************/
|
||||
typedef void _PTR_ _usb_device_handle;
|
||||
typedef uint_8 T_EP_BITFIELD;
|
||||
|
||||
#if 0 /* << EST */
|
||||
#if !(defined _MC9S08JE128_H) && !(defined _MC9S08JM16_H) && !defined(_MC9S08JM60_H) && !(defined _MC9S08JS16_H) && !(defined _MC9S08MM128_H)
|
||||
#pragma pack (1) /* Enforce 1 byte struct alignment */
|
||||
#endif
|
||||
#else
|
||||
#ifndef __HIWARE__
|
||||
/* << EST pushing current packing */
|
||||
#pragma pack(push)
|
||||
#pragma pack(1) /* Enforce 1 byte struct alignment */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __MK_xxx_H__
|
||||
#if (defined(__CWCC__) || defined(__GNUC__))
|
||||
#define ALIGN __attribute__ ((packed))
|
||||
#elif((defined __IAR_SYSTEMS_ICC__) || (defined __CC_ARM))
|
||||
#define ALIGN
|
||||
#else
|
||||
#define ALIGN
|
||||
#endif
|
||||
#else
|
||||
#define ALIGN
|
||||
#endif
|
||||
|
||||
typedef struct _USB_DEV_EVENT_STRUCT
|
||||
{
|
||||
uint_8 controller_ID; /* controller ID */
|
||||
uint_8 ep_num;
|
||||
boolean setup; /* is setup packet */
|
||||
boolean direction; /* direction of endpoint */
|
||||
uint_8* buffer_ptr; /* pointer to buffer */
|
||||
uint_8 errors; /* Any errors */
|
||||
USB_PACKET_SIZE len; /* buffer size of endpoint */
|
||||
}ALIGN USB_DEV_EVENT_STRUCT, *PTR_USB_DEV_EVENT_STRUCT;
|
||||
|
||||
// Same endpoint can have multiple function assignments in g_usb_CB, depending on user input
|
||||
#ifndef MULTIPLE_DEVICES
|
||||
typedef void(_CODE_PTR_ const USB_SERVICE_CALLBACK)(PTR_USB_DEV_EVENT_STRUCT);
|
||||
#else
|
||||
typedef void(_CODE_PTR_ USB_SERVICE_CALLBACK)(PTR_USB_DEV_EVENT_STRUCT);
|
||||
#endif
|
||||
|
||||
typedef struct _USB_EP_STRUCT
|
||||
{
|
||||
uint_8 ep_num; /* endpoint number */
|
||||
uint_8 type; /* type of endpoint */
|
||||
uint_8 direction; /* direction of endpoint */
|
||||
USB_PACKET_SIZE size ALIGN; /* buffer size of endpoint */
|
||||
}ALIGN USB_EP_STRUCT, *USB_EP_STRUCT_PTR;
|
||||
|
||||
#if (defined(__CWCC__))/*||defined(__GNUC__))*/ /* << EST: that pragma does not exist for gcc */
|
||||
#pragma options align = reset
|
||||
#elif defined(__GNUC__) /* << EST */
|
||||
/* << EST restoring previous packing */
|
||||
#pragma pack(pop)
|
||||
#elif defined(__IAR_SYSTEMS_ICC__) || defined(__CC_ARM)
|
||||
#pragma pack()
|
||||
#endif
|
||||
|
||||
|
||||
extern volatile uint_8 gu8ProcessPendingFlag;
|
||||
extern volatile T_EP_BITFIELD gtUSBEPEventFlags;
|
||||
|
||||
/******************************************************************************
|
||||
* Global Functions
|
||||
*****************************************************************************/
|
||||
extern uint_8 _usb_device_init (
|
||||
uint_8 device_number,
|
||||
_usb_device_handle _PTR_ handle,
|
||||
uint_8 number_of_endpoints,
|
||||
uint_8 bVregEn
|
||||
);
|
||||
|
||||
extern uint_8 _usb_device_deinit(void);
|
||||
|
||||
extern uint_8 _usb_device_init_endpoint(
|
||||
_usb_device_handle handle,
|
||||
uint_8 endpoint_number,
|
||||
uint_16 max_packet_size,
|
||||
uint_8 direction,
|
||||
uint_8 endpoint_type,
|
||||
uint_8 flag
|
||||
);
|
||||
|
||||
extern uint_8 _usb_device_cancel_transfer (
|
||||
_usb_device_handle handle,
|
||||
uint_8 endpoint_number,
|
||||
uint_8 direction
|
||||
);
|
||||
|
||||
extern uint_8 _usb_device_deinit_endpoint (
|
||||
_usb_device_handle handle,
|
||||
uint_8 endpoint_number,
|
||||
uint_8 direction
|
||||
);
|
||||
|
||||
extern uint_8 _usb_device_recv_data (
|
||||
_usb_device_handle handle,
|
||||
uint_8 endpoint_number,
|
||||
uint8_ptr buffer_ptr,
|
||||
uint_32 size
|
||||
);
|
||||
|
||||
extern uint_8 _usb_device_send_data (
|
||||
_usb_device_handle handle,
|
||||
uint_8 endpoint_number,
|
||||
uint8_ptr buffer_ptr,
|
||||
uint_32 size
|
||||
);
|
||||
|
||||
extern uint_8 _usb_device_get_send_buffer (
|
||||
uint_8 controller_ID, /* [IN] Controller ID */
|
||||
uint_8 ep_num, /* [IN] Endpoint number */
|
||||
uint_8_ptr *buff_ptr, /* [OUT] Buffer for IN endpoint */
|
||||
USB_PACKET_SIZE *size /* [OUT] Size of IN endpoint */
|
||||
);
|
||||
|
||||
extern void _usb_device_shutdown (
|
||||
_usb_device_handle handle
|
||||
);
|
||||
|
||||
extern void _usb_device_stall_endpoint (
|
||||
_usb_device_handle handle,
|
||||
uint_8 endpoint_number,
|
||||
uint_8 direction
|
||||
);
|
||||
|
||||
extern void _usb_device_unstall_endpoint (
|
||||
_usb_device_handle handle,
|
||||
uint_8 endpoint_number,
|
||||
uint_8 direction
|
||||
);
|
||||
|
||||
extern void _usb_device_read_setup_data (
|
||||
_usb_device_handle handle,
|
||||
uint_8 endpoint_number,
|
||||
uint_8_ptr buffer_ptr
|
||||
);
|
||||
|
||||
extern uint_8 _usb_device_get_status (
|
||||
_usb_device_handle handle,
|
||||
uint_8 component,
|
||||
uint_8_ptr status
|
||||
);
|
||||
|
||||
extern uint_8 _usb_device_set_status (
|
||||
_usb_device_handle handle,
|
||||
uint_8 component,
|
||||
uint_8 setting
|
||||
);
|
||||
|
||||
extern void _usb_device_clear_data0_endpoint(
|
||||
uint_8 endpoint_number,
|
||||
uint_8 direction
|
||||
);
|
||||
|
||||
extern void _usb_device_assert_resume (
|
||||
_usb_device_handle handle
|
||||
);
|
||||
|
||||
extern uint_8 _usb_device_register_service (
|
||||
uint_8 controller_ID,
|
||||
uint_8 type,
|
||||
USB_SERVICE_CALLBACK service
|
||||
);
|
||||
|
||||
extern uint_8 _usb_device_unregister_service (
|
||||
_usb_device_handle handle,
|
||||
uint_8 event_endpoint
|
||||
);
|
||||
|
||||
extern uint_8 _usb_device_get_transfer_status (
|
||||
_usb_device_handle handle,
|
||||
uint_8 endpoint_number,
|
||||
uint_8 direction
|
||||
);
|
||||
|
||||
extern void _usb_device_set_address (
|
||||
_usb_device_handle handle,
|
||||
uint_8 address
|
||||
);
|
||||
|
||||
extern uint_8 USB_Device_Call_Service(
|
||||
uint_8 type,
|
||||
PTR_USB_DEV_EVENT_STRUCT event
|
||||
);
|
||||
|
||||
extern void USB_Engine(void);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,629 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Freescale Semiconductor Inc.
|
||||
* (c) Copyright 2004-2010 Freescale Semiconductor, Inc.
|
||||
* ALL RIGHTS RESERVED.
|
||||
*
|
||||
******************************************************************************
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY FREESCALE "AS IS" AND ANY EXPRESSED OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL FREESCALE OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
**************************************************************************//*!
|
||||
*
|
||||
* @file usb_driver.c
|
||||
*
|
||||
* @author
|
||||
*
|
||||
* @version
|
||||
*
|
||||
* @date
|
||||
*
|
||||
* @brief The file contains S08 USB stack device layer implementation.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Includes
|
||||
*****************************************************************************/
|
||||
#include "usb_devapi.h" /* USB Device Layer API Header File */
|
||||
#include "usb_dciapi.h" /* USB Controller API Header File */
|
||||
#ifdef _MK_xxx_H_
|
||||
#include "usb_dci_kinetis.h"
|
||||
#endif
|
||||
#ifndef MULTIPLE_DEVICES
|
||||
#include "USB_Config.h"
|
||||
#endif
|
||||
|
||||
/*****************************************************************************
|
||||
* Constant and Macro's
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Global Variables
|
||||
****************************************************************************/
|
||||
extern void USB_Control_Service (PTR_USB_DEV_EVENT_STRUCT event );
|
||||
extern void USB_Reset_Service (PTR_USB_DEV_EVENT_STRUCT event );
|
||||
extern void USB_Sof_Service (PTR_USB_DEV_EVENT_STRUCT event );
|
||||
extern void USB_Resume_Service (PTR_USB_DEV_EVENT_STRUCT event );
|
||||
extern void USB_Suspend_Service (PTR_USB_DEV_EVENT_STRUCT event );
|
||||
extern void USB_Error_Service (PTR_USB_DEV_EVENT_STRUCT event );
|
||||
extern void USB_Stall_Service (PTR_USB_DEV_EVENT_STRUCT event );
|
||||
|
||||
/* Array of USB Service pointers */
|
||||
#ifdef MULTIPLE_DEVICES
|
||||
static USB_SERVICE_CALLBACK g_usb_CB[USB_SERVICE_MAX];
|
||||
#else
|
||||
static USB_SERVICE_CALLBACK g_usb_CB[USB_SERVICE_MAX] = {
|
||||
USB_EP0_CALLBACK,
|
||||
USB_EP1_CALLBACK,
|
||||
USB_EP2_CALLBACK,
|
||||
USB_EP3_CALLBACK,
|
||||
USB_EP4_CALLBACK,
|
||||
USB_EP5_CALLBACK,
|
||||
USB_EP6_CALLBACK,
|
||||
USB_EP7_CALLBACK,
|
||||
USB_EP8_CALLBACK,
|
||||
USB_EP9_CALLBACK,
|
||||
USB_EP10_CALLBACK,
|
||||
USB_EP11_CALLBACK,
|
||||
USB_EP12_CALLBACK,
|
||||
USB_EP13_CALLBACK,
|
||||
USB_EP14_CALLBACK,
|
||||
USB_EP15_CALLBACK,
|
||||
USB_BUS_RESET_CALLBACK,
|
||||
USB_SUSPEND_CALLBACK,
|
||||
USB_SOF_CALLBACK,
|
||||
USB_RESUME_CALLBACK,
|
||||
USB_SLEEP_CALLBACK,
|
||||
USB_SPEED_DETECTION_CALLBACK,
|
||||
USB_ERROR_CALLBACK,
|
||||
USB_STALL_CALLBACK
|
||||
};
|
||||
#endif
|
||||
/* Array of USB Component Status */
|
||||
/* Test mode is the last service */
|
||||
static uint_8 g_usb_component_status[USB_STATUS_TEST_MODE];
|
||||
/* Array of USB Endpoint Status */
|
||||
static uint_8 g_usb_ep_status[MAX_SUPPORTED_ENDPOINTS];
|
||||
/* Current un-initialized non CONTROL Endpoint */
|
||||
static uint_8 g_EPn=0;
|
||||
/* Maximum number of Non CONTROL Endpoint required by upper layer */
|
||||
static uint_8 g_EPn_max=0;
|
||||
|
||||
/*****************************************************************************
|
||||
* Local Types - None
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* Local Functions Prototypes - None
|
||||
*****************************************************************************/
|
||||
static void USB_Device_Init_Params(void);
|
||||
|
||||
/*****************************************************************************
|
||||
* Local Variables - None
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* Local Functions
|
||||
*****************************************************************************/
|
||||
#if 0 /* << EST */
|
||||
#if (defined(_MC9S08MM128_H) || defined(_MC9S08JE128_H))
|
||||
#pragma CODE_SEG DEFAULT
|
||||
#endif
|
||||
#else
|
||||
/* device is Kinetis K20D72 << EST */
|
||||
#endif
|
||||
/*****************************************************************************
|
||||
* Global Functions
|
||||
*****************************************************************************/
|
||||
extern uint_8 USB_DCI_DeInit(void);
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Device_Init_Params
|
||||
*
|
||||
* @brief The function initializes the Device Layer Structures
|
||||
*
|
||||
* @param None
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
******************************************************************************
|
||||
* Initializes USB Device Layer Structures
|
||||
*****************************************************************************/
|
||||
static void USB_Device_Init_Params(void)
|
||||
{
|
||||
uint_8 loop_index=0;
|
||||
|
||||
g_EPn= g_EPn_max; /* 1 control endpoint */
|
||||
|
||||
/*
|
||||
Initialize USB_STATUS_DEVICE_STATE, USB_STATUS_INTERFACE,
|
||||
USB_STATUS_ADDRESS, USB_STATUS_CURRENT_CONFIG, USB_STATUS_SOF_COUNT
|
||||
and USB_STATUS_DEVICE to USB_STATUS_UNKNOWN
|
||||
*/
|
||||
for(loop_index = 0; loop_index < USB_STATUS_TEST_MODE; loop_index++)
|
||||
{
|
||||
#ifdef OTG_BUILD
|
||||
if(loop_index != (USB_STATUS_OTG-1)) /* Do not initialize the OTG status with 0xFFFF */
|
||||
#endif
|
||||
{
|
||||
g_usb_component_status[loop_index] = USB_STATUS_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
/* Initialize status of All Endpoints to USB_STATUS_DISABLED */
|
||||
for(loop_index = 0; loop_index < MAX_SUPPORTED_ENDPOINTS; loop_index++)
|
||||
{
|
||||
g_usb_ep_status[loop_index] = USB_STATUS_DISABLED;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
* Global Functions
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name _usb_device_init
|
||||
*
|
||||
* @brief The function initializes the Device and Controller layer
|
||||
*
|
||||
* @param device_number : USB Device controller to initialize
|
||||
* @param handle : pointer to USB Device handle
|
||||
* @param number_of_endpoints : Endpoint count of the application
|
||||
*
|
||||
* @return status
|
||||
* USB_OK : When Successfull
|
||||
* USBERR_INVALID_NUM_OF_ENDPOINTS : When endpoints > max Supported
|
||||
******************************************************************************
|
||||
* This function initializes the Device layer and the Controller layer of the
|
||||
* S08 USB stack. It initializes the variables used for this layer and then
|
||||
* calls the controller layer initialize function
|
||||
*****************************************************************************/
|
||||
uint_8 _usb_device_init (
|
||||
uint_8 device_number, /* [IN] USB Device controller to initialize */
|
||||
_usb_device_handle _PTR_ handle, /* [IN] Pointer to USB Device handle */
|
||||
uint_8 number_of_endpoints, /* [IN] Number of endpoints to initialize */
|
||||
uint_8 bVregEn /* Enables or disables internal regulator */
|
||||
)
|
||||
{
|
||||
UNUSED(handle);
|
||||
|
||||
/* validate endpoints param */
|
||||
if((number_of_endpoints > MAX_SUPPORTED_ENDPOINTS) ||
|
||||
(number_of_endpoints < MIN_SUPPORTED_ENDPOINTS))
|
||||
{
|
||||
return USBERR_INVALID_NUM_OF_ENDPOINTS;
|
||||
}
|
||||
|
||||
/* init variables */
|
||||
g_EPn_max = (uint_8)(number_of_endpoints - 1);
|
||||
|
||||
USB_Device_Init_Params();
|
||||
|
||||
#ifdef MULTIPLE_DEVICES
|
||||
/* Initialize all services to null value */
|
||||
Clear_Mem((uint_8_ptr)g_usb_CB,
|
||||
(uint_32)(sizeof(USB_SERVICE_CALLBACK) * USB_SERVICE_MAX), (uint_8)0);
|
||||
#endif
|
||||
/* Call controller layer initialization function */
|
||||
return USB_DCI_Init(device_number, bVregEn);
|
||||
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name _usb_device_deinit
|
||||
*
|
||||
* @brief The function de-initializes the Device and Controller layer
|
||||
*
|
||||
* @return status
|
||||
* USB_OK : When Successfull
|
||||
* USBERR_INVALID_NUM_OF_ENDPOINTS : When endpoints > max Supported
|
||||
******************************************************************************
|
||||
* This function de-initializes the Device layer and the Controller layer
|
||||
*****************************************************************************/
|
||||
uint_8 _usb_device_deinit(void)
|
||||
{
|
||||
g_EPn_max = 0;
|
||||
/* Call controller layer de-initialization function */
|
||||
return USB_DCI_DeInit();
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name _usb_device_init_endpoint
|
||||
*
|
||||
* @brief The function initializes the endpoint
|
||||
*
|
||||
* @param handle : USB Device handle
|
||||
* @param endpoint_number : Endpoint number
|
||||
* @param max_packet_size : Maximum packet size (in bytes) for the endpoint
|
||||
* @param direction : Direction of transfer
|
||||
* @param endpoint_type : Type of endpoint
|
||||
* @param flag : Zero termination flag
|
||||
*
|
||||
* @return status
|
||||
* USB_OK : When Successfull
|
||||
* USBERR_EP_INIT_FAILED : When endpoints > max Supported
|
||||
******************************************************************************
|
||||
*
|
||||
* This function initializes an endpoint the Device layer and the Controller
|
||||
* layer in the S08 USB stack. It validate whether all endpoints have already
|
||||
* been initialized or not and then calls the controller layer endpoint
|
||||
* initialize function
|
||||
*
|
||||
*****************************************************************************/
|
||||
uint_8 _usb_device_init_endpoint (
|
||||
_usb_device_handle handle, /* [IN] USB Device handle */
|
||||
uint_8 endpoint_number, /* [IN] Endpoint number*/
|
||||
uint_16 max_packet_size, /* [IN] Maximum packet size (in bytes) for the endpoint */
|
||||
uint_8 direction, /* [IN] Direction of transfer */
|
||||
uint_8 endpoint_type, /* [IN] Type of endpoint */
|
||||
uint_8 flag /* [IN] Zero termination flag */
|
||||
)
|
||||
{
|
||||
USB_EP_STRUCT ep_str;
|
||||
|
||||
uint_8 status = USB_OK;
|
||||
|
||||
/* check if all endpoint have already been initialised */
|
||||
if((g_EPn == 0) && (endpoint_number != CONTROL_ENDPOINT))
|
||||
{
|
||||
return USBERR_EP_INIT_FAILED;
|
||||
}
|
||||
|
||||
ep_str.direction = direction;
|
||||
ep_str.ep_num = endpoint_number;
|
||||
|
||||
#if 0 /* << EST */
|
||||
#ifndef _MC9S08JS16_H
|
||||
ep_str.size = max_packet_size;
|
||||
#else
|
||||
ep_str.size = (char)max_packet_size;
|
||||
#endif
|
||||
#else
|
||||
/* device is Kinetis K20D72 << EST */
|
||||
ep_str.size = max_packet_size;
|
||||
#endif
|
||||
|
||||
ep_str.type = endpoint_type;
|
||||
|
||||
/* call controller layer for initiazation */
|
||||
status = USB_DCI_Init_EndPoint(*((uint_8*)handle), &ep_str, flag);
|
||||
|
||||
/* if endpoint successfully initialised update counter */
|
||||
if((ep_str.ep_num != CONTROL_ENDPOINT) && (status == USB_OK))
|
||||
{
|
||||
g_EPn--;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name _usb_device_deinit_endpoint
|
||||
*
|
||||
* @brief The function de-initializes the endpoint
|
||||
*
|
||||
* @param handle : USB Device handle
|
||||
* @param endpoint_number : Endpoint number
|
||||
* @param direction : Endpoint direction
|
||||
*
|
||||
* @return status
|
||||
* USB_OK : When Successfull
|
||||
* USBERR_EP_DEINIT_FAILED : When endpoints > max Supported
|
||||
******************************************************************************
|
||||
*
|
||||
* This function deinitializes an endpoint the Device layer and the Controller
|
||||
* layer in the S08 USB stack. It validate whether all endpoints have already
|
||||
* been deinitialized or not and then calls the controller layer endpoint
|
||||
* deinitialize function
|
||||
*
|
||||
*****************************************************************************/
|
||||
uint_8 _usb_device_deinit_endpoint (
|
||||
_usb_device_handle handle, /* [IN] USB Device handle */
|
||||
uint_8 endpoint_number, /* [IN] Endpoint number */
|
||||
uint_8 direction /* [IN] Direction */
|
||||
)
|
||||
{
|
||||
uint_8 status=USB_OK;
|
||||
|
||||
/* check if all endpoint have already been initialised */
|
||||
if((g_EPn == g_EPn_max) && (endpoint_number != CONTROL_ENDPOINT))
|
||||
{
|
||||
return USBERR_EP_DEINIT_FAILED;
|
||||
}
|
||||
|
||||
/* call controller layer for initiazation */
|
||||
status = USB_DCI_Deinit_EndPoint(*((uint_8*)handle), endpoint_number, direction);
|
||||
|
||||
/* if endpoint successfully deinitialised update counter */
|
||||
if((endpoint_number != CONTROL_ENDPOINT) && (status == USB_OK))
|
||||
{
|
||||
g_EPn++;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name _usb_device_get_status
|
||||
*
|
||||
* @brief The function retrieves various endpoint as well as USB component status
|
||||
*
|
||||
* @param handle : USB Device handle
|
||||
* @param component : USB component
|
||||
* @param status : Pointer to 16 bit return value
|
||||
*
|
||||
* @return status
|
||||
* USB_OK : When Successfull
|
||||
* USBERR_BAD_STATUS : When error
|
||||
*
|
||||
******************************************************************************
|
||||
* This function retrieves the endpoint as well USB component status which is
|
||||
* stored by calling USB_Device_Set_Status. This function can be called by Ap-
|
||||
* plication as well as the DCI layer.
|
||||
*****************************************************************************/
|
||||
uint_8 _usb_device_get_status (
|
||||
_usb_device_handle handle, /* [IN] USB Device handle */
|
||||
uint_8 component, /* [IN] USB component */
|
||||
uint_8_ptr status /* [OUT] Pointer to 16 bit return value */
|
||||
)
|
||||
{
|
||||
/* get the endpoint number from component input variable */
|
||||
uint_8 ep_num = (uint_8)(component & USB_STATUS_ENDPOINT_NUMBER_MASK);
|
||||
UNUSED (handle);
|
||||
|
||||
if((component <= USB_STATUS_TEST_MODE) &&
|
||||
(component >= USB_STATUS_DEVICE_STATE))
|
||||
{
|
||||
/* Get the corresponding component status
|
||||
-1 as components start from 1 */
|
||||
*status = g_usb_component_status[component-1];
|
||||
}
|
||||
else if((component & USB_STATUS_ENDPOINT) &&
|
||||
(ep_num < MAX_SUPPORTED_ENDPOINTS))
|
||||
{
|
||||
/* Get the corresponding endpoint status */
|
||||
*status = g_usb_ep_status[ep_num];
|
||||
}
|
||||
else
|
||||
{
|
||||
return USBERR_BAD_STATUS;
|
||||
}
|
||||
|
||||
return USB_OK;
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name _usb_device_set_status
|
||||
*
|
||||
* @brief The function saves status of endpoints as well as USB components.
|
||||
*
|
||||
* @param handle : USB Device handle
|
||||
* @param component : USB component
|
||||
* @param setting : Value to be set
|
||||
*
|
||||
* @return status
|
||||
* USB_OK : When Successfull
|
||||
* USBERR_BAD_STATUS : When error
|
||||
*
|
||||
******************************************************************************
|
||||
* This function sets the endpoint as well USB component status which can be
|
||||
* retrieved by calling _usb_device_get_status. This function can be called by
|
||||
* Application as well as the DCI layer.
|
||||
*****************************************************************************/
|
||||
uint_8 _usb_device_set_status(
|
||||
_usb_device_handle handle, /* [IN] USB Device handle */
|
||||
uint_8 component, /* [IN] USB Component status to set */
|
||||
uint_8 setting /* [IN] Status to set */
|
||||
)
|
||||
{
|
||||
/* get the endpoint number from component input variable */
|
||||
uint_8 ep_num = (uint_8)(component & USB_STATUS_ENDPOINT_NUMBER_MASK);
|
||||
UNUSED (handle);
|
||||
|
||||
if((component <= USB_STATUS_TEST_MODE) &&
|
||||
(component >= USB_STATUS_DEVICE_STATE))
|
||||
{
|
||||
/*
|
||||
Set the corresponding component setting
|
||||
-1 as components start from 1
|
||||
*/
|
||||
g_usb_component_status[component-1] = setting;
|
||||
}
|
||||
else if((component & USB_STATUS_ENDPOINT) &&
|
||||
(ep_num < MAX_SUPPORTED_ENDPOINTS))
|
||||
{
|
||||
uint_8 direction =
|
||||
(uint_8)((component >> USB_COMPONENT_DIRECTION_SHIFT) &
|
||||
USB_COMPONENT_DIRECTION_MASK);
|
||||
/* HALT Endpoint */
|
||||
if(setting == USB_STATUS_STALLED)
|
||||
{
|
||||
_usb_device_stall_endpoint(handle, ep_num, direction);
|
||||
}
|
||||
else if((setting == USB_STATUS_IDLE) &&
|
||||
(g_usb_ep_status[ep_num] == USB_STATUS_STALLED))
|
||||
{
|
||||
_usb_device_unstall_endpoint(handle, ep_num, direction);
|
||||
|
||||
if(ep_num == CONTROL_ENDPOINT)
|
||||
{
|
||||
direction = (uint_8)((direction == USB_SEND)?
|
||||
(USB_RECV):(USB_SEND));
|
||||
_usb_device_unstall_endpoint(handle, ep_num, direction);
|
||||
}
|
||||
}
|
||||
/* Set the corresponding endpoint setting */
|
||||
g_usb_ep_status[ep_num] = setting;
|
||||
}
|
||||
else
|
||||
{
|
||||
return USBERR_BAD_STATUS;
|
||||
}
|
||||
return USB_OK;
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name _usb_device_register_service
|
||||
*
|
||||
* @brief The function registers a callback function from the Application layer
|
||||
*
|
||||
* @param controller_ID : Controller ID
|
||||
* @param type : event type or endpoint number
|
||||
* @param service : callback function pointer
|
||||
*
|
||||
* @return status
|
||||
* USB_OK : When Successfull
|
||||
* USBERR_ALLOC_SERVICE : When invalid type or already registered
|
||||
*
|
||||
******************************************************************************
|
||||
* This function registers a callback function from the application if it is
|
||||
* called not already registered so that the registered callback function can
|
||||
* be if the event of that type occurs
|
||||
*****************************************************************************/
|
||||
uint_8 _usb_device_register_service(
|
||||
uint_8 controller_ID, /* [IN] Controller ID */
|
||||
uint_8 type, /* [IN] type of event or endpoint
|
||||
number to service */
|
||||
USB_SERVICE_CALLBACK service /* [IN] pointer to callback
|
||||
function */
|
||||
)
|
||||
{
|
||||
UNUSED (controller_ID);
|
||||
UNUSED (service);
|
||||
#ifdef MULTIPLE_DEVICES
|
||||
/* check if the type is valid and callback for the type
|
||||
is not already registered */
|
||||
if(((type <= USB_SERVICE_MAX_EP) ||
|
||||
((type < USB_SERVICE_MAX) && (type >= USB_SERVICE_BUS_RESET))) &&
|
||||
(g_usb_CB[type] == NULL))
|
||||
{
|
||||
|
||||
/* register the callback function */
|
||||
g_usb_CB[type] = service;
|
||||
return USB_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
return USBERR_ALLOC_SERVICE;
|
||||
}
|
||||
#else
|
||||
UNUSED(type);
|
||||
return USB_OK;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name _usb_device_unregister_service
|
||||
*
|
||||
* @brief The function unregisters an event or endpoint callback function
|
||||
*
|
||||
* @param handle : USB Device handle
|
||||
* @param event_endpoint : event type or endpoint number
|
||||
*
|
||||
* @return status
|
||||
* USB_OK : When Successfull
|
||||
* USBERR_UNKNOWN_ERROR : When invalid type or not registered
|
||||
*
|
||||
*****************************************************************************
|
||||
* This function un registers a callback function which has been previously
|
||||
* registered by the application layer
|
||||
*****************************************************************************/
|
||||
uint_8 _usb_device_unregister_service(
|
||||
_usb_device_handle handle, /* [IN] USB Device handle */
|
||||
uint_8 event_endpoint /* [IN] Endpoint (0 through 15) or event to service */
|
||||
)
|
||||
{
|
||||
UNUSED (handle);
|
||||
/* check if the type is valid and callback for the type
|
||||
is already registered */
|
||||
if(((event_endpoint <= USB_SERVICE_MAX_EP) ||
|
||||
((event_endpoint < USB_SERVICE_MAX) && (event_endpoint >= USB_SERVICE_BUS_RESET))) &&
|
||||
(g_usb_CB[event_endpoint] != NULL))
|
||||
{
|
||||
#ifdef MULTIPLE_DEVICES
|
||||
/* unregister the callback */
|
||||
g_usb_CB[event_endpoint] = NULL;
|
||||
#endif
|
||||
return USB_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
return USBERR_UNKNOWN_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************************************************//*!
|
||||
*
|
||||
* @name USB_Device_Call_Service
|
||||
*
|
||||
* @brief The function is a device layer event handler
|
||||
*
|
||||
* @param type : Type of service or endpoint
|
||||
* @param event : Pointer to event structure
|
||||
*
|
||||
* @return status
|
||||
* USB_OK : Always
|
||||
*
|
||||
*****************************************************************************
|
||||
*
|
||||
* This function calls the registered service callback function of the applic-
|
||||
* ation layer based on the type of event received. This function is called
|
||||
* from the DCI layer.
|
||||
*
|
||||
*****************************************************************************/
|
||||
uint_8 USB_Device_Call_Service(
|
||||
uint_8 type, /* [IN] Type of service or endpoint */
|
||||
PTR_USB_DEV_EVENT_STRUCT event /* [IN] Pointer to event structure */
|
||||
)
|
||||
{
|
||||
|
||||
if(type == USB_SERVICE_BUS_RESET)
|
||||
{ /* if it is an reset interrupt then reset all status structures */
|
||||
USB_Device_Init_Params();
|
||||
}
|
||||
|
||||
/* check if the callback is registered or not */
|
||||
if(g_usb_CB[type] != NULL)
|
||||
{
|
||||
/* call the callback function */
|
||||
g_usb_CB[type](event);
|
||||
}
|
||||
|
||||
return USB_OK;
|
||||
}
|
||||
|
||||
void USB_NULL_CALLBACK (PTR_USB_DEV_EVENT_STRUCT event)
|
||||
{
|
||||
UNUSED(event);
|
||||
|
||||
#if (defined(__CWCC__) || defined(__IAR_SYSTEMS_ICC__) || defined(__GNUC__))
|
||||
asm("nop");
|
||||
#elif defined (__CC_ARM)
|
||||
__nop();
|
||||
#endif
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,151 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Freescale Semiconductor Inc.
|
||||
* (c) Copyright 2004-2009 Freescale Semiconductor, Inc.
|
||||
* ALL RIGHTS RESERVED.
|
||||
*
|
||||
******************************************************************************
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY FREESCALE "AS IS" AND ANY EXPRESSED OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL FREESCALE OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
**************************************************************************//*!
|
||||
*
|
||||
* @file usb_framwork.h
|
||||
*
|
||||
* @author
|
||||
*
|
||||
* @version
|
||||
*
|
||||
* @date May-28-2009
|
||||
*
|
||||
* @brief The file contains USB Framework module API header function.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef _USB_FRAMEWORK_H
|
||||
#define _USB_FRAMEWORK_H
|
||||
|
||||
/******************************************************************************
|
||||
* Includes
|
||||
*****************************************************************************/
|
||||
#include "types.h"
|
||||
#include "usb_class.h"
|
||||
#include "usb_descriptor.h"
|
||||
|
||||
/******************************************************************************
|
||||
* Constants - None
|
||||
*****************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Macro's
|
||||
*****************************************************************************/
|
||||
#define MAX_STRD_REQ (13) /* Max value of standard request */
|
||||
/* size of data to be returned for various Get Desc calls */
|
||||
#define DEVICE_STATUS_SIZE (2)
|
||||
#ifdef OTG_BUILD
|
||||
#define OTG_STATUS_SIZE (2)
|
||||
#endif
|
||||
#define INTERFACE_STATUS_SIZE (2)
|
||||
|
||||
#define CONFIG_SIZE (1)
|
||||
#define INTERFACE_SIZE (1)
|
||||
#define FRAME_SIZE (2)
|
||||
#define ENDP_STATUS_SIZE (2)
|
||||
|
||||
#ifdef OTG_BUILD
|
||||
#define DEVICE_SET_FEATURE_B_HNP_ENABLE (0x0003) /* B HNP enable SET/CLEAR feature value */
|
||||
#define DEVICE_SET_FEATURE_A_HNP_SUPPORT (0x0004) /* A HNP support SET/CLEAR feature value */
|
||||
#endif
|
||||
|
||||
/* Standard Feature Selectors */
|
||||
#define DEVICE_FEATURE_REMOTE_WAKEUP (0x0001)
|
||||
#define DEVICE_FEATURE_TEST_MODE (0x0002)
|
||||
#define DEVICE_SET_FEATURE_MASK ((uint_16)((1<<(DEVICE_FEATURE_REMOTE_WAKEUP)) | (1<<(DEVICE_FEATURE_TEST_MODE))))
|
||||
#define DEVICE_CLEAR_FEATURE_MASK ((uint_16)(1<<(DEVICE_FEATURE_REMOTE_WAKEUP)))
|
||||
|
||||
|
||||
|
||||
#define REPORT_DESCRIPTOR_TYPE (0x22)
|
||||
#define STRING_DESCRIPTOR_TYPE (0x03)
|
||||
|
||||
/* masks and values for provides of Get Desc information */
|
||||
#define USB_REQUEST_SRC_MASK (0x03)
|
||||
#define USB_REQUEST_SRC_DEVICE (0x00)
|
||||
#define USB_REQUEST_SRC_INTERFACE (0x01)
|
||||
#define USB_REQUEST_SRC_ENDPOINT (0x02)
|
||||
|
||||
#define USB_SET_REQUEST_MASK (0x02)
|
||||
|
||||
/* wIndex values for GET_Status */
|
||||
#ifdef OTG_BUILD
|
||||
#define USB_WINDEX_OTG_STATUS_SEL (0xF000)
|
||||
#endif
|
||||
|
||||
/* for transfer direction check */
|
||||
#define USB_DATA_TO_HOST (0x80)
|
||||
#define USB_DATA_TO_DEVICE (0x00)
|
||||
#define USB_DATA_DIREC_MASK (0x80)
|
||||
|
||||
#define USB_uint_16_low(x) ((uint_8)x) /* lsb byte */
|
||||
#define USB_uint_16_high(x) ((uint_8)(x>>8)) /* msb byte */
|
||||
|
||||
#ifdef CPU_LITTLE_ENDIAN /* << EST: defined by Processor Expert CPU.h for Kinetis devices */
|
||||
#ifndef LITTLE_ENDIAN /* might be defined already on the compiler command line? */
|
||||
#define LITTLE_ENDIAN
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if(defined LITTLE_ENDIAN)
|
||||
#define BYTE_SWAP16(a) (a)
|
||||
#else
|
||||
#define BYTE_SWAP16(a) (uint_16)((((uint_16)(a)&0xFF00)>>8) | \
|
||||
(((uint_16)(a)&0x00FF)<<8))
|
||||
#endif
|
||||
|
||||
/******************************************************************************
|
||||
* Types
|
||||
*****************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Global Functions
|
||||
*****************************************************************************/
|
||||
extern boolean USB_Frame_Remote_Wakeup(uint_8 controller_ID);
|
||||
|
||||
#define USB_Frame_Remote_Wakeup USB_Desc_Remote_Wakeup
|
||||
|
||||
typedef struct _app_data_struct
|
||||
{
|
||||
uint_8_ptr data_ptr; /* pointer to buffer */
|
||||
USB_PACKET_SIZE data_size; /* buffer size of endpoint */
|
||||
}APP_DATA_STRUCT;
|
||||
|
||||
extern uint_8 USB_Framework_Init (
|
||||
uint_8 controller_ID,
|
||||
USB_CLASS_CALLBACK callback,
|
||||
USB_REQ_FUNC other_req_callback
|
||||
);
|
||||
|
||||
extern uint_8 USB_Framework_DeInit
|
||||
(
|
||||
uint_8 controller_ID
|
||||
);
|
||||
|
||||
extern uint_8 USB_Framework_Reset (
|
||||
uint_8 controller_ID
|
||||
);
|
||||
#ifdef DELAYED_PROCESSING
|
||||
extern void USB_Framework_Periodic_Task(void);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Freescale Semiconductor Inc.
|
||||
* (c) Copyright 2004-2009 Freescale Semiconductor, Inc.
|
||||
* ALL RIGHTS RESERVED.
|
||||
*
|
||||
**************************************************************************//*!
|
||||
*
|
||||
* @file usb_user_config.h << EST 'user_config.h' conflicts with MQX Lite
|
||||
*
|
||||
* @author
|
||||
*
|
||||
* @version
|
||||
*
|
||||
* @date May-28-2009
|
||||
*
|
||||
* @brief The file contains User Modifiable Macros for Virtual COM Loopback
|
||||
* Application
|
||||
*
|
||||
*****************************************************************************/
|
||||
#if 0 /* << EST */
|
||||
#include "derivative.h"
|
||||
|
||||
#if (defined MCU_MK70F12) || (defined __MCF52277_H__)
|
||||
#define HIGH_SPEED_DEVICE (0)
|
||||
#else
|
||||
#define HIGH_SPEED_DEVICE (0)
|
||||
#endif
|
||||
|
||||
#if (defined MCU_MK20D7) || (defined MCU_MK40D7)
|
||||
#define MCGOUTCLK_72_MHZ
|
||||
#endif
|
||||
|
||||
#if ((defined __MK_xxx_H__)||(defined MCU_mcf51jf128))
|
||||
#define KEY_PRESS_SIM_TMR_INTERVAL (1000) /* 2s between simulated key press events */
|
||||
#else
|
||||
#ifdef __MCF52277_H__
|
||||
#define BUTTON_PRESS_SIMULATION (1)
|
||||
#define KEY_PRESS_SIM_TMR_INTERVAL (2000) /* 2s between simulated key press events */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#else
|
||||
#include "FSL_USB_Stack_Config.h"
|
||||
|
||||
/* device is Kinetis K20D72 << EST */
|
||||
#define HIGH_SPEED_DEVICE (0)
|
||||
|
||||
|
||||
#endif
|
||||
/*
|
||||
Below two MACROS are required for Virtual COM Loopback
|
||||
Application to execute
|
||||
*/
|
||||
#define LONG_SEND_TRANSACTION /* support to send large data pkts */
|
||||
#define LONG_RECEIVE_TRANSACTION /* support to receive large data pkts */
|
||||
#ifndef _MC9S08JS16_H
|
||||
#define USB_OUT_PKT_SIZE 32 /* Define the maximum data length received from the host */
|
||||
#else
|
||||
#define USB_OUT_PKT_SIZE 16 /* Define the maximum data length received from the host */
|
||||
#endif
|
||||
|
||||
/* User Defined MACRO to set number of Timer Objects */
|
||||
#define MAX_TIMER_OBJECTS 5
|
||||
|
||||
#if MAX_TIMER_OBJECTS
|
||||
/* When Enabled Timer Callback is invoked with an argument */
|
||||
#define TIMER_CALLBACK_ARG
|
||||
#undef TIMER_CALLBACK_ARG
|
||||
#endif
|
||||
|
||||
#if 0 /* << EST */
|
||||
#ifndef _MC9S08JS16_H
|
||||
#define USB_PACKET_SIZE uint_16 /* support 16/32 bit packet size */
|
||||
#else
|
||||
#define USB_PACKET_SIZE uint_8 /* support 8 bit packet size */
|
||||
#endif
|
||||
#else
|
||||
/* device is Kinetis K20D72 << EST */
|
||||
#define USB_PACKET_SIZE uint_16 /* support 16/32 bit packet size */
|
||||
#endif
|
||||
|
||||
#if 0 /* << EST */
|
||||
#ifndef _MCF51JM128_H
|
||||
/* Use double buffered endpoints 5 & 6. To be only used with S08 cores */
|
||||
#define DOUBLE_BUFFERING_USED
|
||||
#endif
|
||||
#else
|
||||
/* device is Kinetis K20D72 << EST */
|
||||
/* Use double buffered endpoints 5 & 6. To be only used with S08 cores */
|
||||
#define DOUBLE_BUFFERING_USED
|
||||
#endif
|
||||
@@ -0,0 +1,46 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Freescale Semiconductor Inc.
|
||||
* (c) Copyright 2004-2010 Freescale Semiconductor, Inc.
|
||||
* ALL RIGHTS RESERVED.
|
||||
*
|
||||
******************************************************************************
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY FREESCALE "AS IS" AND ANY EXPRESSED OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL FREESCALE OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
**************************************************************************//*!
|
||||
*
|
||||
* @file wdt_kinetis.c
|
||||
*
|
||||
* @author
|
||||
*
|
||||
* @version
|
||||
*
|
||||
* @date
|
||||
*
|
||||
* @brief This file contains the implementation of the Watchdog service routines on CFV2
|
||||
*****************************************************************************/
|
||||
|
||||
#include "types.h" /* User Defined Data Types */
|
||||
#include "hal/derivative.h" /* include peripheral declarations */
|
||||
#include "wdt_kinetis.h" /* own header with public declarations */
|
||||
|
||||
/*****************************************************************************/
|
||||
void Watchdog_Reset(void)
|
||||
{
|
||||
#if defined(MCU_MKL25Z4) || defined(MCU_MKL26Z4) || defined(MCU_MKL46Z4)
|
||||
(void)(RCM_SRS0 |= RCM_SRS0_WDOG_MASK);
|
||||
#else
|
||||
(void)(WDOG_REFRESH = 0xA602, WDOG_REFRESH = 0xB480);
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Freescale Semiconductor Inc.
|
||||
* (c) Copyright 2004-2010 Freescale Semiconductor, Inc.
|
||||
* ALL RIGHTS RESERVED.
|
||||
*
|
||||
******************************************************************************
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY FREESCALE "AS IS" AND ANY EXPRESSED OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL FREESCALE OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
**************************************************************************//*!
|
||||
*
|
||||
* @file Wdt_kinetis.h
|
||||
*
|
||||
* @brief This is the header file for the Watchdog service routines on CFV2
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef _WDT_KINETIS_
|
||||
#define _WDT_KINETIS_
|
||||
|
||||
/*****************************************************************************
|
||||
* Public functions
|
||||
*
|
||||
****************************************************************************/
|
||||
extern void Watchdog_Reset(void);
|
||||
|
||||
#endif /* _INIT_HW_ */
|
||||
@@ -0,0 +1,302 @@
|
||||
/*
|
||||
* kinetis_sysinit.c - Default init routines for Flycatcher
|
||||
* Kinetis ARM systems
|
||||
* Copyright © 2012 Freescale semiConductor Inc. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#include "hal/derivative.h"
|
||||
#include "kinetis_sysinit.h"
|
||||
|
||||
/**
|
||||
**===========================================================================
|
||||
** External declarations
|
||||
**===========================================================================
|
||||
*/
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
extern unsigned long _estack;
|
||||
extern void __thumb_startup(void);
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
**===========================================================================
|
||||
** Default interrupt handler
|
||||
**===========================================================================
|
||||
*/
|
||||
void Default_Handler(void)
|
||||
{
|
||||
// Uncomment this breakpoint instruction if you are debugging a hard
|
||||
// fault during development. If this breakpoint is hit without a
|
||||
// debugger attached a LOCKUP is triggered. For this processor this
|
||||
// causes an immediate system reset.
|
||||
//asm volatile ("bkpt");
|
||||
|
||||
while(1);
|
||||
|
||||
/* Fault registers:
|
||||
* 0xE000ED2C: HFSR (HardFault status register)
|
||||
* 0xE000ED28: MMFSR (MemManage fault status register)
|
||||
* 0xE000ED34: MMFAR (MemManage fault address register)
|
||||
* 0xE000ED29: BFSR (BusFault status register)
|
||||
* 0xE000ED38: BFAR (BusFault address register)
|
||||
*/
|
||||
}
|
||||
|
||||
/* Weak definitions of handlers point to Default_Handler if not implemented */
|
||||
void NMI_Handler(void) __attribute__ ((weak, alias("Default_Handler")));
|
||||
void HardFault_Handler(void) __attribute__ ((weak, alias("Default_Handler")));
|
||||
void MemManage_Handler(void) __attribute__ ((weak, alias("Default_Handler")));
|
||||
void BusFault_Handler(void) __attribute__ ((weak, alias("Default_Handler")));
|
||||
void UsageFault_Handler(void) __attribute__ ((weak, alias("Default_Handler")));
|
||||
void SVC_Handler(void) __attribute__ ((weak, alias("Default_Handler")));
|
||||
void DebugMon_Handler(void) __attribute__ ((weak, alias("Default_Handler")));
|
||||
void PendSV_Handler(void) __attribute__ ((weak, alias("Default_Handler")));
|
||||
void SysTick_Handler(void) __attribute__ ((weak, alias("Default_Handler")));
|
||||
|
||||
void DMA0_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* DMA channel 0 transfer complete interrupt */
|
||||
void DMA1_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* DMA channel 1 transfer complete interrupt */
|
||||
void DMA2_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* DMA channel 2 transfer complete interrupt */
|
||||
void DMA3_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* DMA channel 3 transfer complete interrupt */
|
||||
void DMA4_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* DMA channel 4 transfer complete interrupt */
|
||||
void DMA5_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* DMA channel 5 transfer complete interrupt */
|
||||
void DMA6_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* DMA channel 6 transfer complete interrupt */
|
||||
void DMA7_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* DMA channel 7 transfer complete interrupt */
|
||||
void DMA8_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* DMA channel 8 transfer complete interrupt */
|
||||
void DMA9_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* DMA channel 9 transfer complete interrupt */
|
||||
void DMA10_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* DMA channel 10 transfer complete interrupt */
|
||||
void DMA11_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* DMA channel 11 transfer complete interrupt */
|
||||
void DMA12_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* DMA channel 12 transfer complete interrupt */
|
||||
void DMA13_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* DMA channel 13 transfer complete interrupt */
|
||||
void DMA14_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* DMA channel 14 transfer complete interrupt */
|
||||
void DMA15_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* DMA channel 15 transfer complete interrupt */
|
||||
void DMA_Error_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* DMA error interrupt */
|
||||
void MCMNormal_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* MCM normal interrupt */
|
||||
void FlashCmd_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* Flash memory command complete interrupt */
|
||||
void FlashReadErr_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* Flash read collision interrupt */
|
||||
void LVD_LVW_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* Low Voltage Detect, Low Voltage Warning */
|
||||
void LLW_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* Low Leakage Wakeup */
|
||||
void Watchdog_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* WDOG or EVM interrupt (shared) */
|
||||
void Reserved39_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* Reserved interrupt 39 */
|
||||
void I2C0_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* I2C0 interrupt */
|
||||
void I2C1_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* I2C1 interrupt */
|
||||
void SPI0_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* SPI0 interrupt */
|
||||
void SPI1_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* SPI1 interrupt */
|
||||
void SPI2_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* SPI 2 interrupt */
|
||||
void CAN0Msg_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* CAN0 message buffer (0-15) interrupt */
|
||||
void CAN0BusOff_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* CAN0 Bus Off interrupt */
|
||||
void CAN0Error_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* CAN0 Error interrupt */
|
||||
void CAN0Xmit_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* CAN0 Transmit warning interrupt */
|
||||
void CAN0Rcv_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* CAN0 Recieve warning interrupt */
|
||||
void CAN0Wake_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* CAN0 Wake Up interrupt */
|
||||
void I2S0_Tx_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* I2S0 transmit interrupt */
|
||||
void I2S0_Rx_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* I2S0 receive interrupt */
|
||||
void CAN1Msg_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* CAN1Msg interrupt */
|
||||
void CAN1BusOff_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* CAN1BusOff interrupt */
|
||||
void CAN1Error_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* CAN1Error interrupt */
|
||||
void CAN1Xmit_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* CAN1Xmit interrupt */
|
||||
void CAN1Rcv_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* CAN1Rcv interrupt */
|
||||
void CAN1Wake_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* CAN1Wake interrupt */
|
||||
void Reserved59_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* Reserved interrupt 59 */
|
||||
void UART0_LON_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* UART0 LON interrupt */
|
||||
void UART0_RX_TX_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* UART0 receive/transmit interrupt */
|
||||
void UART0Error_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* UART0 error interrupt */
|
||||
void UART1_RX_TX_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* UART1 receive/transmit interrupt */
|
||||
void UART1Error_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* UART1 error interrupt */
|
||||
void UART2_RX_TX_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* UART2 receive/transmit interrupt */
|
||||
void UART2Error_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* UART2 error interrupt */
|
||||
void UART3_RX_TX_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* UART3 receive/transmit interrupt */
|
||||
void UART3Error_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* UART3 error interrupt */
|
||||
void UART4_RX_TX_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* UART4 receive/transmit interrupt */
|
||||
void UART4Error_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* UART4 error interrupt */
|
||||
void Reserved71_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* Reserved interrupt 71 */
|
||||
void Reserved72_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* Reserved interrupt 72 */
|
||||
void ADC0_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* ADC0 interrupt */
|
||||
void ADC1_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* ADC1 interrupt */
|
||||
void CMP0_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* CMP0 interrupt */
|
||||
void CMP1_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* CMP1 interrupt */
|
||||
void CMP2_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* CMP2 interrupt */
|
||||
void FTM0_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* FTM0 fault, all sources interrupt */
|
||||
void FTM1_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* FTM1 fault, all sources interrupt */
|
||||
void FTM2_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* FTM2 fault, all sources interrupt */
|
||||
void CMT_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* CMT interrupt */
|
||||
void RTC_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* RTC alarm interrupt */
|
||||
void RTCSeconds_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* RTC seconds interrupt */
|
||||
void PIT0_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* PIT timer channel 0 interrupt */
|
||||
void PIT1_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* PIT timer channel 1 interrupt */
|
||||
void PIT2_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* PIT timer channel 2 interrupt */
|
||||
void PIT3_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* PIT timer channel 3 interrupt */
|
||||
void PDB0_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* PDB0 interrupt */
|
||||
void USB_ISR(void) __attribute__ ((weak, alias("Default_Handler"))); /* USB OTG interrupt */
|
||||
void USBCharge_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* USB charger detect interrupt */
|
||||
void Reserved91_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* Reserved interrupt 91 */
|
||||
void Reserved92_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* Reserved interrupt 92 */
|
||||
void Reserved93_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* Reserved interrupt 93 */
|
||||
void Reserved94_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* Reserved interrupt 94 */
|
||||
void Reserved95_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* Reserved interrupt 95 */
|
||||
void SDHC_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* SDHC interrupt */
|
||||
void DAC0_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* DAC0 interrupt */
|
||||
void Reserved98_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* Reserved interrupt 98 */
|
||||
void TSI_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* TSI all sources interrupt */
|
||||
void MCG_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* MCG interrupt */
|
||||
void LPTimer_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* Low-power Timer interrupt */
|
||||
void Reserved102_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* Reserved interrupt 102 */
|
||||
void PORTA_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* Port A pin detect interrupt */
|
||||
void PORTB_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* Port B pin detect interrupt */
|
||||
void PORTC_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* Port C pin detect interrupt */
|
||||
void PORTD_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* Port D pin detect interrupt */
|
||||
void PORTE_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* Port E pin detect interrupt */
|
||||
void Reserved108_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* Reserved interrupt 108 */
|
||||
void Reserved109_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* Reserved interrupt 109 */
|
||||
void SWI_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler"))); /* Software interrupt */
|
||||
|
||||
/* The Interrupt Vector Table */
|
||||
void (* const InterruptVector[])(void) __attribute__ ((section(".vectortable"))) = {
|
||||
/* Processor exceptions */
|
||||
(void(*)(void)) &_estack,
|
||||
__thumb_startup,
|
||||
NMI_Handler,
|
||||
HardFault_Handler,
|
||||
MemManage_Handler,
|
||||
BusFault_Handler,
|
||||
UsageFault_Handler,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
SVC_Handler,
|
||||
DebugMon_Handler,
|
||||
0,
|
||||
PendSV_Handler,
|
||||
SysTick_Handler,
|
||||
|
||||
/* Interrupts */
|
||||
DMA0_IRQHandler, /* DMA channel 0 transfer complete interrupt */
|
||||
DMA1_IRQHandler, /* DMA channel 1 transfer complete interrupt */
|
||||
DMA2_IRQHandler, /* DMA channel 2 transfer complete interrupt */
|
||||
DMA3_IRQHandler, /* DMA channel 3 transfer complete interrupt */
|
||||
DMA4_IRQHandler, /* DMA channel 4 transfer complete interrupt */
|
||||
DMA5_IRQHandler, /* DMA channel 5 transfer complete interrupt */
|
||||
DMA6_IRQHandler, /* DMA channel 6 transfer complete interrupt */
|
||||
DMA7_IRQHandler, /* DMA channel 7 transfer complete interrupt */
|
||||
DMA8_IRQHandler, /* DMA channel 8 transfer complete interrupt */
|
||||
DMA9_IRQHandler, /* DMA channel 9 transfer complete interrupt */
|
||||
DMA10_IRQHandler, /* DMA channel 10 transfer complete interrupt */
|
||||
DMA11_IRQHandler, /* DMA channel 11 transfer complete interrupt */
|
||||
DMA12_IRQHandler, /* DMA channel 12 transfer complete interrupt */
|
||||
DMA13_IRQHandler, /* DMA channel 13 transfer complete interrupt */
|
||||
DMA14_IRQHandler, /* DMA channel 14 transfer complete interrupt */
|
||||
DMA15_IRQHandler, /* DMA channel 15 transfer complete interrupt */
|
||||
DMA_Error_IRQHandler, /* DMA error interrupt */
|
||||
MCMNormal_IRQHandler, /* MCM normal interrupt */
|
||||
FlashCmd_IRQHandler, /* Flash memory command complete interrupt */
|
||||
FlashReadErr_IRQHandler, /* Flash read collision interrupt */
|
||||
LVD_LVW_IRQHandler, /* Low Voltage Detect, Low Voltage Warning */
|
||||
LLW_IRQHandler, /* Low Leakage Wakeup */
|
||||
Watchdog_IRQHandler, /* WDOG or EVM interrupt (shared) */
|
||||
Reserved39_IRQHandler, /* Reserved interrupt 39 */
|
||||
I2C0_IRQHandler, /* I2C0 interrupt */
|
||||
I2C1_IRQHandler, /* I2C1 interrupt */
|
||||
SPI0_IRQHandler, /* SPI0 interrupt */
|
||||
SPI1_IRQHandler, /* SPI1 interrupt */
|
||||
SPI2_IRQHandler, /* SPI2 interrupt 44 */
|
||||
CAN0Msg_IRQHandler, /* CAN0 message buffer (0-15) interrupt */
|
||||
CAN0BusOff_IRQHandler, /* CAN0 Bus Off interrupt */
|
||||
CAN0Error_IRQHandler, /* CAN0 Error interrupt */
|
||||
CAN0Xmit_IRQHandler, /* CAN0 Transmit warning interrupt */
|
||||
CAN0Rcv_IRQHandler, /* CAN0 Recieve warning interrupt */
|
||||
CAN0Wake_IRQHandler, /* CAN0 Wake Up interrupt */
|
||||
I2S0_Tx_IRQHandler, /* I2S0 transmit interrupt */
|
||||
I2S0_Rx_IRQHandler, /* I2S0 receive interrupt */
|
||||
CAN1Msg_IRQHandler, /* Reserved interrupt 53 */
|
||||
CAN1BusOff_IRQHandler, /* Reserved interrupt 54 */
|
||||
CAN1Error_IRQHandler, /* Reserved interrupt 55 */
|
||||
CAN1Xmit_IRQHandler, /* Reserved interrupt 56 */
|
||||
CAN1Rcv_IRQHandler, /* Reserved interrupt 57 */
|
||||
CAN1Wake_IRQHandler, /* Reserved interrupt 58 */
|
||||
Reserved59_IRQHandler, /* Reserved interrupt 59 */
|
||||
UART0_LON_IRQHandler, /* UART0 LON interrupt */
|
||||
UART0_RX_TX_IRQHandler, /* UART0 receive/transmit interrupt */
|
||||
UART0Error_IRQHandler, /* UART0 error interrupt */
|
||||
UART1_RX_TX_IRQHandler, /* UART1 receive/transmit interrupt */
|
||||
UART1Error_IRQHandler, /* UART1 error interrupt */
|
||||
UART2_RX_TX_IRQHandler, /* UART2 receive/transmit interrupt */
|
||||
UART2Error_IRQHandler, /* UART2 error interrupt */
|
||||
UART3_RX_TX_IRQHandler, /* UART3 receive/transmit interrupt */
|
||||
UART3Error_IRQHandler, /* UART3 error interrupt */
|
||||
UART4_RX_TX_IRQHandler, /* UART4 receive/transmit */
|
||||
UART4Error_IRQHandler, /* UART4 error interrupt */
|
||||
Reserved71_IRQHandler, /* Reserved interrupt 71 */
|
||||
Reserved72_IRQHandler, /* Reserved interrupt 72 */
|
||||
ADC0_IRQHandler, /* ADC0 interrupt */
|
||||
ADC1_IRQHandler, /* ADC1 interrupt */
|
||||
CMP0_IRQHandler, /* CMP0 interrupt */
|
||||
CMP1_IRQHandler, /* CMP1 interrupt */
|
||||
CMP2_IRQHandler, /* CMP2 interrupt */
|
||||
FTM0_IRQHandler, /* FTM0 fault, all sources interrupt */
|
||||
FTM1_IRQHandler, /* FTM1 fault, all sources interrupt */
|
||||
FTM2_IRQHandler, /* FTM2 fault, all sources interrupt */
|
||||
CMT_IRQHandler, /* CMT interrupt */
|
||||
RTC_IRQHandler, /* RTC alarm interrupt */
|
||||
RTCSeconds_IRQHandler, /* RTC seconds interrupt */
|
||||
PIT0_IRQHandler, /* PIT timer channel 0 interrupt */
|
||||
PIT1_IRQHandler, /* PIT timer channel 1 interrupt */
|
||||
PIT2_IRQHandler, /* PIT timer channel 2 interrupt */
|
||||
PIT3_IRQHandler, /* PIT timer channel 3 interrupt */
|
||||
PDB0_IRQHandler, /* PDB0 interrupt */
|
||||
USB_ISR, /* USB OTG interrupt */
|
||||
USBCharge_IRQHandler, /* USB charger detect interrupt */
|
||||
Reserved91_IRQHandler, /* Reserved interrupt 91 */
|
||||
Reserved92_IRQHandler, /* Reserved interrupt 92 */
|
||||
Reserved93_IRQHandler, /* Reserved interrupt 93 */
|
||||
Reserved94_IRQHandler, /* Reserved interrupt 94 */
|
||||
Reserved95_IRQHandler, /* Reserved interrupt 95 */
|
||||
SDHC_IRQHandler, /* SDHC interrupt */
|
||||
DAC0_IRQHandler, /* DAC0 interrupt */
|
||||
Reserved98_IRQHandler, /* Reserved interrupt 98 */
|
||||
TSI_IRQHandler, /* TSI all sources interrupt */
|
||||
MCG_IRQHandler, /* MCG interrupt */
|
||||
LPTimer_IRQHandler, /* Low-power Timer interrupt */
|
||||
Reserved102_IRQHandler, /* Reserved interrupt 102 */
|
||||
PORTA_IRQHandler, /* Port A pin detect interrupt */
|
||||
PORTB_IRQHandler, /* Port B pin detect interrupt */
|
||||
PORTC_IRQHandler, /* Port C pin detect interrupt */
|
||||
PORTD_IRQHandler, /* Port D pin detect interrupt */
|
||||
PORTE_IRQHandler, /* Port E pin detect interrupt */
|
||||
Reserved108_IRQHandler, /* Reserved interrupt 108 */
|
||||
Reserved109_IRQHandler, /* Reserved interrupt 109 */
|
||||
SWI_IRQHandler /* Software interrupt */
|
||||
};
|
||||
|
||||
/**
|
||||
**===========================================================================
|
||||
** Reset handler
|
||||
**===========================================================================
|
||||
*/
|
||||
void __init_hardware(void)
|
||||
{
|
||||
SCB_VTOR = (uint32)&InterruptVector[0]; /* Set the interrupt vector table position */
|
||||
|
||||
#if defined(MKL25Z128)
|
||||
// Disable the Watchdog because it may reset the core before entering main().
|
||||
SIM_COPC = KINETIS_WDOG_DISABLED_CTRL;
|
||||
|
||||
#elif defined(MKE02Z64)
|
||||
// Disable the Watchdog because it may reset the core before entering main().
|
||||
WDOG_CNT = 0x20C5;
|
||||
WDOG_CNT = 0x28D9;
|
||||
WDOG_TOVAL = 0x28D9;
|
||||
WDOG_CS2 = WDOG_CS2_CLK(0);
|
||||
WDOG_CS1 = WDOG_CS1_UPDATE_MASK; //watchdog setting can be changed later
|
||||
|
||||
#elif defined(MK20DN512) || defined(MK20DX256)
|
||||
// Disable the Watchdog because it may reset the core before entering main().
|
||||
WDOG_UNLOCK = 0xC520; // Write 0xC520 to the unlock register
|
||||
WDOG_UNLOCK = 0xD928; // Followed by 0xD928 to complete the unlock
|
||||
WDOG_STCTRLH &= ~WDOG_STCTRLH_WDOGEN_MASK; // Clear the WDOGEN bit to disable the watchdog
|
||||
#else
|
||||
#error "MCU sub-model not supported!"
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
FILE : kinetis_sysinit.h
|
||||
PURPOSE : system initialization header for Kinetis ARM architecture
|
||||
LANGUAGE: C
|
||||
Copyright © 2012 Freescale semiConductor Inc. All Rights Reserved.
|
||||
*/
|
||||
#ifndef KINETIS_SYSINIT_H
|
||||
#define KINETIS_SYSINIT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "tmc/helpers/API_Header.h"
|
||||
|
||||
/* Word to be written in SIM_COP in order to disable the Watchdog */
|
||||
#define KINETIS_WDOG_DISABLED_CTRL 0x0
|
||||
|
||||
/*
|
||||
Initializes the Kinetis hardware: e.g. disables the Watchdog
|
||||
*/
|
||||
void __init_hardware(void);
|
||||
|
||||
/*
|
||||
** ===================================================================
|
||||
** Method : Default_Handler
|
||||
**
|
||||
** Description :
|
||||
** The default interrupt handler.
|
||||
** ===================================================================
|
||||
*/
|
||||
void Default_Handler(void);
|
||||
|
||||
void SetBASEPRI(uint32 Level) ;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* #ifndef KINETIS_SYSINIT_H */
|
||||
134
Clean_TMC2209/lib/tmc/hal/Landungsbruecke/freescale/nvic-m4.c
Normal file
134
Clean_TMC2209/lib/tmc/hal/Landungsbruecke/freescale/nvic-m4.c
Normal file
@@ -0,0 +1,134 @@
|
||||
#include "hal/derivative.h"
|
||||
|
||||
/***********************************************************************/
|
||||
/*
|
||||
* Initialize the NVIC to enable the specified IRQ.
|
||||
*
|
||||
* NOTE: The function only initializes the NVIC to enable a single IRQ.
|
||||
* Interrupts will also need to be enabled in the ARM core. This can be
|
||||
* done using the EnableInterrupts; macro.
|
||||
*
|
||||
* Parameters:
|
||||
* irq irq number to be enabled (the irq number NOT the vector number)
|
||||
*/
|
||||
|
||||
void enable_irq (int irq)
|
||||
{
|
||||
|
||||
int div;
|
||||
|
||||
/* Make sure that the IRQ is an allowable number. Right now up to 91 is
|
||||
* used.
|
||||
*/
|
||||
// if(irq > 91)
|
||||
//printf("\nERR! Invalid IRQ value passed to enable irq function!\n");
|
||||
|
||||
/* Determine which of the NVICISERs corresponds to the irq */
|
||||
div = irq/32;
|
||||
|
||||
switch (div)
|
||||
{
|
||||
case 0x0:
|
||||
NVICICPR0 |= 1 << (irq%32);
|
||||
NVICISER0 |= 1 << (irq%32);
|
||||
break;
|
||||
case 0x1:
|
||||
NVICICPR1 |= 1 << (irq%32);
|
||||
NVICISER1 |= 1 << (irq%32);
|
||||
break;
|
||||
case 0x2:
|
||||
NVICICPR2 |= 1 << (irq%32);
|
||||
NVICISER2 |= 1 << (irq%32);
|
||||
break;
|
||||
}
|
||||
}
|
||||
/***********************************************************************/
|
||||
/*
|
||||
* Initialize the NVIC to disable the specified IRQ.
|
||||
*
|
||||
* NOTE: The function only initializes the NVIC to disable a single IRQ.
|
||||
* If you want to disable all interrupts, then use the DisableInterrupts
|
||||
* macro instead.
|
||||
*
|
||||
* Parameters:
|
||||
* irq irq number to be disabled (the irq number NOT the vector number)
|
||||
*/
|
||||
|
||||
void disable_irq (int irq)
|
||||
{
|
||||
|
||||
/* Make sure that the IRQ is an allowable number. Right now up to 32 is
|
||||
* used.
|
||||
*
|
||||
* NOTE: If you are using the interrupt definitions from the header
|
||||
* file, you MUST SUBTRACT 16!!!
|
||||
*/
|
||||
if(irq > 128)
|
||||
{
|
||||
/* Set the ICER register accordingly */
|
||||
NVICICER3 = 1 << (irq%32);
|
||||
}
|
||||
else if(irq > 64)
|
||||
{
|
||||
/* Set the ICER register accordingly */
|
||||
NVICICER2 = 1 << (irq%32);
|
||||
}
|
||||
else if(irq > 32)
|
||||
{
|
||||
/* Set the ICER register accordingly */
|
||||
NVICICER1 = 1 << (irq%32);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Set the ICER register accordingly */
|
||||
NVICICER0 = 1 << (irq%32);
|
||||
}
|
||||
}
|
||||
/***********************************************************************/
|
||||
/*
|
||||
* Initialize the NVIC to set specified IRQ priority.
|
||||
*
|
||||
* NOTE: The function only initializes the NVIC to set a single IRQ priority.
|
||||
* Interrupts will also need to be enabled in the ARM core. This can be
|
||||
* done using the EnableInterrupts; macro.
|
||||
*
|
||||
* Parameters:
|
||||
* irq irq number to be enabled (the irq number NOT the vector number)
|
||||
* prio irq priority. 0-3 levels. 0 max priority
|
||||
*/
|
||||
|
||||
void set_irq_priority (int irq, int prio)
|
||||
{
|
||||
/*irq priority pointer*/
|
||||
uint32 *prio_reg;
|
||||
uint8 err = 0;
|
||||
uint8 div = 0;
|
||||
uint8 off = 0;
|
||||
|
||||
/* Make sure that the IRQ is an allowable number. Right now up to 32 is
|
||||
* used.
|
||||
*
|
||||
* NOTE: If you are using the interrupt definitions from the header
|
||||
* file, you MUST SUBTRACT 16!!!
|
||||
*/
|
||||
if(irq > 32)
|
||||
{
|
||||
err = 1;
|
||||
}
|
||||
|
||||
if(prio > 3)
|
||||
{
|
||||
err = 1;
|
||||
}
|
||||
|
||||
if(err != 1)
|
||||
{
|
||||
/* Determine which of the NVICIPx corresponds to the irq */
|
||||
div = irq / 4;
|
||||
off = irq % 4;
|
||||
prio_reg = (uint32 *)((uint32)&NVIC_IP(div));
|
||||
/* Assign priority to IRQ */
|
||||
*prio_reg |= ( (prio&0x3) << (8 - ARM_INTERRUPT_LEVEL_BITS) ) << (off * 8);
|
||||
}
|
||||
}
|
||||
|
||||
26
Clean_TMC2209/lib/tmc/hal/Landungsbruecke/freescale/nvic.h
Normal file
26
Clean_TMC2209/lib/tmc/hal/Landungsbruecke/freescale/nvic.h
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* nvic.h
|
||||
*
|
||||
* Created on: Nov 6, 2012
|
||||
* Author: B34443
|
||||
*/
|
||||
|
||||
#ifndef NVIC_H_
|
||||
#define NVIC_H_
|
||||
|
||||
/* ARM Cortex M0 implementation for interrupt priority shift */
|
||||
#define ARM_INTERRUPT_LEVEL_BITS 2
|
||||
|
||||
#ifndef EnableInterrupts
|
||||
#define EnableInterrupts asm(" CPSIE i")
|
||||
#endif
|
||||
|
||||
#ifndef DisableInterrupts
|
||||
#define DisableInterrupts asm(" CPSID i")
|
||||
#endif
|
||||
|
||||
void enable_irq(int);
|
||||
void disable_irq(int);
|
||||
void set_irq_priority(int, int);
|
||||
|
||||
#endif /* NVIC_H_ */
|
||||
@@ -0,0 +1,78 @@
|
||||
/********************************************************************************
|
||||
* \file startup.s
|
||||
* \brief Startup file for Kinetis L (KL25Z).
|
||||
* This module performs:
|
||||
* - Set the initial SP
|
||||
* - Set the initial PC == __thumb_startup,
|
||||
* - Branches to main in the C library (which eventually
|
||||
* calls main()).
|
||||
******************************************************************************/
|
||||
.syntax unified
|
||||
.cpu cortex-m4
|
||||
.thumb
|
||||
|
||||
.global g_pfnVectors
|
||||
.global Default_Handler
|
||||
|
||||
/* start address for the initialization values of the .data section. defined in linker script */
|
||||
.word ___ROM_AT
|
||||
/* start address for the .data section. defined in linker script */
|
||||
.word _sdata
|
||||
/* end address for the .data section. defined in linker script */
|
||||
.word _edata
|
||||
/* start address for the .bss section. defined in linker script */
|
||||
.word __START_BSS
|
||||
/* end address for the .bss section. defined in linker script */
|
||||
.word __END_BSS
|
||||
|
||||
/**
|
||||
* \brief This is the code that gets called when the processor first
|
||||
* starts execution following a reset event. Only the absolutely
|
||||
* necessary set is performed, after which the application
|
||||
* supplied main() routine is called.
|
||||
* \param None
|
||||
* \retval : None
|
||||
*/
|
||||
.section .text.__thumb_startup
|
||||
.weak __thumb_startup
|
||||
.type __thumb_startup, %function
|
||||
__thumb_startup:
|
||||
/* Call the C hardware init function (which also has to switch off the watchdog) */
|
||||
bl __init_hardware
|
||||
|
||||
/* Copy the data segment initializers from flash to SRAM: */
|
||||
movs r1, #0
|
||||
b LoopCopyDataInit
|
||||
|
||||
CopyDataInit:
|
||||
ldr r3, =___ROM_AT
|
||||
ldr r3, [r3, r1]
|
||||
str r3, [r0, r1]
|
||||
adds r1, r1, #4
|
||||
|
||||
LoopCopyDataInit:
|
||||
ldr r0, =_sdata
|
||||
ldr r3, =_edata
|
||||
adds r2, r0, r1
|
||||
cmp r2, r3
|
||||
bcc CopyDataInit
|
||||
ldr r2, =__START_BSS
|
||||
b LoopFillZerobss
|
||||
|
||||
/* Zero fill the bss segment: */
|
||||
FillZerobss:
|
||||
movs r3, #0
|
||||
str r3, [r2]
|
||||
adds r2, r2, #4
|
||||
|
||||
LoopFillZerobss:
|
||||
ldr r3, = __END_BSS
|
||||
cmp r2, r3
|
||||
bcc FillZerobss
|
||||
/* Call the application's entry point: */
|
||||
bl main
|
||||
blx r0 /*Call the startup code of the application (address returned by the main() function of the boot loader)*/
|
||||
bx lr
|
||||
.size __thumb_startup, .-__thumb_startup
|
||||
|
||||
/****END OF FILE****/
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user