Значит такс:
1.проект на С++
В общем, структура кода приблизительно такова:
Главная ф-ция:
Код
ResourceManager RM;
int main(void)
{
/*!< At this stage the microcontroller clock setting is already configured,
this is done through SystemInit() function which is called from startup
file (startup_stm32f10x_xx.s) before to branch to application main.
To reconfigure the default setting of SystemInit() function, refer to
system_stm32f10x.c file
*/
RM.start();
}
Содержит два класса
Первый, базовый
Код
class PlatformAbstractionLayer
{
public:
PlatformAbstractionLayer();
virtual ~PlatformAbstractionLayer();
inline void confGPIO(void);
inline void confConnection(void);
inline bool confSystemTimer(void);
protected:
...
};
inline void PlatformAbstractionLayer::confGPIO(void)
{
//Единственное место, где я задействовал библиотеку STM32F10x_StdPeriph_Lib_V3.3.0
...
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIO_Init(GPIOC, &GPIO_InitStructure);
GPIO_Init(GPIOD, &GPIO_InitStructure);
...
}
inline bool PlatformAbstractionLayer::confSystemTimer(void)
{
return !SysTick_Config(SystemCoreClock / 1000);
}
!!!Остальные методы класса пусты!!!
второй, наследник
Код
class ResourceManager: public PlatformAbstractionLayer
{
public:
ResourceManager();
virtual ~ResourceManager();
inline void start(void);
inline void softTimersDecrement(void);
private:
uint32 SoftTimerTicks[SOFT_TIMER_CNT];
uint32 SoftTimerPeriod[SOFT_TIMER_CNT];
uint32 SoftTimerFlags;
inline void confHardware(void);
inline void confSoftware(void);
};
inline void ResourceManager::start(void)
{
this->confHardware();
this->confSoftware();
while(1)
{}
}
inline void ResourceManager::softTimersDecrement(void)
{
uint16 idx;
for(idx = 0; idx < SOFT_TIMER_CNT; idx++)
{
if((this->SoftTimerTicks[idx] != 0) && (--(this->SoftTimerTicks[idx]) == 0))
{
this->SoftTimerTicks[idx] = this->SoftTimerPeriod[idx];
this->SoftTimerFlags |= BV32(idx);
}
}
}
inline void ResourceManager::confHardware(void)
{
this->confGPIO();
this->confConnection();
this->confSystemTimer();
}
inline void ResourceManager::confSoftware(void)
{
}
2.опции -fno-exceptions -fno-rtti использовал!
3.Компилил проект четырьмя сборками компилятора
а. CodeSourcery
б. kgp_arm_eabi_x86_32_20101006
в. Собственная сборка
г. Собственная сборка (newlib собирал с опцией (среди прочих, оптимизирующих размер кода) --disable-newlib-supplied-syscalls, с использованием файла-заглушки syscalls.c)
Результаты получились такие (размер секции .text в байтах):
CodeSourcery - 57936
kgp_arm_eabi_x86_32_20101006 - 5008
Собственная сборка (в) - 10636
Собственная сборка (г) - 7784
При определении класса PlatformAbstractionLayer как абстрактный:
Код
class PlatformAbstractionLayer
{
public:
PlatformAbstractionLayer();
virtual ~PlatformAbstractionLayer();
inline void confGPIO(void);
inline void confConnection(void);
inline bool confSystemTimer(void);
protected:
virtual inline void softTimersDecrement(void)=0;
...
};
ситуация меняется так (размер секции .text в байтах):
CodeSourcery - 57936
kgp_arm_eabi_x86_32_20101006 - 41716
Собственная сборка (в) - 65664
Собственная сборка (г) - 64728