Commit b545b8a2 authored by Sergi Hernandez's avatar Sergi Hernandez
Browse files

Updated the dynamixel slave interface to version 2.

parent 759998bc
This diff is collapsed.
......@@ -8,6 +8,7 @@ extern "C" {
// servo models
#define SERVO_AX12A 0x000C
#define SERVO_AX12W 0x012C
#define SERVO_AX12N 0xF00C
#define SERVO_AX18A 0x0012
#define SERVO_MX28 0x001D
#define SERVO_RX24F 0x0018
......@@ -45,14 +46,14 @@ typedef enum{
P_HIGH_CALIBRATION_H = 23,
P_TORQUE_ENABLE = 24,
P_LED = 25,
P_CW_COMPLIANCE_MARGIN = 26,
P_CCW_COMPLIANCE_MARGIN = 27,
P_CW_COMPLIANCE_SLOPE = 28,
P_CCW_COMPLIANCE_SLOPE = 29,
P_D_GAIN = 26,
P_I_GAIN = 27,
P_P_GAIN = 28,
P_RESERVED = 29,
P_CW_COMPLIANCE_MARGIN = 26,// servos with compliance
P_CCW_COMPLIANCE_MARGIN = 27,// servos with compliance
P_CW_COMPLIANCE_SLOPE = 28,// servos with compliance
P_CCW_COMPLIANCE_SLOPE = 29,// servos with compliance
P_D_GAIN = 26,// servos with PID
P_I_GAIN = 27,// servos with PID
P_P_GAIN = 28,// servos with PID
P_RESERVED = 29,// servos with PID
P_GOAL_POSITION_L = 30,
P_GOAL_POSITION_H = 31,
P_MOVING_SPEED_L = 32,
......@@ -71,8 +72,8 @@ typedef enum{
P_PAUSE_TIME = 45,
P_MOVING = 46,
P_LOCK = 47,
P_PUNCH_L = 48,
P_PUNCH_H = 49,
P_PUNCH_L = 48,// servos with compliance
P_PUNCH_H = 49,// servos with compliance
P_RESERVED4 = 50,
P_RESERVED5 = 51,
P_POT_L = 52,
......
......@@ -83,7 +83,7 @@ extern "C" {
#define PAGE_FULL ((uint8_t)0x80)
/* Variables' number */
#define NB_OF_VAR ((uint8_t)0x03)
#define NB_OF_VAR ((uint8_t)0x33)
/* Exported types ------------------------------------------------------------*/
/* Exported macro ------------------------------------------------------------*/
......
......@@ -14,21 +14,21 @@ extern "C" {
#define RAM_BAD_BIT -3
#define RAM_BAD_ACCESS -4
#define RAM_SIZE 256
#define RAM_SIZE 512
extern uint8_t ram_data[RAM_SIZE];
void ram_init(void);
inline void ram_read_byte(uint8_t address, uint8_t *data);
inline void ram_read_word(uint8_t address, uint16_t *data);
uint8_t ram_read_table(uint8_t address, uint8_t length,uint8_t *data);
uint8_t ram_set_bit(uint8_t address, uint8_t bit);
uint8_t ram_clear_bit(uint8_t address, uint8_t bit);
uint8_t ram_write_byte(uint8_t address, uint8_t data);
uint8_t ram_write_word(uint8_t address, uint16_t data);
uint8_t ram_write_table(uint8_t address, uint8_t length,uint8_t *data);
inline uint8_t ram_in_range(uint8_t reg,uint8_t address,uint8_t length);
uint8_t ram_in_window(uint8_t start_reg,uint8_t reg_length,uint8_t start_address,uint8_t address_length);
inline void ram_read_byte(uint16_t address, uint8_t *data);
inline void ram_read_word(uint16_t address, uint16_t *data);
uint8_t ram_read_table(uint16_t address, uint16_t length,uint8_t *data);
uint8_t ram_set_bit(uint16_t address, uint8_t bit);
uint8_t ram_clear_bit(uint16_t address, uint8_t bit);
uint8_t ram_write_byte(uint16_t address, uint8_t data);
uint8_t ram_write_word(uint16_t address, uint16_t data);
uint8_t ram_write_table(uint16_t address, uint16_t length,uint8_t *data);
inline uint8_t ram_in_range(uint16_t reg,uint16_t address,uint16_t length);
uint8_t ram_in_window(uint16_t start_reg,uint16_t reg_length,uint16_t start_address,uint16_t address_length);
#ifdef __cplusplus
}
......
......@@ -47,7 +47,7 @@ unsigned char bioloid_on_read(unsigned short int address,unsigned short int leng
unsigned char bioloid_on_write(unsigned short int address,unsigned short int length,unsigned char *data)
{
unsigned char i,j;
unsigned short int i,j;
/* dynamixel slave internal operation registers */
if(ram_in_range(BIOLOID_ID,address,length))
......@@ -96,6 +96,11 @@ unsigned char bioloid_on_write(unsigned short int address,unsigned short int len
return 0x00;
}
void bioloid_on_ping(void)
{
gpio_toggle_led(RXD_LED);
}
/* interrupt service routines */
void DYN_SLAVE_TIMER_IRQHandler(void)
{
......@@ -139,9 +144,10 @@ void bioloid_dyn_slave_init(void)
priorities.dma_tx_subpriority=0;
usart3_init(&bioloid_dyn_slave_comm,&bioloid_comm_init,&priorities);
dyn_slave_init(&bioloid_dyn_slave,&bioloid_dyn_slave_comm,ram_data[BIOLOID_ID],DYN_VER1);
dyn_slave_init(&bioloid_dyn_slave,&bioloid_dyn_slave_comm,ram_data[BIOLOID_ID],DYN_VER2);
bioloid_dyn_slave.on_read=bioloid_on_read;
bioloid_dyn_slave.on_write=bioloid_on_write;
bioloid_dyn_slave.on_ping=bioloid_on_ping;
dyn_slave_set_return_delay(&bioloid_dyn_slave,ram_data[BIOLOID_RETURN_DELAY_TIME]);
dyn_slave_set_return_level(&bioloid_dyn_slave,ram_data[BIOLOID_RETURN_LEVEL]);
......
......@@ -60,6 +60,38 @@
#define DEFAULT_GYRO_FB_ADC_CH (uint16_t)ADC_CH1
#define DEFAULT_GYRO_LR_ADC_CH (uint16_t)ADC_CH2
#define DEFAULT_RETURN_LEVEL 0x0002
#define DEFAULT_SERVO0_OFFSET 0x0000
#define DEFAULT_SERVO1_OFFSET 0x0000
#define DEFAULT_SERVO2_OFFSET 0x0000
#define DEFAULT_SERVO3_OFFSET 0x0000
#define DEFAULT_SERVO4_OFFSET 0x0000
#define DEFAULT_SERVO5_OFFSET 0x0000
#define DEFAULT_SERVO6_OFFSET 0x0000
#define DEFAULT_SERVO7_OFFSET 0x0000
#define DEFAULT_SERVO8_OFFSET 0x0000
#define DEFAULT_SERVO9_OFFSET 0x0000
#define DEFAULT_SERVO10_OFFSET 0x0000
#define DEFAULT_SERVO11_OFFSET 0x0000
#define DEFAULT_SERVO12_OFFSET 0x0000
#define DEFAULT_SERVO13_OFFSET 0x0000
#define DEFAULT_SERVO14_OFFSET 0x0000
#define DEFAULT_SERVO15_OFFSET 0x0000
#define DEFAULT_SERVO16_OFFSET 0x0000
#define DEFAULT_SERVO17_OFFSET 0x0000
#define DEFAULT_SERVO18_OFFSET 0x0000
#define DEFAULT_SERVO19_OFFSET 0x0000
#define DEFAULT_SERVO20_OFFSET 0x0000
#define DEFAULT_SERVO21_OFFSET 0x0000
#define DEFAULT_SERVO22_OFFSET 0x0000
#define DEFAULT_SERVO23_OFFSET 0x0000
#define DEFAULT_SERVO24_OFFSET 0x0000
#define DEFAULT_SERVO25_OFFSET 0x0000
#define DEFAULT_SERVO26_OFFSET 0x0000
#define DEFAULT_SERVO27_OFFSET 0x0000
#define DEFAULT_SERVO28_OFFSET 0x0000
#define DEFAULT_SERVO29_OFFSET 0x0000
#define DEFAULT_SERVO30_OFFSET 0x0000
#define DEFAULT_SERVO31_OFFSET 0x0000
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
......@@ -67,46 +99,58 @@
uint16_t DataVar = 0;
/* Virtual address defined by the user: 0xFFFF value is prohibited */
uint16_t eeprom_data[] __attribute__ ((section (".eeprom")))={VALID_PAGE,
0xFFFF,
DEFAULT_DEVICE_MODEL&0xFF,// model number LSB
DEVICE_MODEL_OFFSET,
DEFAULT_DEVICE_MODEL>>8,// model number MSB
DEVICE_MODEL_OFFSET+1,
DEFAULT_FIRMWARE_VERSION,// firmware version
FIRMWARE_VERSION_OFFSET,
DEFAULT_DEVICE_ID,// default device id
DEVICE_ID_OFFSET,
DEFAULT_BAUDRATE,// default baudrate
BAUDRATE_OFFSET,
DEFAULT_RETURN_DELAY,// return delay time
RETURN_DELAY_OFFSET,
DEFAULT_MM_PERIOD&0xFF,
MM_PERIOD_OFFSET,
DEFAULT_MM_PERIOD>>8,
MM_PERIOD_OFFSET+1,
DEFAULT_BAL_KNEE_GAIN&0xFF,
MM_BAL_KNEE_GAIN_OFFSET,
DEFAULT_BAL_KNEE_GAIN>>8,
MM_BAL_KNEE_GAIN_OFFSET+1,
DEFAULT_BAL_ANKLE_ROLL_GAIN&0xFF,
MM_BAL_ANKLE_ROLL_GAIN_OFFSET,
DEFAULT_BAL_ANKLE_ROLL_GAIN>>8,
MM_BAL_ANKLE_ROLL_GAIN_OFFSET+1,
DEFAULT_BAL_ANKLE_PITCH_GAIN&0xFF,
MM_BAL_ANKLE_PITCH_GAIN_OFFSET,
DEFAULT_BAL_ANKLE_PITCH_GAIN>>8,
MM_BAL_ANKLE_PITCH_GAIN_OFFSET+1,
DEFAULT_BAL_HIP_ROLL_GAIN&0xFF,
MM_BAL_HIP_ROLL_GAIN_OFFSET,
DEFAULT_BAL_HIP_ROLL_GAIN>>8,
MM_BAL_HIP_ROLL_GAIN_OFFSET+1,
DEFAULT_RETURN_LEVEL,
RETURN_LEVEL_OFFSET,
DEFAULT_GYRO_FB_ADC_CH,
GYRO_FB_ADC_CH_OFFSET,
DEFAULT_GYRO_LR_ADC_CH,
GYRO_LR_ADC_CH_OFFSET};// return level
uint16_t eeprom_data[] __attribute__ ((section (".eeprom")))={VALID_PAGE, 0xFFFF,
DEFAULT_DEVICE_MODEL&0xFF, DEVICE_MODEL_OFFSET,// model number LSB
DEFAULT_DEVICE_MODEL>>8, DEVICE_MODEL_OFFSET+1,// model number MSB
DEFAULT_FIRMWARE_VERSION, FIRMWARE_VERSION_OFFSET,// firmware version
DEFAULT_DEVICE_ID, DEVICE_ID_OFFSET,// default device id
DEFAULT_BAUDRATE, BAUDRATE_OFFSET,// default baudrate
DEFAULT_RETURN_DELAY, RETURN_DELAY_OFFSET,// return delay time
DEFAULT_MM_PERIOD&0xFF, MM_PERIOD_OFFSET,
DEFAULT_MM_PERIOD>>8, MM_PERIOD_OFFSET+1,
DEFAULT_BAL_KNEE_GAIN&0xFF, MM_BAL_KNEE_GAIN_OFFSET,
DEFAULT_BAL_KNEE_GAIN>>8, MM_BAL_KNEE_GAIN_OFFSET+1,
DEFAULT_BAL_ANKLE_ROLL_GAIN&0xFF, MM_BAL_ANKLE_ROLL_GAIN_OFFSET,
DEFAULT_BAL_ANKLE_ROLL_GAIN>>8, MM_BAL_ANKLE_ROLL_GAIN_OFFSET+1,
DEFAULT_BAL_ANKLE_PITCH_GAIN&0xFF, MM_BAL_ANKLE_PITCH_GAIN_OFFSET,
DEFAULT_BAL_ANKLE_PITCH_GAIN>>8, MM_BAL_ANKLE_PITCH_GAIN_OFFSET+1,
DEFAULT_BAL_HIP_ROLL_GAIN&0xFF, MM_BAL_HIP_ROLL_GAIN_OFFSET,
DEFAULT_BAL_HIP_ROLL_GAIN>>8, MM_BAL_HIP_ROLL_GAIN_OFFSET+1,
DEFAULT_RETURN_LEVEL, RETURN_LEVEL_OFFSET,// return level
DEFAULT_SERVO0_OFFSET, MM_SERVO0_OFFSET,
DEFAULT_SERVO1_OFFSET, MM_SERVO1_OFFSET,
DEFAULT_SERVO2_OFFSET, MM_SERVO2_OFFSET,
DEFAULT_SERVO3_OFFSET, MM_SERVO3_OFFSET,
DEFAULT_SERVO4_OFFSET, MM_SERVO4_OFFSET,
DEFAULT_SERVO5_OFFSET, MM_SERVO5_OFFSET,
DEFAULT_SERVO6_OFFSET, MM_SERVO6_OFFSET,
DEFAULT_SERVO7_OFFSET, MM_SERVO7_OFFSET,
DEFAULT_SERVO8_OFFSET, MM_SERVO8_OFFSET,
DEFAULT_SERVO9_OFFSET, MM_SERVO9_OFFSET,
DEFAULT_SERVO10_OFFSET, MM_SERVO10_OFFSET,
DEFAULT_SERVO11_OFFSET, MM_SERVO11_OFFSET,
DEFAULT_SERVO12_OFFSET, MM_SERVO12_OFFSET,
DEFAULT_SERVO13_OFFSET, MM_SERVO13_OFFSET,
DEFAULT_SERVO14_OFFSET, MM_SERVO14_OFFSET,
DEFAULT_SERVO15_OFFSET, MM_SERVO15_OFFSET,
DEFAULT_SERVO16_OFFSET, MM_SERVO16_OFFSET,
DEFAULT_SERVO17_OFFSET, MM_SERVO17_OFFSET,
DEFAULT_SERVO18_OFFSET, MM_SERVO18_OFFSET,
DEFAULT_SERVO19_OFFSET, MM_SERVO19_OFFSET,
DEFAULT_SERVO20_OFFSET, MM_SERVO20_OFFSET,
DEFAULT_SERVO21_OFFSET, MM_SERVO21_OFFSET,
DEFAULT_SERVO22_OFFSET, MM_SERVO22_OFFSET,
DEFAULT_SERVO23_OFFSET, MM_SERVO23_OFFSET,
DEFAULT_SERVO24_OFFSET, MM_SERVO24_OFFSET,
DEFAULT_SERVO25_OFFSET, MM_SERVO25_OFFSET,
DEFAULT_SERVO26_OFFSET, MM_SERVO26_OFFSET,
DEFAULT_SERVO27_OFFSET, MM_SERVO27_OFFSET,
DEFAULT_SERVO28_OFFSET, MM_SERVO28_OFFSET,
DEFAULT_SERVO29_OFFSET, MM_SERVO29_OFFSET,
DEFAULT_SERVO30_OFFSET, MM_SERVO30_OFFSET,
DEFAULT_SERVO31_OFFSET, MM_SERVO31_OFFSET,
DEFAULT_GYRO_FB_ADC_CH, GYRO_FB_ADC_CH_OFFSET,
DEFAULT_GYRO_LR_ADC_CH, GYRO_LR_ADC_CH_OFFSET};
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
......
......@@ -5,6 +5,7 @@
#include "action.h"
#include "adc_dma.h"
#include "bioloid_gyro.h"
#include "gpio.h"
#define MANAGER_TIMER TIM3
#define ENABLE_MANAGER_TIMER_CLK __HAL_RCC_TIM3_CLK_ENABLE()
......@@ -34,13 +35,16 @@ void manager_send_motion_command(void)
for(i=0;i<MANAGER_MAX_NUM_SERVOS;i++)
{
if(manager_servos[i].enabled && manager_servos[i].model!=0x0000)
{
servo_ids[num]=manager_servos[i].id;
manager_servos[i].cw_comp=(1<<(manager_current_slopes[i]&0x0F));
manager_servos[i].ccw_comp=(1<<((manager_current_slopes[i]&0xF0)>>4));
write_data[num].data_addr=(uint8_t *)&(manager_servos[i].cw_comp);
num++;
if(manager_servos[i].enabled)
{
if(manager_servos[i].model==SERVO_AX12A)
{
servo_ids[num]=manager_servos[i].id;
manager_servos[i].cw_comp=(1<<(manager_current_slopes[i]&0x0F));
manager_servos[i].ccw_comp=(1<<((manager_current_slopes[i]&0xF0)>>4));
write_data[num].data_addr=(uint8_t *)&(manager_servos[i].cw_comp);
num++;
}
}
}
if(num>0)
......@@ -183,7 +187,6 @@ void manager_init(uint16_t period_us)
// enable power to the servos
bioloid_dyn_master_servos_enable_power();
HAL_Delay(1000);
// detect the servos connected
dyn_master_scan(&bioloid_dyn_master_servos,&num,servo_ids);
ram_data[BIOLOID_MM_NUM_SERVOS]=num;
......@@ -320,6 +323,7 @@ void manager_init(uint16_t period_us)
for(i=0;i<MANAGER_MAX_NUM_SERVOS;i++)
manager_balance_offset[i]=0;
manager_balance_enabled=0x00;
gpio_set_led(TXD_LED);
/* initialize action module */
action_init(period_us);
......@@ -464,7 +468,8 @@ inline int16_t manager_get_ccw_angle_limit(uint8_t servo_id)
uint8_t manager_in_range(unsigned short int address, unsigned short int length)
{
if(ram_in_window(MANAGER_BASE_ADDRESS,MANAGER_MEM_LENGTH,address,length) ||
ram_in_window(BIOLOID_MM_PERIOD_L,MANAGER_EEPROM_LENGTH,address,length))
ram_in_window(BIOLOID_MM_PERIOD_L,BIOLOID_MM_BAL_HIP_ROLL_GAIN_H,address,length) ||
ram_in_window(BIOLOID_MM_SERVO0_OFFSET,BIOLOID_MM_SERVO31_OFFSET,address,length))
return 0x01;
else
return 0x00;
......@@ -472,8 +477,8 @@ uint8_t manager_in_range(unsigned short int address, unsigned short int length)
void manager_process_write_cmd(unsigned short int address,unsigned short int length,unsigned char *data)
{
uint16_t word_value;
uint8_t byte_value,module,i,j;
uint16_t word_value,i,j;
uint8_t byte_value,module;
if(ram_in_range(BIOLOID_MM_PERIOD_L,address,length) && ram_in_range(BIOLOID_MM_PERIOD_H,address,length))
{
......
......@@ -15,13 +15,13 @@ void ram_init(void)
if(EE_ReadVariable(DEVICE_MODEL_OFFSET+1,&eeprom_data)==0)
ram_data[DEVICE_MODEL_OFFSET+1]=(uint8_t)(eeprom_data&0x00FF);
if(EE_ReadVariable(FIRMWARE_VERSION_OFFSET,&eeprom_data)==0)
ram_data[FIRMWARE_VERSION_OFFSET]=(uint8_t)eeprom_data;
ram_data[FIRMWARE_VERSION_OFFSET]=(uint8_t)(eeprom_data&0x00FF);
if(EE_ReadVariable(DEVICE_ID_OFFSET,&eeprom_data)==0)
ram_data[DEVICE_ID_OFFSET]=(uint8_t)eeprom_data;
ram_data[DEVICE_ID_OFFSET]=(uint8_t)(eeprom_data&0x00FF);
if(EE_ReadVariable(BAUDRATE_OFFSET,&eeprom_data)==0)
ram_data[BAUDRATE_OFFSET]=(uint8_t)eeprom_data;
ram_data[BAUDRATE_OFFSET]=(uint8_t)(eeprom_data&0x00FF);
if(EE_ReadVariable(RETURN_DELAY_OFFSET,&eeprom_data)==0)
ram_data[RETURN_DELAY_OFFSET]=(uint8_t)eeprom_data;
ram_data[RETURN_DELAY_OFFSET]=(uint8_t)(eeprom_data&0x00FF);
if(EE_ReadVariable(MM_PERIOD_OFFSET,&eeprom_data)==0)
ram_data[MM_PERIOD_OFFSET]=(uint8_t)(eeprom_data&0x00FF);
if(EE_ReadVariable(MM_PERIOD_OFFSET+1,&eeprom_data)==0)
......@@ -43,27 +43,32 @@ void ram_init(void)
if(EE_ReadVariable(MM_BAL_HIP_ROLL_GAIN_OFFSET+1,&eeprom_data)==0)
ram_data[MM_BAL_HIP_ROLL_GAIN_OFFSET+1]=(uint8_t)(eeprom_data&0x00FF);
if(EE_ReadVariable(RETURN_LEVEL_OFFSET,&eeprom_data)==0)
ram_data[RETURN_LEVEL_OFFSET]=(uint8_t)eeprom_data;
ram_data[RETURN_LEVEL_OFFSET]=(uint8_t)(eeprom_data&0x00FF);
for(i=0;i<32;i++)
{
if(EE_ReadVariable(MM_SERVO0_OFFSET+i,&eeprom_data)==0)
ram_data[BIOLOID_MM_SERVO0_OFFSET+i]=(uint8_t)(eeprom_data&0x00FF);
}
if(EE_ReadVariable(GYRO_FB_ADC_CH_OFFSET,&eeprom_data)==0)
ram_data[GYRO_FB_ADC_CH_OFFSET]=(uint8_t)(eeprom_data&0x00FF);
if(EE_ReadVariable(GYRO_LR_ADC_CH_OFFSET,&eeprom_data)==0)
ram_data[GYRO_LR_ADC_CH_OFFSET]=(uint8_t)(eeprom_data&0x00FF);
}
inline void ram_read_byte(uint8_t address,uint8_t *data)
inline void ram_read_byte(uint16_t address,uint8_t *data)
{
(*data)=ram_data[address];
}
inline void ram_read_word(uint8_t address, uint16_t *data)
inline void ram_read_word(uint16_t address, uint16_t *data)
{
(*data)=ram_data[address];
(*data)+=ram_data[address+1]*256;
}
uint8_t ram_read_table(uint8_t address, uint8_t length,uint8_t *data)
uint8_t ram_read_table(uint16_t address, uint16_t length,uint8_t *data)
{
uint8_t i;
uint16_t i;
if((address+length)<=(RAM_SIZE-1))
{
......@@ -75,7 +80,7 @@ uint8_t ram_read_table(uint8_t address, uint8_t length,uint8_t *data)
return RAM_BAD_ADDRESS;
}
uint8_t ram_set_bit(uint8_t address, uint8_t bit)
uint8_t ram_set_bit(uint16_t address, uint8_t bit)
{
if(bit>=0 && bit<8)
{
......@@ -86,7 +91,7 @@ uint8_t ram_set_bit(uint8_t address, uint8_t bit)
return RAM_BAD_BIT;
}
uint8_t ram_clear_bit(uint8_t address, uint8_t bit)
uint8_t ram_clear_bit(uint16_t address, uint8_t bit)
{
if(bit>=0 && bit<8)
{
......@@ -97,14 +102,14 @@ uint8_t ram_clear_bit(uint8_t address, uint8_t bit)
return RAM_BAD_BIT;
}
uint8_t ram_write_byte(uint8_t address, uint8_t data)
uint8_t ram_write_byte(uint16_t address, uint8_t data)
{
ram_data[address]=data;
return RAM_SUCCESS;
}
uint8_t ram_write_word(uint8_t address, uint16_t data)
uint8_t ram_write_word(uint16_t address, uint16_t data)
{
if(address < (RAM_SIZE-1))
{
......@@ -117,9 +122,9 @@ uint8_t ram_write_word(uint8_t address, uint16_t data)
return RAM_BAD_ADDRESS;
}
uint8_t ram_write_table(uint8_t address, uint8_t length,uint8_t *data)
uint8_t ram_write_table(uint16_t address, uint16_t length,uint8_t *data)
{
uint8_t i;
uint16_t i;
if((address+length)<RAM_SIZE)
{
......@@ -131,7 +136,7 @@ uint8_t ram_write_table(uint8_t address, uint8_t length,uint8_t *data)
return RAM_BAD_ADDRESS;
}
inline uint8_t ram_in_range(uint8_t reg,uint8_t address,uint8_t length)
inline uint8_t ram_in_range(uint16_t reg,uint16_t address,uint16_t length)
{
if(reg>=address && reg<(address+length))
return 0x01;
......@@ -139,10 +144,10 @@ inline uint8_t ram_in_range(uint8_t reg,uint8_t address,uint8_t length)
return 0x00;
}
uint8_t ram_in_window(uint8_t start_reg,uint8_t reg_length,uint8_t start_address,uint8_t address_length)
uint8_t ram_in_window(uint16_t start_reg,uint16_t reg_length,uint16_t start_address,uint16_t address_length)
{
uint8_t end_reg=start_reg+reg_length;
uint8_t end_address=start_address+address_length;
uint16_t end_reg=start_reg+reg_length;
uint16_t end_address=start_address+address_length;
if((start_reg>=start_address && start_reg<end_address) || (end_reg>=start_address && end_reg<end_address) ||
(start_address>=start_reg && start_address<end_reg) || (end_address>=start_reg && end_address<end_reg))
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment