Got AS series of angle sensor working
This commit is contained in:
parent
9d2f2a2598
commit
4dbced4c9d
|
@ -1904,7 +1904,7 @@ drivers:
|
|||
spi_master_arch_dord: MSB first
|
||||
spi_master_arch_ibon: In data stream
|
||||
spi_master_arch_runstdby: false
|
||||
spi_master_baud_rate: 8000000
|
||||
spi_master_baud_rate: 1000000
|
||||
spi_master_character_size: 8 bits
|
||||
spi_master_dummybyte: 511
|
||||
spi_master_rx_enable: true
|
||||
|
|
|
@ -377,7 +377,7 @@
|
|||
// <i> The SPI data transfer rate
|
||||
// <id> spi_master_baud_rate
|
||||
#ifndef CONF_SERCOM_5_SPI_BAUD
|
||||
#define CONF_SERCOM_5_SPI_BAUD 8000000
|
||||
#define CONF_SERCOM_5_SPI_BAUD 1000000
|
||||
#endif
|
||||
|
||||
// </h>
|
||||
|
|
|
@ -176,7 +176,7 @@ static void update_telemetry(void)
|
|||
*M1_Motor__hallState = Motor1.motor_status.currentHallPattern;
|
||||
*M1_Motor_dutyCycle = Motor1.motor_status.duty_cycle;
|
||||
*M1_Motor_speed = (int16_t)Motor1.motor_status.calc_rpm;
|
||||
*M1_Joint_abs_position = Motor1.motor_status.actualDirection;
|
||||
//*M1_Joint_abs_position = Motor1.motor_status.actualDirection;
|
||||
/* Motor 2 */
|
||||
*M2_Status = Motor2.motor_state.currentstate;
|
||||
*M2_Joint_rel_position = Motor2.motor_status.Num_Steps;
|
||||
|
@ -189,7 +189,7 @@ static void update_telemetry(void)
|
|||
*M2_Motor__hallState = Motor2.motor_status.currentHallPattern;
|
||||
*M2_Motor_dutyCycle = Motor2.motor_status.duty_cycle;
|
||||
*M2_Motor_speed = (int16_t)Motor2.motor_status.calc_rpm;
|
||||
*M2_Joint_abs_position = Motor2.motor_status.actualDirection;
|
||||
//*M2_Joint_abs_position = Motor2.motor_status.actualDirection;
|
||||
}
|
||||
|
||||
static void update_setpoints(void)
|
||||
|
@ -266,7 +266,7 @@ static inline void comms_check(void)
|
|||
*M1_Status = 1;
|
||||
*M1_Mode = 2;
|
||||
*M1_Joint_rel_position = -3;
|
||||
*M1_Joint_abs_position = 4;
|
||||
//*M1_Joint_abs_position = 4;
|
||||
*M1_Motor_speed = -5;
|
||||
*M1_Motor_current_bus = 6;
|
||||
*M1_Motor_currentPhA = -7;
|
||||
|
@ -278,7 +278,7 @@ static inline void comms_check(void)
|
|||
*M2_Status = 12;
|
||||
*M2_Mode = 13;
|
||||
*M2_Joint_rel_position = 14;
|
||||
*M2_Joint_abs_position = -15;
|
||||
//*M2_Joint_abs_position = -15;
|
||||
*M2_Motor_speed = 16;
|
||||
*M2_Motor_current_bus = -17;
|
||||
*M2_Motor_currentPhA = 18;
|
||||
|
|
|
@ -176,7 +176,7 @@ static void update_telemetry(void)
|
|||
*M1_Motor__hallState = Motor1.motor_status.currentHallPattern;
|
||||
*M1_Motor_dutyCycle = Motor1.motor_status.duty_cycle;
|
||||
*M1_Motor_speed = (int16_t)Motor1.motor_status.calc_rpm;
|
||||
*M1_Joint_abs_position = Motor1.motor_status.actualDirection;
|
||||
//*M1_Joint_abs_position = Motor1.motor_status.actualDirection;
|
||||
/* Motor 2 */
|
||||
*M2_Status = Motor2.motor_state.currentstate;
|
||||
*M2_Joint_rel_position = Motor2.motor_status.Num_Steps;
|
||||
|
@ -189,7 +189,7 @@ static void update_telemetry(void)
|
|||
*M2_Motor__hallState = Motor2.motor_status.currentHallPattern;
|
||||
*M2_Motor_dutyCycle = Motor2.motor_status.duty_cycle;
|
||||
*M2_Motor_speed = (int16_t)Motor2.motor_status.calc_rpm;
|
||||
*M2_Joint_abs_position = Motor2.motor_status.actualDirection;
|
||||
//*M2_Joint_abs_position = Motor2.motor_status.actualDirection;
|
||||
}
|
||||
|
||||
static void update_setpoints(void)
|
||||
|
@ -266,7 +266,7 @@ static inline void comms_check(void)
|
|||
*M1_Status = 1;
|
||||
*M1_Mode = 2;
|
||||
*M1_Joint_rel_position = -3;
|
||||
*M1_Joint_abs_position = 4;
|
||||
//*M1_Joint_abs_position = 4;
|
||||
*M1_Motor_speed = -5;
|
||||
*M1_Motor_current_bus = 6;
|
||||
*M1_Motor_currentPhA = -7;
|
||||
|
@ -278,7 +278,7 @@ static inline void comms_check(void)
|
|||
*M2_Status = 12;
|
||||
*M2_Mode = 13;
|
||||
*M2_Joint_rel_position = 14;
|
||||
*M2_Joint_abs_position = -15;
|
||||
//*M2_Joint_abs_position = -15;
|
||||
*M2_Motor_speed = 16;
|
||||
*M2_Motor_current_bus = -17;
|
||||
*M2_Motor_currentPhA = 18;
|
||||
|
|
|
@ -221,7 +221,7 @@
|
|||
<AcmeProjectActionInfo Action="File" Source="config/hpl_oscctrl_config.h" IsConfig="true" Hash="Uje5LXAS+nQpGryt9t0fYA" />
|
||||
<AcmeProjectActionInfo Action="File" Source="config/hpl_port_config.h" IsConfig="true" Hash="rMTNR+5FXtu+wfT1NbfRRA" />
|
||||
<AcmeProjectActionInfo Action="File" Source="config/hpl_qspi_config.h" IsConfig="true" Hash="CwZ360eeEYs7T9SYFSvDug" />
|
||||
<AcmeProjectActionInfo Action="File" Source="config/hpl_sercom_config.h" IsConfig="true" Hash="VqQgNrcYjhppN3Wx5EeLwg" />
|
||||
<AcmeProjectActionInfo Action="File" Source="config/hpl_sercom_config.h" IsConfig="true" Hash="C7HLgXBWMtjVUMM9/rRk/w" />
|
||||
<AcmeProjectActionInfo Action="File" Source="config/hpl_tc_config.h" IsConfig="true" Hash="T93Kr6C+WDuufZob89oPeg" />
|
||||
<AcmeProjectActionInfo Action="File" Source="config/hpl_tcc_config.h" IsConfig="true" Hash="2LU7afZ/3Yx7FE2KzF9dSQ" />
|
||||
<AcmeProjectActionInfo Action="File" Source="config/peripheral_clk_config.h" IsConfig="true" Hash="rqTY1slZEq9V5moV+8Q+hw" />
|
||||
|
@ -419,7 +419,7 @@
|
|||
<armgcc.compiler.optimization.PrepareFunctionsForGarbageCollection>True</armgcc.compiler.optimization.PrepareFunctionsForGarbageCollection>
|
||||
<armgcc.compiler.optimization.DebugLevel>Maximum (-g3)</armgcc.compiler.optimization.DebugLevel>
|
||||
<armgcc.compiler.warnings.AllWarnings>True</armgcc.compiler.warnings.AllWarnings>
|
||||
<armgcc.compiler.miscellaneous.OtherFlags>-std=gnu11 -mfloat-abi=hard -mfpu=fpv4-sp-d16</armgcc.compiler.miscellaneous.OtherFlags>
|
||||
<armgcc.compiler.miscellaneous.OtherFlags>-std=gnu99 -mfloat-abi=hard -mfpu=fpv4-sp-d16</armgcc.compiler.miscellaneous.OtherFlags>
|
||||
<armgcc.linker.general.UseNewlibNano>True</armgcc.linker.general.UseNewlibNano>
|
||||
<armgcc.linker.libraries.Libraries>
|
||||
<ListValues>
|
||||
|
|
|
@ -29,20 +29,19 @@ void angle_sensor_init()
|
|||
gpio_set_pin_level(ANGLESENSOR.SS_pin, true);
|
||||
}
|
||||
|
||||
//void read(ASCommand command)
|
||||
//{
|
||||
//_read(command); // Send command to device(s)
|
||||
//_read(AS_CMD_NOP); // Read-out device(s)
|
||||
//}
|
||||
int16_t* ang_sense_read(ASCommand command)
|
||||
{
|
||||
_read(command); // Send command to device(s)
|
||||
return _read(command); // Read-out device(s)
|
||||
}
|
||||
|
||||
int16_t* read_angle()
|
||||
{
|
||||
_read(AS_CMD_ANGLE); // Send command to device(s)
|
||||
_read(AS_CMD_ANGLE); // Read-out device(s)
|
||||
return &ANGLESENSOR._readBuffer;
|
||||
return _read(AS_CMD_ANGLE); // Read-out device(s)
|
||||
}
|
||||
|
||||
void _read(ASCommand command)
|
||||
int16_t* _read(ASCommand command)
|
||||
{
|
||||
|
||||
if(ANGLESENSOR.n_dev == 1)
|
||||
|
@ -50,7 +49,7 @@ void _read(ASCommand command)
|
|||
// Give command to start reading the angle
|
||||
gpio_set_pin_level(ANGLESENSOR.SS_pin, false);
|
||||
uint16_t temp = _spi_transfer16(&ANGLESENSOR, command);
|
||||
ANGLESENSOR._readBuffer[0] = (temp & AS_MASK);
|
||||
ANGLESENSOR._readBuffer[0] = (temp);
|
||||
gpio_set_pin_level(ANGLESENSOR.SS_pin, true);
|
||||
//delay_us(1); // Wait at least 350ns after chip select
|
||||
} else {
|
||||
|
@ -60,11 +59,12 @@ void _read(ASCommand command)
|
|||
for(int i = 0; i < ANGLESENSOR.n_dev; ++i)
|
||||
{
|
||||
uint16_t temp = _spi_transfer16(&ANGLESENSOR, command);
|
||||
ANGLESENSOR._readBuffer[i] = (temp & AS_MASK);
|
||||
ANGLESENSOR._readBuffer[i] = (temp);
|
||||
}
|
||||
gpio_set_pin_level(ANGLESENSOR.SS_pin, true);
|
||||
//delay_us(1); // Wait at least 350ns after chip select
|
||||
}
|
||||
return &ANGLESENSOR._readBuffer;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -57,8 +57,9 @@ typedef enum {
|
|||
AS_CMD_NOP = 0x0000,
|
||||
AS_CMD_ERROR = 0x0001 | AS_FLAG_READ, // Reads error register of sensor and clear error flags
|
||||
AS_CMD_DIAGNOSTICS = 0x3FFD | AS_FLAG_READ, // Reads automatic gain control and diagnostics info
|
||||
AS_CMD_MAGNITUDE = 0x3FFE | AS_FLAG_READ,
|
||||
AS_CMD_MAGNITUDE = (uint16_t)(((0x2A & AS_ADDRESS_MASK) | AS_FLAG_READ) << 8),
|
||||
AS_CMD_ANGLE = (uint16_t)(((0x20 & AS_ADDRESS_MASK) | AS_FLAG_READ) << 8),
|
||||
AS_CMD_TEMP = ((0x28 & AS_ADDRESS_MASK) | AS_FLAG_READ) << 8,
|
||||
} ASCommand;
|
||||
|
||||
// Masks for bits in the result of the AS_CMD_DIAGNOSTICS command
|
||||
|
@ -88,7 +89,7 @@ static struct SPI_ANGLE_SENSOR ANGLESENSOR = {
|
|||
};
|
||||
|
||||
void angle_sensor_init();
|
||||
void read(ASCommand command);
|
||||
int16_t* ang_sense_read(ASCommand command);
|
||||
// Performs a single angle measurement on all sensors
|
||||
// @return Array of raw angle data. To get the 14-bit value representing
|
||||
// the angle, apply the mask() to the result.
|
||||
|
@ -103,7 +104,7 @@ static bool parity_check(int16_t sensor_result);
|
|||
int16_t degrees(int16_t sensor_result);
|
||||
|
||||
// Intended to be used Internally
|
||||
void _read(ASCommand command);
|
||||
int16_t* _read(ASCommand command);
|
||||
uint16_t _spi_transfer16(struct spi_m_sync_descriptor *spi, uint16_t value);
|
||||
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ void motor_StateMachine(BLDCMotor_t* const motor)
|
|||
case MOTOR_IDLE:
|
||||
//hri_tcc_write_PATTBUF_reg(motor->motor_param->pwm_desc->device.hw, DISABLE_PATTERN);
|
||||
motor->motor_state.previousstate = motor->motor_state.currentstate;
|
||||
motor->motor_state.currentstate = MOTOR_IDLE;
|
||||
motor->motor_state.currentstate = MOTOR_PVI_CTRL_STATE;
|
||||
break;
|
||||
case MOTOR_OPEN_LOOP_STATE:
|
||||
BLDC_runOpenLoop(motor, *M1_Desired_dc);
|
||||
|
@ -227,12 +227,18 @@ void exec_commutation(BLDCMotor_t* const motor)
|
|||
volatile uint16_t temp_M1 = COMMUTATION_PATTERN[currentHall +
|
||||
motor->motor_setpoints.directionOffset];
|
||||
|
||||
hri_tcc_write_PATTBUF_reg(motor->motor_param->pwm_desc->device.hw, temp_M1);
|
||||
//TCC0->PATTBUF.reg = temp_M1;
|
||||
Tcc * tmp = (Tcc *)motor->motor_param->pwm_desc->device.hw;
|
||||
tmp->PATTBUF.reg = (uint16_t)temp_M1;
|
||||
//motor->motor_param->pwm_desc->device.hw->PATTBUF.reg = temp_M1;
|
||||
//hri_tcc_write_PATTBUF_reg(motor->motor_param->pwm_desc->device.hw, temp_M1);
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Set Calculated Duty Cycle
|
||||
// ----------------------------------------------------------------------
|
||||
hri_tcc_write_CCBUF_CCBUF_bf(motor->motor_param->pwm_desc->device.hw, 0, motor->motor_status.duty_cycle);
|
||||
//hri_tcc_write_CCBUF_CCBUF_bf(motor->motor_param->pwm_desc->device.hw, 0, motor->motor_status.duty_cycle);
|
||||
tmp->CCBUF[0].reg = (uint32_t)motor->motor_status.duty_cycle;
|
||||
|
||||
|
||||
volatile uint8_t cur_comm_step = MOTOR_COMMUTATION_STEPS[currentHall];
|
||||
motor->motor_status.cur_comm_step = cur_comm_step;
|
||||
|
|
|
@ -54,7 +54,7 @@ static struct timer_task Onems_task;
|
|||
|
||||
void One_ms_timer_init(void)
|
||||
{
|
||||
Onems_task.interval = 10;
|
||||
Onems_task.interval = 1;
|
||||
Onems_task.cb = One_ms_cycle_callback;
|
||||
Onems_task.mode = TIMER_TASK_REPEAT;
|
||||
timer_add_task(&TIMER_0, &Onems_task);
|
||||
|
@ -191,11 +191,20 @@ int main(void)
|
|||
_dma_enable_transaction(DMAC_CHANNEL_CONF_SERCOM_1_TRANSMIT, false);
|
||||
volatile int x = 1;
|
||||
|
||||
|
||||
//
|
||||
int16_t* angles;
|
||||
angles = read_angle();
|
||||
*M1_Joint_abs_position = degrees(angles[0]);
|
||||
*M2_Joint_abs_position = degrees(angles[1]);
|
||||
//int16_t* field;
|
||||
//int16_t* temp;
|
||||
//angles = read_angle();
|
||||
//*M1_Joint_abs_position = degrees(angles[0]);
|
||||
//*M2_Joint_abs_position = degrees(angles[1]);
|
||||
//field = ang_sense_read(AS_CMD_MAGNITUDE);
|
||||
//*Spare1_tx = (field[0] & AS_MASK);
|
||||
//*Spare2_tx = (field[1] & AS_MASK);
|
||||
//temp = ang_sense_read(AS_CMD_TEMP);
|
||||
//*Spare3_tx = (int16_t)(((float)(temp[0] & AS_MASK) / 8.0) - 273.15);
|
||||
//*Spare4_tx = (int16_t)(((float)(temp[1] & AS_MASK) / 8.0) - 273.15);
|
||||
|
||||
volatile int y = 0;
|
||||
|
||||
//spi_m_dma_transfer(&SPI_1_MSIF, (uint8_t*)Slave_1.tx_buffer, (uint8_t*)Slave_1.rx_buffer, MASTER_BUFFER_SIZE);
|
||||
|
|
|
@ -102,7 +102,7 @@ static void update_telemetry(void)
|
|||
*M3_Motor__hallState = Motor1.motor_status.currentHallPattern;
|
||||
*M3_Motor_dutyCycle = Motor1.motor_status.duty_cycle;
|
||||
*M3_Motor_speed = (int16_t)Motor1.motor_status.calc_rpm;
|
||||
*M3_Joint_abs_position = Motor1.motor_status.actualDirection;
|
||||
//*M3_Joint_abs_position = ;
|
||||
/* Motor 2 */
|
||||
*M4_Status = Motor2.motor_state.currentstate;
|
||||
*M4_Joint_rel_position = Motor2.motor_status.Num_Steps;
|
||||
|
@ -115,7 +115,7 @@ static void update_telemetry(void)
|
|||
*M4_Motor__hallState = Motor2.motor_status.currentHallPattern;
|
||||
*M4_Motor_dutyCycle = Motor2.motor_status.duty_cycle;
|
||||
*M4_Motor_speed = (int16_t)Motor2.motor_status.calc_rpm;
|
||||
*M4_Joint_abs_position = Motor2.motor_status.actualDirection;
|
||||
//*M4_Joint_abs_position = Motor2.motor_status.actualDirection;
|
||||
}
|
||||
|
||||
static void update_setpoints(void)
|
||||
|
|
|
@ -29,20 +29,19 @@ void angle_sensor_init()
|
|||
gpio_set_pin_level(ANGLESENSOR.SS_pin, true);
|
||||
}
|
||||
|
||||
void read(ASCommand command)
|
||||
int16_t* read(ASCommand command)
|
||||
{
|
||||
_read(command); // Send command to device(s)
|
||||
_read(AS_CMD_NOP); // Read-out device(s)
|
||||
return _read(AS_CMD_NOP); // Read-out device(s)
|
||||
}
|
||||
|
||||
int16_t* read_angle()
|
||||
{
|
||||
_read(AS_CMD_ANGLE); // Send command to device(s)
|
||||
_read(AS_CMD_ANGLE); // Read-out device(s)
|
||||
return &ANGLESENSOR._readBuffer;
|
||||
return _read(AS_CMD_ANGLE); // Read-out device(s)
|
||||
}
|
||||
|
||||
void _read(ASCommand command)
|
||||
int16_t* _read(ASCommand command)
|
||||
{
|
||||
|
||||
if(ANGLESENSOR.n_dev == 1)
|
||||
|
@ -52,19 +51,20 @@ void _read(ASCommand command)
|
|||
uint16_t temp = _spi_transfer16(&ANGLESENSOR, command);
|
||||
ANGLESENSOR._readBuffer[0] = (temp & ~0xC000);
|
||||
gpio_set_pin_level(ANGLESENSOR.SS_pin, true);
|
||||
//delay_us(1); // Wait at least 350ns after chip select
|
||||
delay_us(1); // Wait at least 350ns after chip select
|
||||
} else {
|
||||
// Enable the sensor on the chain
|
||||
gpio_set_pin_level(ANGLESENSOR.SS_pin, false);
|
||||
//delay_us(1); // Wait at least 350ns after chip select
|
||||
delay_us(1); // Wait at least 350ns after chip select
|
||||
for(int i = 0; i < ANGLESENSOR.n_dev; ++i)
|
||||
{
|
||||
uint16_t temp = _spi_transfer16(&ANGLESENSOR, command);
|
||||
ANGLESENSOR._readBuffer[i] = (temp & ~0xC000);
|
||||
}
|
||||
gpio_set_pin_level(ANGLESENSOR.SS_pin, true);
|
||||
//delay_us(1); // Wait at least 350ns after chip select
|
||||
delay_us(1); // Wait at least 350ns after chip select
|
||||
}
|
||||
return &ANGLESENSOR._readBuffer;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -83,12 +83,12 @@ static struct SPI_ANGLE_SENSOR ANGLESENSOR = {
|
|||
.SPI_descr = &SPI_3,
|
||||
.flags = 0,
|
||||
.SS_pin = SPI3_SS,
|
||||
.n_dev = 1,
|
||||
.n_dev = 2,
|
||||
._readBuffer = {0} // Must Equal n_dev
|
||||
};
|
||||
|
||||
void angle_sensor_init();
|
||||
void read(ASCommand command);
|
||||
int16_t* read(ASCommand command);
|
||||
// Performs a single angle measurement on all sensors
|
||||
// @return Array of raw angle data. To get the 14-bit value representing
|
||||
// the angle, apply the mask() to the result.
|
||||
|
@ -103,7 +103,7 @@ static bool parity_check(int16_t sensor_result);
|
|||
int16_t degrees(int16_t sensor_result);
|
||||
|
||||
// Intended to be used Internally
|
||||
void _read(ASCommand command);
|
||||
int16_t* _read(ASCommand command);
|
||||
uint16_t _spi_transfer16(struct spi_m_sync_descriptor *spi, uint16_t value);
|
||||
|
||||
|
||||
|
|
|
@ -227,13 +227,18 @@ void exec_commutation(BLDCMotor_t* const motor)
|
|||
volatile uint16_t temp_M1 = COMMUTATION_PATTERN[currentHall +
|
||||
motor->motor_setpoints.directionOffset];
|
||||
|
||||
hri_tcc_write_PATTBUF_reg(motor->motor_param->pwm_desc->device.hw, temp_M1);
|
||||
//TCC0->PATTBUF.reg = temp_M1;
|
||||
Tcc * tmp = (Tcc *)motor->motor_param->pwm_desc->device.hw;
|
||||
tmp->PATTBUF.reg = (uint16_t)temp_M1;
|
||||
//motor->motor_param->pwm_desc->device.hw->PATTBUF.reg = temp_M1;
|
||||
//hri_tcc_write_PATTBUF_reg(motor->motor_param->pwm_desc->device.hw, temp_M1);
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Set Calculated Duty Cycle
|
||||
// ----------------------------------------------------------------------
|
||||
hri_tcc_write_CCBUF_CCBUF_bf(motor->motor_param->pwm_desc->device.hw, 0, motor->motor_status.duty_cycle);
|
||||
|
||||
//hri_tcc_write_CCBUF_CCBUF_bf(motor->motor_param->pwm_desc->device.hw, 0, motor->motor_status.duty_cycle);
|
||||
tmp->CCBUF[0].reg = (uint32_t)motor->motor_status.duty_cycle;
|
||||
|
||||
volatile uint8_t cur_comm_step = MOTOR_COMMUTATION_STEPS[currentHall];
|
||||
motor->motor_status.cur_comm_step = cur_comm_step;
|
||||
volatile int8_t step_change = (cur_comm_step - motor->motor_status.prev_comm_step);
|
||||
|
|
|
@ -70,7 +70,7 @@ static struct timer_task Onems_task;
|
|||
|
||||
void One_ms_timer_init(void)
|
||||
{
|
||||
Onems_task.interval = 10;
|
||||
Onems_task.interval = 1;
|
||||
Onems_task.cb = One_ms_cycle_callback;
|
||||
Onems_task.mode = TIMER_TASK_REPEAT;
|
||||
timer_add_task(&TIMER_0, &Onems_task);
|
||||
|
@ -86,6 +86,10 @@ void SERCOM1_1_Handler()
|
|||
//SERCOM1->SPI.INTFLAG.bit.TXC = 0x01;
|
||||
//SPI_tx_buffer[0] += 1;
|
||||
//tx_buffer[31] += 1;
|
||||
|
||||
//DMAC->Channel[0].CHCTRLA.reg |= DMAC_CHCTRLA_ENABLE;
|
||||
//DMAC->Channel[1].CHCTRLA.reg |= DMAC_CHCTRLA_ENABLE;
|
||||
|
||||
_dma_enable_transaction(CONF_SERCOM_1_RECEIVE_DMA_CHANNEL, false);
|
||||
_dma_enable_transaction(CONF_SERCOM_1_TRANSMIT_DMA_CHANNEL, false);
|
||||
|
||||
|
@ -103,6 +107,7 @@ void SERCOM1_3_Handler()
|
|||
//SERCOM1->SPI.INTFLAG.bit.TXC = 0x01;
|
||||
//tx_buffer[0] += 1;
|
||||
//tx_buffer[31] += 1;
|
||||
|
||||
//_dma_enable_transaction(CONF_SERCOM_1_RECEIVE_DMA_CHANNEL, false);
|
||||
//_dma_enable_transaction(CONF_SERCOM_1_TRANSMIT_DMA_CHANNEL, false);
|
||||
|
||||
|
@ -129,13 +134,15 @@ void enable_NVIC_IRQ(void)
|
|||
NVIC_SetPriority(DMAC_0_IRQn, 2);
|
||||
NVIC_SetPriority(ADC1_0_IRQn, 3);
|
||||
NVIC_EnableIRQ(TCC0_0_IRQn);
|
||||
NVIC_SetPriority(TCC0_0_IRQn, 1);
|
||||
NVIC_EnableIRQ(TCC1_0_IRQn);
|
||||
NVIC_SetPriority(TCC1_0_IRQn, 1);
|
||||
//NVIC_EnableIRQ(SERCOM5_0_IRQn);
|
||||
|
||||
//NVIC_EnableIRQ(SERCOM1_1_IRQn);
|
||||
//NVIC_SetPriority(SERCOM1_1_IRQn, 1);
|
||||
//NVIC_EnableIRQ(SERCOM1_3_IRQn);
|
||||
//NVIC_SetPriority(SERCOM1_3_IRQn, 1);
|
||||
NVIC_EnableIRQ(SERCOM1_1_IRQn);
|
||||
NVIC_SetPriority(SERCOM1_1_IRQn, 0);
|
||||
NVIC_EnableIRQ(SERCOM1_3_IRQn);
|
||||
NVIC_SetPriority(SERCOM1_3_IRQn, 0);
|
||||
//NVIC_EnableIRQ(SERCOM1_3_IRQn);
|
||||
//NVIC_EnableIRQ(EIC_5_IRQn);
|
||||
}
|
||||
|
@ -171,7 +178,7 @@ void APPLICATION_StateMachine(void)
|
|||
//applicationStatus.currentstate ;
|
||||
//comms_check();
|
||||
motor_StateMachine(&Motor1);
|
||||
motor_StateMachine(&Motor2);
|
||||
//motor_StateMachine(&Motor2);
|
||||
break;
|
||||
case APP_FAULT:
|
||||
//DisableGateDrivers(&Motor1);
|
||||
|
@ -239,10 +246,10 @@ int main(void)
|
|||
|
||||
/* Replace with your application code */
|
||||
while (1) {
|
||||
//if (Motor1.timerflags.adc_readings_ready_tic) {process_currents();}
|
||||
if (Motor1.timerflags.adc_readings_ready_tic) {process_currents();}
|
||||
if (Motor1.timerflags.current_loop_tic) {
|
||||
//APPLICATION_StateMachine();
|
||||
//exec_commutation(&Motor1);
|
||||
APPLICATION_StateMachine();
|
||||
exec_commutation(&Motor1);
|
||||
//exec_commutation(&Motor2);
|
||||
}
|
||||
|
||||
|
@ -263,7 +270,7 @@ int main(void)
|
|||
int16_t* angles;
|
||||
angles = read_angle();
|
||||
*M3_Joint_abs_position = degrees(angles[0]);
|
||||
//*M4_Joint_abs_position = angles[1];
|
||||
*M4_Joint_abs_position = degrees(angles[1]);
|
||||
volatile int y = 0;
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue