Tweaks to HAL codestyle

This commit is contained in:
Scott Lahteine 2018-02-25 00:13:46 -06:00
parent 0e0f17be30
commit f3dbe19669
5 changed files with 76 additions and 139 deletions

View file

@ -54,8 +54,7 @@ unsigned char SoftwareSerial::_receive_buffer[_SS_MAX_RX_BUFF];
volatile uint8_t SoftwareSerial::_receive_buffer_tail = 0; volatile uint8_t SoftwareSerial::_receive_buffer_tail = 0;
volatile uint8_t SoftwareSerial::_receive_buffer_head = 0; volatile uint8_t SoftwareSerial::_receive_buffer_head = 0;
typedef struct _DELAY_TABLE typedef struct _DELAY_TABLE {
{
long baud; long baud;
uint16_t rx_delay_centering; uint16_t rx_delay_centering;
uint16_t rx_delay_intrabit; uint16_t rx_delay_intrabit;
@ -64,16 +63,12 @@ typedef struct _DELAY_TABLE
} DELAY_TABLE; } DELAY_TABLE;
// rough delay estimation // rough delay estimation
static const DELAY_TABLE table[] = static const DELAY_TABLE table[] = {
{ //baud |rxcenter|rxintra |rxstop |tx { 250000, 2, 4, 4, 4, }, //Done but not good due to instruction cycle error { 115200, 4, 8, 8, 8, }, //Done but not good due to instruction cycle error
//baud |rxcenter|rxintra |rxstop |tx
{ 250000, 2, 4, 4, 4, }, //Done but not good due to instruction cycle error
{ 115200, 4, 8, 8, 8, }, //Done but not good due to instruction cycle error
//{ 74880, 69, 139, 62, 162, }, // estimation //{ 74880, 69, 139, 62, 162, }, // estimation
// { 57600, 100, 185, 1, 208, }, // Done but not good due to instruction cycle error // { 57600, 100, 185, 1, 208, }, // Done but not good due to instruction cycle error
//{ 38400, 13, 26, 26, 26, }, // Done //{ 38400, 13, 26, 26, 26, }, // Done
//{ 19200, 26, 52, 52, 52, }, // Done //{ 19200, 26, 52, 52, 52, }, // Done { 9600, 52, 104, 104, 104, }, // Done
{ 9600, 52, 104, 104, 104, }, // Done
//{ 4800, 104, 208, 208, 208, }, //{ 4800, 104, 208, 208, 208, },
//{ 2400, 208, 417, 417, 417, }, //{ 2400, 208, 417, 417, 417, },
//{ 1200, 416, 833, 833, 833,}, //{ 1200, 416, 833, 833, 833,},
@ -85,7 +80,7 @@ static const DELAY_TABLE table[] =
#if 0 #if 0
/* static */ /* static */
inline void SoftwareSerial::tunedDelay(uint32_t count) { inline void SoftwareSerial::tunedDelay(const uint32_t count) {
asm volatile( asm volatile(
@ -101,20 +96,18 @@ inline void SoftwareSerial::tunedDelay(uint32_t count) {
} }
#else #else
inline void SoftwareSerial::tunedDelay(uint32_t count) { inline void SoftwareSerial::tunedDelay(const uint32_t count) {
delayMicroseconds(count); delayMicroseconds(count);
} }
#endif #endif
// This function sets the current object as the "listening" // This function sets the current object as the "listening"
// one and returns true if it replaces another // one and returns true if it replaces another
bool SoftwareSerial::listen() bool SoftwareSerial::listen() {
{
if (!_rx_delay_stopbit) if (!_rx_delay_stopbit)
return false; return false;
if (active_object != this) if (active_object != this) {
{
if (active_object) if (active_object)
active_object->stopListening(); active_object->stopListening();
@ -130,10 +123,8 @@ bool SoftwareSerial::listen()
} }
// Stop listening. Returns true if we were actually listening. // Stop listening. Returns true if we were actually listening.
bool SoftwareSerial::stopListening() bool SoftwareSerial::stopListening() {
{ if (active_object == this) {
if (active_object == this)
{
setRxIntMsk(false); setRxIntMsk(false);
active_object = NULL; active_object = NULL;
return true; return true;
@ -144,14 +135,12 @@ bool SoftwareSerial::stopListening()
// //
// The receive routine called by the interrupt handler // The receive routine called by the interrupt handler
// //
void SoftwareSerial::recv() void SoftwareSerial::recv() {
{
uint8_t d = 0; uint8_t d = 0;
// If RX line is high, then we don't see any start bit // If RX line is high, then we don't see any start bit
// so interrupt is probably not for us // so interrupt is probably not for us
if (_inverse_logic ? rx_pin_read() : !rx_pin_read()) if (_inverse_logic ? rx_pin_read() : !rx_pin_read()) {
{
// Disable further interrupts during reception, this prevents // Disable further interrupts during reception, this prevents
// triggering another interrupt directly after we return, which can // triggering another interrupt directly after we return, which can
// cause problems at higher baudrates. // cause problems at higher baudrates.
@ -160,38 +149,31 @@ void SoftwareSerial::recv()
// Wait approximately 1/2 of a bit width to "center" the sample // Wait approximately 1/2 of a bit width to "center" the sample
tunedDelay(_rx_delay_centering); tunedDelay(_rx_delay_centering);
// Read each of the 8 bits // Read each of the 8 bits
for (uint8_t i=8; i > 0; --i) for (uint8_t i=8; i > 0; --i) {
{ tunedDelay(_rx_delay_intrabit);
tunedDelay(_rx_delay_intrabit);
d >>= 1; d >>= 1;
if (rx_pin_read()) if (rx_pin_read()) d |= 0x80;
d |= 0x80;
} }
if (_inverse_logic) if (_inverse_logic) d = ~d;
d = ~d;
// if buffer full, set the overflow flag and return // if buffer full, set the overflow flag and return
uint8_t next = (_receive_buffer_tail + 1) % _SS_MAX_RX_BUFF; uint8_t next = (_receive_buffer_tail + 1) % _SS_MAX_RX_BUFF;
if (next != _receive_buffer_head) if (next != _receive_buffer_head) {
{
// save new data in buffer: tail points to where byte goes // save new data in buffer: tail points to where byte goes
_receive_buffer[_receive_buffer_tail] = d; // save new byte _receive_buffer[_receive_buffer_tail] = d; // save new byte
_receive_buffer_tail = next; _receive_buffer_tail = next;
} }
else else {
{
_buffer_overflow = true; _buffer_overflow = true;
} }
tunedDelay(_rx_delay_stopbit); tunedDelay(_rx_delay_stopbit);
// Re-enable interrupts when we're sure to be inside the stop bit // Re-enable interrupts when we're sure to be inside the stop bit
setRxIntMsk(true);//__enable_irq();// setRxIntMsk(true); //__enable_irq();//
} }
} }
uint32_t SoftwareSerial::rx_pin_read() uint32_t SoftwareSerial::rx_pin_read() {
{
return digitalRead(_receivePin); return digitalRead(_receivePin);
} }
@ -200,12 +182,9 @@ uint32_t SoftwareSerial::rx_pin_read()
// //
/* static */ /* static */
inline void SoftwareSerial::handle_interrupt() inline void SoftwareSerial::handle_interrupt() {
{
if (active_object) if (active_object)
{
active_object->recv(); active_object->recv();
}
} }
extern "C" void intWrapper() { extern "C" void intWrapper() {
SoftwareSerial::handle_interrupt(); SoftwareSerial::handle_interrupt();
@ -219,23 +198,19 @@ SoftwareSerial::SoftwareSerial(pin_t receivePin, pin_t transmitPin, bool inverse
_rx_delay_stopbit(0), _rx_delay_stopbit(0),
_tx_delay(0), _tx_delay(0),
_buffer_overflow(false), _buffer_overflow(false),
_inverse_logic(inverse_logic) _inverse_logic(inverse_logic) {
{
setTX(transmitPin); setTX(transmitPin);
setRX(receivePin); setRX(receivePin);
} }
// //
// Destructor // Destructor
// //
SoftwareSerial::~SoftwareSerial() SoftwareSerial::~SoftwareSerial() {
{
end(); end();
} }
void SoftwareSerial::setTX(pin_t tx) void SoftwareSerial::setTX(pin_t tx) {
{
// First write, then set output. If we do this the other way around, // First write, then set output. If we do this the other way around,
// the pin would be output low for a short while before switching to // the pin would be output low for a short while before switching to
// output hihg. Now, it is input with pullup for a short while, which // output hihg. Now, it is input with pullup for a short while, which
@ -244,36 +219,30 @@ void SoftwareSerial::setTX(pin_t tx)
digitalWrite(tx, _inverse_logic ? LOW : HIGH); digitalWrite(tx, _inverse_logic ? LOW : HIGH);
pinMode(tx,OUTPUT); pinMode(tx,OUTPUT);
_transmitPin = tx; _transmitPin = tx;
} }
void SoftwareSerial::setRX(pin_t rx) void SoftwareSerial::setRX(pin_t rx) {
{
pinMode(rx, INPUT_PULLUP); // pullup for normal logic! pinMode(rx, INPUT_PULLUP); // pullup for normal logic!
//if (!_inverse_logic) //if (!_inverse_logic)
// digitalWrite(rx, HIGH); // digitalWrite(rx, HIGH);
_receivePin = rx; _receivePin = rx;
_receivePort = LPC1768_PIN_PORT(rx); _receivePort = LPC1768_PIN_PORT(rx);
_receivePortPin = LPC1768_PIN_PIN(rx); _receivePortPin = LPC1768_PIN_PIN(rx);
/* GPIO_T * rxPort = digitalPinToPort(rx); /* GPIO_T * rxPort = digitalPinToPort(rx);
_receivePortRegister = portInputRegister(rxPort); _receivePortRegister = portInputRegister(rxPort);
_receiveBitMask = digitalPinToBitMask(rx);*/ _receiveBitMask = digitalPinToBitMask(rx);*/
} }
// //
// Public methods // Public methods
// //
void SoftwareSerial::begin(long speed) void SoftwareSerial::begin(long speed) {
{
_rx_delay_centering = _rx_delay_intrabit = _rx_delay_stopbit = _tx_delay = 0; _rx_delay_centering = _rx_delay_intrabit = _rx_delay_stopbit = _tx_delay = 0;
for(uint8_t i = 0; i < sizeof(table)/sizeof(table[0]); ++i) for(uint8_t i = 0; i < sizeof(table)/sizeof(table[0]); ++i) {
{
long baud = table[i].baud; long baud = table[i].baud;
if(baud == speed) if (baud == speed) {
{
_rx_delay_centering = table[i].rx_delay_centering; _rx_delay_centering = table[i].rx_delay_centering;
_rx_delay_intrabit = table[i].rx_delay_intrabit; _rx_delay_intrabit = table[i].rx_delay_intrabit;
_rx_delay_stopbit = table[i].rx_delay_stopbit; _rx_delay_stopbit = table[i].rx_delay_stopbit;
@ -289,29 +258,24 @@ void SoftwareSerial::begin(long speed)
} }
void SoftwareSerial::setRxIntMsk(bool enable) void SoftwareSerial::setRxIntMsk(bool enable) {
{
if (enable) if (enable)
GpioEnableInt(_receivePort,_receivePin,CHANGE); GpioEnableInt(_receivePort,_receivePin,CHANGE);
else else
GpioDisableInt(_receivePort,_receivePin); GpioDisableInt(_receivePort,_receivePin);
} }
void SoftwareSerial::end() void SoftwareSerial::end() {
{
stopListening(); stopListening();
} }
// Read data from buffer // Read data from buffer
int SoftwareSerial::read() int SoftwareSerial::read() {
{ if (!isListening()) return -1;
if (!isListening())
return -1;
// Empty buffer? // Empty buffer?
if (_receive_buffer_head == _receive_buffer_tail) if (_receive_buffer_head == _receive_buffer_tail) return -1;
return -1;
// Read from "head" // Read from "head"
uint8_t d = _receive_buffer[_receive_buffer_head]; // grab next byte uint8_t d = _receive_buffer[_receive_buffer_head]; // grab next byte
@ -319,16 +283,13 @@ int SoftwareSerial::read()
return d; return d;
} }
int SoftwareSerial::available() int SoftwareSerial::available() {
{ if (!isListening()) return 0;
if (!isListening())
return 0;
return (_receive_buffer_tail + _SS_MAX_RX_BUFF - _receive_buffer_head) % _SS_MAX_RX_BUFF; return (_receive_buffer_tail + _SS_MAX_RX_BUFF - _receive_buffer_head) % _SS_MAX_RX_BUFF;
} }
size_t SoftwareSerial::write(uint8_t b) size_t SoftwareSerial::write(uint8_t b) {
{
// By declaring these as local variables, the compiler will put them // By declaring these as local variables, the compiler will put them
// in registers _before_ disabling interrupts and entering the // in registers _before_ disabling interrupts and entering the
// critical timing sections below, which makes it a lot easier to // critical timing sections below, which makes it a lot easier to
@ -337,36 +298,25 @@ size_t SoftwareSerial::write(uint8_t b)
bool inv = _inverse_logic; bool inv = _inverse_logic;
uint16_t delay = _tx_delay; uint16_t delay = _tx_delay;
if(inv) if (inv) b = ~b;
b = ~b;
cli(); // turn off interrupts for a clean txmit cli(); // turn off interrupts for a clean txmit
// Write the start bit // Write the start bit
if (inv) digitalWrite(_transmitPin, !!inv);
digitalWrite(_transmitPin, 1);
else
digitalWrite(_transmitPin, 0);
tunedDelay(delay); tunedDelay(delay);
// Write each of the 8 bits // Write each of the 8 bits
for (uint8_t i = 8; i > 0; --i) for (uint8_t i = 8; i > 0; --i) {
{ digitalWrite(_transmitPin, b & 1); // send 1 //(GPIO_Desc[_transmitPin].P)->DOUT |= GPIO_Desc[_transmitPin].bit;
if (b & 1) // choose bit // send 0 //(GPIO_Desc[_transmitPin].P)->DOUT &= ~GPIO_Desc[_transmitPin].bit;
digitalWrite(_transmitPin, 1); // send 1 //(GPIO_Desc[_transmitPin].P)->DOUT |= GPIO_Desc[_transmitPin].bit;
else
digitalWrite(_transmitPin, 0); // send 0 //(GPIO_Desc[_transmitPin].P)->DOUT &= ~GPIO_Desc[_transmitPin].bit;
tunedDelay(delay); tunedDelay(delay);
b >>= 1; b >>= 1;
} }
// restore pin to natural state // restore pin to natural state
if (inv) digitalWrite(_transmitPin, !inv);
digitalWrite(_transmitPin, 0);
else
digitalWrite(_transmitPin, 1);
sei(); // turn interrupts back on sei(); // turn interrupts back on
tunedDelay(delay); tunedDelay(delay);
@ -374,18 +324,15 @@ size_t SoftwareSerial::write(uint8_t b)
return 1; return 1;
} }
void SoftwareSerial::flush() void SoftwareSerial::flush() {
{ if (!isListening()) return;
if (!isListening())
return;
cli(); cli();
_receive_buffer_head = _receive_buffer_tail = 0; _receive_buffer_head = _receive_buffer_tail = 0;
sei(); sei();
} }
int SoftwareSerial::peek() int SoftwareSerial::peek() {
{
if (!isListening()) if (!isListening())
return -1; return -1;

View file

@ -165,9 +165,9 @@ void eeprom_write_byte(unsigned char *pos, unsigned char value) {
unsigned char eeprom_read_byte(uint8_t * pos) { return '\0'; } unsigned char eeprom_read_byte(uint8_t * pos) { return '\0'; }
void eeprom_read_block (void *__dst, const void *__src, size_t __n) { } void eeprom_read_block(void *__dst, const void *__src, size_t __n) { }
void eeprom_update_block (const void *__src, void *__dst, size_t __n) { } void eeprom_update_block(const void *__src, void *__dst, size_t __n) { }
char *dtostrf (double __val, signed char __width, unsigned char __prec, char *__s) { char *dtostrf (double __val, signed char __width, unsigned char __prec, char *__s) {
char format_string[20]; char format_string[20];

View file

@ -80,23 +80,18 @@ static bool eeprom_initialised = false;
void eeprom_init() { void eeprom_init() {
if(!eeprom_initialised) { if (!eeprom_initialised) {
HAL_FLASH_Unlock(); HAL_FLASH_Unlock();
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR |FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR | FLASH_FLAG_PGSERR); __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR |FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR | FLASH_FLAG_PGSERR);
/* EEPROM Init */ /* EEPROM Init */
if(EE_Initialise() != EE_OK) if (EE_Initialise() != EE_OK)
{ for (;;) HAL_Delay(1); // Spin forever until watchdog reset
while(1) {
HAL_Delay(1);
}
}
HAL_FLASH_Lock(); HAL_FLASH_Lock();
eeprom_initialised = true; eeprom_initialised = true;
} }
} }
void eeprom_write_byte(unsigned char *pos, unsigned char value) { void eeprom_write_byte(unsigned char *pos, unsigned char value) {
@ -106,39 +101,38 @@ void eeprom_write_byte(unsigned char *pos, unsigned char value) {
HAL_FLASH_Unlock(); HAL_FLASH_Unlock();
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR |FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR | FLASH_FLAG_PGSERR); __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR |FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR | FLASH_FLAG_PGSERR);
if(EE_WriteVariable(eeprom_address, (uint16_t) value) != EE_OK) {
while(1) { if (EE_WriteVariable(eeprom_address, (uint16_t) value) != EE_OK)
HAL_Delay(1); for (;;) HAL_Delay(1); // Spin forever until watchdog reset
}
}
HAL_FLASH_Lock(); HAL_FLASH_Lock();
} }
unsigned char eeprom_read_byte(unsigned char *pos) { unsigned char eeprom_read_byte(unsigned char *pos) {
uint16_t data = 0xFF; uint16_t data = 0xFF;
uint16_t eeprom_address = (unsigned) pos; uint16_t eeprom_address = (unsigned)pos;
eeprom_init(); eeprom_init();
if(EE_ReadVariable(eeprom_address, &data) != EE_OK) { if (EE_ReadVariable(eeprom_address, &data) != EE_OK) {
return (char) data; return (unsigned char)data;
} }
return (char)data; return (unsigned char)data;
} }
void eeprom_read_block (void *__dst, const void *__src, size_t __n) { void eeprom_read_block(void *__dst, const void *__src, size_t __n) {
uint16_t data = 0xFF; uint16_t data = 0xFF;
uint16_t eeprom_address = (unsigned) __src; uint16_t eeprom_address = (unsigned) __src;
eeprom_init(); eeprom_init();
for(uint8_t c = 0; c < __n; c++) { for (uint8_t c = 0; c < __n; c++) {
EE_ReadVariable(eeprom_address+c, &data); EE_ReadVariable(eeprom_address+c, &data);
*((uint8_t*)__dst + c) = data; *((uint8_t*)__dst + c) = data;
} }
} }
void eeprom_update_block (const void *__src, void *__dst, size_t __n) { void eeprom_update_block(const void *__src, void *__dst, size_t __n) {
} }

View file

@ -72,10 +72,10 @@
// Public functions // Public functions
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
static bool eeprom_initialised = false;
static uint8_t eeprom_device_address = 0x50; static uint8_t eeprom_device_address = 0x50;
static void eeprom_init(void) { static void eeprom_init(void) {
static bool eeprom_initialised = false;
if (!eeprom_initialised) { if (!eeprom_initialised) {
Wire.begin(); Wire.begin();
eeprom_initialised = true; eeprom_initialised = true;
@ -100,27 +100,25 @@ void eeprom_write_byte(unsigned char *pos, unsigned char value) {
// WARNING: address is a page address, 6-bit end will wrap around // WARNING: address is a page address, 6-bit end will wrap around
// also, data can be maximum of about 30 bytes, because the Wire library has a buffer of 32 bytes // also, data can be maximum of about 30 bytes, because the Wire library has a buffer of 32 bytes
void eeprom_update_block(const void* pos, void* eeprom_address, size_t n) { void eeprom_update_block(const void *pos, void* eeprom_address, size_t n) {
uint8_t eeprom_temp[32] = {0};
uint8_t flag = 0;
eeprom_init(); eeprom_init();
Wire.beginTransmission(eeprom_device_address); Wire.beginTransmission(eeprom_device_address);
Wire.write((int)((unsigned)eeprom_address >> 8)); // MSB Wire.write((int)((unsigned)eeprom_address >> 8)); // MSB
Wire.write((int)((unsigned)eeprom_address & 0xFF)); // LSB Wire.write((int)((unsigned)eeprom_address & 0xFF)); // LSB
Wire.endTransmission(); Wire.endTransmission();
uint8_t *ptr = (uint8_t*)pos;
uint8_t flag = 0;
Wire.requestFrom(eeprom_device_address, (byte)n); Wire.requestFrom(eeprom_device_address, (byte)n);
for (byte c = 0; c < n; c++) { for (byte c = 0; c < n && Wire.available(); c++)
if (Wire.available()) eeprom_temp[c] = Wire.read(); flag |= Wire.read() ^ ptr[c];
flag |= (eeprom_temp[c] ^ *((uint8_t*)pos + c));
}
if (flag) { if (flag) {
Wire.beginTransmission(eeprom_device_address); Wire.beginTransmission(eeprom_device_address);
Wire.write((int)((unsigned)eeprom_address >> 8)); // MSB Wire.write((int)((unsigned)eeprom_address >> 8)); // MSB
Wire.write((int)((unsigned)eeprom_address & 0xFF)); // LSB Wire.write((int)((unsigned)eeprom_address & 0xFF)); // LSB
Wire.write((uint8_t*)(pos), n); Wire.write((uint8_t*)pos, n);
Wire.endTransmission(); Wire.endTransmission();
// wait for write cycle to complete // wait for write cycle to complete
@ -132,18 +130,16 @@ void eeprom_update_block(const void* pos, void* eeprom_address, size_t n) {
unsigned char eeprom_read_byte(unsigned char *pos) { unsigned char eeprom_read_byte(unsigned char *pos) {
byte data = 0xFF; byte data = 0xFF;
unsigned eeprom_address = (unsigned) pos; unsigned eeprom_address = (unsigned)pos;
eeprom_init (); eeprom_init();
Wire.beginTransmission(eeprom_device_address); Wire.beginTransmission(eeprom_device_address);
Wire.write((int)(eeprom_address >> 8)); // MSB Wire.write((int)(eeprom_address >> 8)); // MSB
Wire.write((int)(eeprom_address & 0xFF)); // LSB Wire.write((int)(eeprom_address & 0xFF)); // LSB
Wire.endTransmission(); Wire.endTransmission();
Wire.requestFrom(eeprom_device_address, (byte)1); Wire.requestFrom(eeprom_device_address, (byte)1);
if (Wire.available()) return Wire.available() ? Wire.read() : 0xFF;
data = Wire.read();
return data;
} }
// maybe let's not read more than 30 or 32 bytes at a time! // maybe let's not read more than 30 or 32 bytes at a time!

View file

@ -541,7 +541,7 @@
// increment to first segment destination // increment to first segment destination
LOOP_XYZE(i) raw[i] += diff[i]; LOOP_XYZE(i) raw[i] += diff[i];
for(;;) { // for each mesh cell encountered during the move for (;;) { // for each mesh cell encountered during the move
// Compute mesh cell invariants that remain constant for all segments within cell. // Compute mesh cell invariants that remain constant for all segments within cell.
// Note for cell index, if point is outside the mesh grid (in MESH_INSET perimeter) // Note for cell index, if point is outside the mesh grid (in MESH_INSET perimeter)
@ -591,7 +591,7 @@
const float z_sxy0 = z_xmy0 * diff[X_AXIS], // per-segment adjustment to z_cxy0 const float z_sxy0 = z_xmy0 * diff[X_AXIS], // per-segment adjustment to z_cxy0
z_sxym = (z_xmy1 - z_xmy0) * (1.0 / (MESH_Y_DIST)) * diff[X_AXIS]; // per-segment adjustment to z_cxym z_sxym = (z_xmy1 - z_xmy0) * (1.0 / (MESH_Y_DIST)) * diff[X_AXIS]; // per-segment adjustment to z_cxym
for(;;) { // for all segments within this mesh cell for (;;) { // for all segments within this mesh cell
if (--segments == 0) // if this is last segment, use rtarget for exact if (--segments == 0) // if this is last segment, use rtarget for exact
COPY(raw, rtarget); COPY(raw, rtarget);