Malala Yousafzai, the 14-year-old Pakistani girl shot in the head by Taliban gunmen last week, is being flown to the UK for medical treatment, the Pakistani army has said.
Malala Yousafzai has until now been at a military hospital in Rawalpindi, with doctors saying her progress over the next few days would be "critical".
The girl wrote a diary about suffering under the Taliban and was accused by them of "promoting secularism".
The UK said Malala Yousafzai's transfer followed London's offer to help her in any way.
Malala Yousafzai was taken to Islamabad and then left the country on board an air ambulance provided by the United Arab Emirates, accompanied by a full medical team.
The military said her doctors in Rawalpindi were "pleased with her present condition which has been described as optimal".
"The panel of doctors recommended that Malala be shifted abroad to a UK centre which has the capability to provide integrated care to children who have sustained severe injury," it said.
Malala Yousafzai is expected to need treatment to repair or replace damaged bones in her skull and to undergo neurological treatment.
The UK said it would not release information about where she was being taken to respect patient confidentiality, but said it had "capacity for Malala to be treated without affecting the normal operations of the hospital".
The UK's Foreign Secretary William Hague said the attack on Malala Yousafzai and her friends "shocked Pakistan and the world" and that her bravery was "an example to us all".
Malala Yousafzai – who was a well-known campaigner for education for girls – was attacked last Tuesday as she was returning home from school in Mingora in north-western Swat.
Two armed men, on foot, stopped a van packed with about a dozen schoolgirls in a congested area of the town.
One of them got into the van and asked which of the girls was Malala Yousafzai before he fired three shots, hitting Malala in the head and injuring two others.
The Taliban has warned they will target Malala Yousafzai again.
Malala has been kept sedated and on a ventilator since she was taken to hospital, with tight security around her.
The ventilator was removed briefly over the weekend to see how she coped and presumably have determined she is well enough to travel.
Four people have been arrested in connection with the attack. They were among about 100 people rounded up this week, most of whom were later released on bail.
On Monday, former British Prime Minister Gordon Brown, who is now the UN's Special Envoy for Global Education, said he was launching a petition in Malala Yousafzai's name "in support of what Malala fought for".
"Today, sadly, 32 million girls are not going to school and it is time to fight harder for Malala's dream to come true," he said.


text:
#include <string.h>
#ifdef RTE_CMSIS_RTOS
#include "cmsis_os.h"
#endif
#include "DAP_config.h"
#include "DAP.h"

#define DAP_FW_VER      "1.10"  // Firmware Version

#if (DAP_PACKET_SIZE < 64U)
#error "Minimum Packet Size is 64"
#endif
#if (DAP_PACKET_SIZE > 32768U)
#error "Maximum Packet Size is 32768"
#endif
#if (DAP_PACKET_COUNT < 1U)
#error "Minimum Packet Count is 1"
#endif
#if (DAP_PACKET_COUNT > 255U)
#error "Maximum Packet Count is 255"
#endif

 // Clock Macros

#define MAX_SWJ_CLOCK(delay_cycles) \
  (CPU_CLOCK/2 / (IO_PORT_WRITE_CYCLES + delay_cycles))

#define CLOCK_DELAY(swj_clock) \
  ((CPU_CLOCK/2 / swj_clock) - IO_PORT_WRITE_CYCLES)

         DAP_Data_t DAP_Data;           // DAP Data
volatile uint8_t    DAP_TransferAbort;  // Transfer Abort Flag

#ifdef DAP_VENDOR
const char DAP_Vendor [] = DAP_VENDOR;
#endif
#ifdef DAP_PRODUCT
const char DAP_Product[] = DAP_PRODUCT;
#endif
#ifdef DAP_SER_NUM
const char DAP_SerNum [] = DAP_SER_NUM;
#endif
const char DAP_FW_Ver [] = DAP_FW_VER;

#if TARGET_DEVICE_FIXED
const char TargetDeviceVendor [] = TARGET_DEVICE_VENDOR;
const char TargetDeviceName   [] = TARGET_DEVICE_NAME;
#endif

// Get DAP Information
//   id:      info identifier
//   info:    pointer to info data
//   return:  number of bytes in info data
static uint8_t DAP_Info(uint8_t id, uint8_t *info) {
  uint8_t length = 0U;

  switch (id) {
    case DAP_ID_VENDOR:
#ifdef DAP_VENDOR
      memcpy(info, DAP_Vendor, sizeof(DAP_Vendor));
      length = (uint8_t)sizeof(DAP_Vendor);
#endif
      break;
    case DAP_ID_PRODUCT:
#ifdef DAP_PRODUCT
      memcpy(info, DAP_Product, sizeof(DAP_Product));
      length = (uint8_t)sizeof(DAP_Product);
#endif
      break;
    case DAP_ID_SER_NUM:
#ifdef DAP_SER_NUM
      memcpy(info, DAP_SerNum, sizeof(DAP_SerNum));
      length = (uint8_t)sizeof(DAP_SerNum);
#endif
      break;
    case DAP_ID_FW_VER:
      memcpy(info, DAP_FW_Ver, sizeof(DAP_FW_Ver));
      length = (uint8_t)sizeof(DAP_FW_Ver);
      break;
    case DAP_ID_DEVICE_VENDOR:
#if TARGET_DEVICE_FIXED
      memcpy(info, TargetDeviceVendor, sizeof(TargetDeviceVendor));
      length = (uint8_t)sizeof(TargetDeviceVendor);
#endif
      break;
    case DAP_ID_DEVICE_NAME:
#if TARGET_DEVICE_FIXED
      memcpy(info, TargetDeviceName, sizeof(TargetDeviceName));
      length = (uint8_t)sizeof(TargetDeviceName);
#endif
      break;
    case DAP_ID_CAPABILITIES:
      info[0] = ((DAP_SWD  != 0)       ? (1U << 0) : 0U) |
                ((DAP_JTAG != 0)       ? (1U << 1) : 0U) |
                ((SWO_UART != 0)       ? (1U << 2) : 0U) |
                ((SWO_MANCHESTER != 0) ? (1U << 3) : 0U) |
                /* Atomic Commands  */   (1U << 4);
      length = 1U;
      break;
    case DAP_ID_SWO_BUFFER_SIZE:
#if ((SWO_UART != 0) || (SWO_MANCHESTER != 0))
      info[0] = (uint8_t)(SWO_BUFFER_SIZE >>  0);
      info[1] = (uint8_t)(SWO_BUFFER_SIZE >>  8);
      info[2] = (uint8_t)(SWO_BUFFER_SIZE >> 16);
      info[3] = (uint8_t)(SWO_BUFFER_SIZE >> 24);
      length = 4U;
#endif
      break;
    case DAP_ID_PACKET_SIZE:
      info[0] = (uint8_t)(DAP_PACKET_SIZE >> 0);
      info[1] = (uint8_t)(DAP_PACKET_SIZE >> 8);
      length = 2U;
      break;
    case DAP_ID_PACKET_COUNT:
      info[0] = DAP_PACKET_COUNT;
      length = 1U;
      break;
    default:
      break;
  }

  return (length);
}

// Timer Functions

#if ((DAP_SWD != 0) || (DAP_JTAG != 0))

#ifdef RTE_CMSIS_RTOS

static uint32_t TimerTick;

// Start Timer
static __inline void TIMER_START (uint32_t usec) {
  TimerTick = osKernelSysTick() + osKernelSysTickMicroSec(usec);
}

// Stop Timer
static __inline void TIMER_STOP (void) {}

// Check if Timer expired
static __inline uint32_t TIMER_EXPIRED (void) {
  return ((osKernelSysTick() > TimerTick) ? 1U : 0U);
}

#else

// Start Timer
static __inline void TIMER_START (uint32_t usec) {
  SysTick->VAL  = 0U;
  SysTick->LOAD = usec * (CPU_CLOCK/1000000U);
  SysTick->CTRL = (1U << SysTick_CTRL_ENABLE_Pos) |
                  (1U << SysTick_CTRL_CLKSOURCE_Pos);
}

// Stop Timer
static __inline void TIMER_STOP (void) {
  SysTick->CTRL = 0U;
}

// Check if Timer expired
static __inline uint32_t TIMER_EXPIRED (void) {
  return ((SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk) ? 1U : 0U);
}

#endif

#endif

// Delay for specified time
//    delay:  delay time in ms
void Delayms(uint32_t delay) {
  delay *= ((CPU_CLOCK/1000U) + (DELAY_SLOW_CYCLES-1U)) / DELAY_SLOW_CYCLES;
  PIN_DELAY_SLOW(delay);
}

// Process Delay command and prepare response
//   request:  pointer to request data
//   response: pointer to response data
//   return:   number of bytes in response (lower 16 bits)
//             number of bytes in request (upper 16 bits)
static uint32_t DAP_Delay(const uint8_t *request, uint8_t *response) {
  uint32_t delay;

  delay  = *(request+0) | (*(request+1) << 8);
  delay *= ((CPU_CLOCK/1000000U) + (DELAY_SLOW_CYCLES-1U)) / DELAY_SLOW_CYCLES;

  PIN_DELAY_SLOW(delay);

  *response = DAP_OK;
  return ((2U << 16) | 1U);
}

// Process Host Status command and prepare response
//   request:  pointer to request data
//   response: pointer to response data
//   return:   number of bytes in response (lower 16 bits)
//             number of bytes in request (upper 16 bits)
static uint32_t DAP_HostStatus(const uint8_t *request, uint8_t *response) {

  switch (*request) {
    case DAP_DEBUGGER_CONNECTED:
      LED_CONNECTED_OUT((*(request+1) & 1U));
      break;
    case DAP_TARGET_RUNNING:
      LED_RUNNING_OUT((*(request+1) & 1U));
      break;
    default:
      *response = DAP_ERROR;
      return ((2U << 16) | 1U);
  }

  *response = DAP_OK;
  return ((2U << 16) | 1U);
}

// Process Connect command and prepare response
//   request:  pointer to request data
//   response: pointer to response data
//   return:   number of bytes in response (lower 16 bits)
//             number of bytes in request (upper 16 bits)
static uint32_t DAP_Connect(const uint8_t *request, uint8_t *response) {
  uint32_t port;

  if (*request == DAP_PORT_AUTODETECT) {
    port = DAP_DEFAULT_PORT;
  } else {
    port = *request;
  }

  switch (port) {
#if (DAP_SWD != 0)
    case DAP_PORT_SWD:
      DAP_Data.debug_port = DAP_PORT_SWD;
      PORT_SWD_SETUP();
      break;
#endif
#if (DAP_JTAG != 0)
    case DAP_PORT_JTAG:
      DAP_Data.debug_port = DAP_PORT_JTAG;
      PORT_JTAG_SETUP();
      break;
#endif
    default:
      port = DAP_PORT_DISABLED;
      break;
  }

  *response = (uint8_t)port;
  return ((1U << 16) | 1U);
}

// Process Disconnect command and prepare response
//   response: pointer to response data
//   return:   number of bytes in response
static uint32_t DAP_Disconnect(uint8_t *response) {

  DAP_Data.debug_port = DAP_PORT_DISABLED;
  PORT_OFF();

  *response = DAP_OK;
  return (1U);
}

// Process Reset Target command and prepare response
//   response: pointer to response data
//   return:   number of bytes in response
static uint32_t DAP_ResetTarget(uint8_t *response) {

  *(response+1) = RESET_TARGET();
  *(response+0) = DAP_OK;
  return (2U);
}

// Process SWJ Pins command and prepare response
//   request:  pointer to request data
//   response: pointer to response data
//   return:   number of bytes in response (lower 16 bits)
//             number of bytes in request (upper 16 bits)
static uint32_t DAP_SWJ_Pins(const uint8_t *request, uint8_t *response) {
#if ((DAP_SWD != 0) || (DAP_JTAG != 0))
  uint32_t value;
  uint32_t select;
  uint32_t wait;

  value  =  *(request+0);
  select =  *(request+1);
  wait   = (*(request+2) <<  0) |
           (*(request+3) <<  8) |
           (*(request+4) << 16) |
           (*(request+5) << 24);

  if (select & (1U << DAP_SWJ_SWCLK_TCK)) {
    if (value & (1U << DAP_SWJ_SWCLK_TCK)) {
      PIN_SWCLK_TCK_SET();
    } else {
      PIN_SWCLK_TCK_CLR();
    }
  }
  if (select & (1U << DAP_SWJ_SWDIO_TMS)) {
    if (value & (1U << DAP_SWJ_SWDIO_TMS)) {
      PIN_SWDIO_TMS_SET();
    } else {
      PIN_SWDIO_TMS_CLR();
    }
  }
  if (select & (1U << DAP_SWJ_TDI)) {
    PIN_TDI_OUT(value >> DAP_SWJ_TDI);
  }
  if (select & (1U << DAP_SWJ_nTRST)) {
    PIN_nTRST_OUT(value >> DAP_SWJ_nTRST);
  }
  if (select & (1U << DAP_SWJ_nRESET)) {
    PIN_nRESET_OUT(value >> DAP_SWJ_nRESET);
  }

  if (wait) {
    if (wait > 3000000U) { wait = 3000000U; }
    TIMER_START(wait);
    do {
      if (select & (1U << DAP_SWJ_SWCLK_TCK)) {
        if ((value >> DAP_SWJ_SWCLK_TCK) ^ PIN_SWCLK_TCK_IN()) { continue; }
      }
      if (select & (1U << DAP_SWJ_SWDIO_TMS)) {
        if ((value >> DAP_SWJ_SWDIO_TMS) ^ PIN_SWDIO_TMS_IN()) { continue; }
      }
      if (select & (1U << DAP_SWJ_TDI)) {
        if ((value >> DAP_SWJ_TDI) ^ PIN_TDI_IN()) { continue; }
      }
      if (select & (1U << DAP_SWJ_nTRST)) {
        if ((value >> DAP_SWJ_nTRST) ^ PIN_nTRST_IN()) { continue; }
      }
      if (select & (1U << DAP_SWJ_nRESET)) {
        if ((value >> DAP_SWJ_nRESET) ^ PIN_nRESET_IN()) { continue; }
      }
      break;
    } while (!TIMER_EXPIRED());
    TIMER_STOP();
  }

  value = (PIN_SWCLK_TCK_IN() << DAP_SWJ_SWCLK_TCK) |
          (PIN_SWDIO_TMS_IN() << DAP_SWJ_SWDIO_TMS) |
          (PIN_TDI_IN()       << DAP_SWJ_TDI)       |
          (PIN_TDO_IN()       << DAP_SWJ_TDO)       |
          (PIN_nTRST_IN()     << DAP_SWJ_nTRST)     |
          (PIN_nRESET_IN()    << DAP_SWJ_nRESET);

  *response = (uint8_t)value;
#else
  *response = 0U;
#endif

  return ((6U << 16) | 1U);
}

// Process SWJ Clock command and prepare response
//   request:  pointer to request data
//   response: pointer to response data
//   return:   number of bytes in response (lower 16 bits)
//             number of bytes in request (upper 16 bits)
static uint32_t DAP_SWJ_Clock(const uint8_t *request, uint8_t *response) {
#if ((DAP_SWD != 0) || (DAP_JTAG != 0))
  uint32_t clock;
  uint32_t delay;

  clock = (*(request+0) <<  0) |
          (*(request+1) <<  8) |
          (*(request+2) << 16) |
          (*(request+3) << 24);

  if (clock == 0U) {
    *response = DAP_ERROR;
    return ((4U << 16) | 1U);
  }

  if (clock >= MAX_SWJ_CLOCK(DELAY_FAST_CYCLES)) {
    DAP_Data.fast_clock  = 1U;
    DAP_Data.clock_delay = 1U;
  } else {
    DAP_Data.fast_clock  = 0U;

    delay = ((CPU_CLOCK/2U) + (clock - 1U)) / clock;
    if (delay > IO_PORT_WRITE_CYCLES) {
      delay -= IO_PORT_WRITE_CYCLES;
      delay  = (delay + (DELAY_SLOW_CYCLES - 1U)) / DELAY_SLOW_CYCLES;
    } else {
      delay  = 1U;
    }

    DAP_Data.clock_delay = delay;
  }

  *response = DAP_OK;
#else
  *response = DAP_ERROR;
#endif

  return ((4U << 16) | 1U);
}

// Process SWJ Sequence command and prepare response
//   request:  pointer to request data
//   response: pointer to response data
//   return:   number of bytes in response (lower 16 bits)
//             number of bytes in request (upper 16 bits)
static uint32_t DAP_SWJ_Sequence(const uint8_t *request, uint8_t *response) {
  uint32_t count;

  count = *request++;
  if (count == 0U) { count = 256U; }

#if ((DAP_SWD != 0) || (DAP_JTAG != 0))
  SWJ_Sequence(count, request);
  *response = DAP_OK;
#else
  *response = DAP_ERROR;
#endif

  count = (count + 7U) >> 3;

  return (((uint16_t)(count + 1U) << 16) | 1U);
}

// Process SWD Configure command and prepare response
//   request:  pointer to request data
//   response: pointer to response data
//   return:   number of bytes in response (lower 16 bits)
//             number of bytes in request (upper 16 bits)
static uint32_t DAP_SWD_Configure(const uint8_t *request, uint8_t *response) {
#if (DAP_SWD != 0)
  uint8_t value;

  value = *request;
  DAP_Data.swd_conf.turnaround = (value & 0x03U) + 1U;
  DAP_Data.swd_conf.data_phase = (value & 0x04U) ? 1U : 0U;

  *response = DAP_OK;
#else
  *response = DAP_ERROR;
#endif

  return ((1U << 16) | 1U);
}

// Process JTAG Sequence command and prepare response
//   request:  pointer to request data
//   response: pointer to response data
//   return:   number of bytes in response (lower 16 bits)
//             number of bytes in request (upper 16 bits)
static uint32_t DAP_JTAG_Sequence(const uint8_t *request, uint8_t *response) {
  uint32_t sequence_info;
  uint32_t sequence_count;
  uint32_t request_count;
  uint32_t response_count;
  uint32_t count;

#if (DAP_JTAG != 0)
  *response++ = DAP_OK;
#else
  *response++ = DAP_ERROR;
#endif
  request_count  = 1U;
  response_count = 1U;

  sequence_count = *request++;
  while (sequence_count--) {
    sequence_info = *request++;
#if (DAP_JTAG != 0)
    JTAG_Sequence(sequence_info, request, response);
#endif
    count = sequence_info & JTAG_SEQUENCE_TCK;
    if (count == 0U) { count = 64U; }
    count = (count + 7U) / 8U;
    request += count;
    request_count += count + 1U;
#if (DAP_JTAG != 0)
    if (sequence_info & JTAG_SEQUENCE_TDO) {
      response += count;
      response_count += count;
    }
#endif
  }

  return (((uint16_t)request_count << 16) | (uint16_t)response_count);
}

// Process JTAG Configure command and prepare response
//   request:  pointer to request data
//   response: pointer to response data
//   return:   number of bytes in response (lower 16 bits)
//             number of bytes in request (upper 16 bits)
static uint32_t DAP_JTAG_Configure(const uint8_t *request, uint8_t *response) {
  uint32_t count;
#if (DAP_JTAG != 0)
  uint32_t length;
  uint32_t bits;
  uint32_t n;

  count = *request++;
  DAP_Data.jtag_dev.count = (uint8_t)count;

  bits = 0U;
  for (n = 0U; n < count; n++) {
    length = *request++;
    DAP_Data.jtag_dev.ir_length[n] =  (uint8_t)length;
    DAP_Data.jtag_dev.ir_before[n] = (uint16_t)bits;
    bits += length;
  }
  for (n = 0U; n < count; n++) {
    bits -= DAP_Data.jtag_dev.ir_length[n];
    DAP_Data.jtag_dev.ir_after[n] = (uint16_t)bits;
  }

  *response = DAP_OK;
#else
  count = *request;
  *response = DAP_ERROR;
#endif

  return (((uint16_t)(count + 1U) << 16) | 1U);
}

// Process JTAG IDCODE command and prepare response
//   request:  pointer to request data
//   response: pointer to response data
//   return:   number of bytes in response (lower 16 bits)
//             number of bytes in request (upper 16 bits)
static uint32_t DAP_JTAG_IDCode(const uint8_t *request, uint8_t *response) {
#if (DAP_JTAG != 0)
  uint32_t data;

  if (DAP_Data.debug_port != DAP_PORT_JTAG) {
    goto id_error;
  }

  // Device index (JTAP TAP)
  DAP_Data.jtag_dev.index = *request;
  if (DAP_Data.jtag_dev.index >= DAP_Data.jtag_dev.count) {
    goto id_error;
  }

  // Select JTAG chain
  JTAG_IR(JTAG_IDCODE);

  // Read IDCODE register
  data = JTAG_ReadIDCode();

  // Store Data
  *(response+0) =  DAP_OK;
  *(response+1) = (uint8_t)(data >>  0);
  *(response+2) = (uint8_t)(data >>  8);
  *(response+3) = (uint8_t)(data >> 16);
  *(response+4) = (uint8_t)(data >> 24);

  return ((1U << 16) | 5U);

id_error:
#endif
  *response = DAP_ERROR;
  return ((1U << 16) | 1U);
}

// Process Transfer Configure command and prepare response
//   request:  pointer to request data
//   response: pointer to response data
//   return:   number of bytes in response (lower 16 bits)
//             number of bytes in request (upper 16 bits)
static uint32_t DAP_TransferConfigure(const uint8_t *request, uint8_t *response) {

  DAP_Data.transfer.idle_cycles = *(request+0);
  DAP_Data.transfer.retry_count = *(request+1) | (*(request+2) << 8);
  DAP_Data.transfer.match_retry = *(request+3) | (*(request+4) << 8);

  *response = DAP_OK;
  return ((5U << 16) | 1U);
}

// Process SWD Transfer command and prepare response
//   request:  pointer to request data
//   response: pointer to response data
//   return:   number of bytes in response (lower 16 bits)
//             number of bytes in request (upper 16 bits)
#if (DAP_SWD != 0)
static uint32_t DAP_SWD_Transfer(const uint8_t *request, uint8_t *response) {
  const
  uint8_t  *request_head;
  uint32_t  request_count;
  uint32_t  request_value;
  uint8_t  *response_head;
  uint32_t  response_count;
  uint32_t  response_value;
  uint32_t  post_read;
  uint32_t  check_write;
  uint32_t  match_value;
  uint32_t  match_retry;
  uint32_t  retry;
  uint32_t  data;

  request_head   = request;

  response_count = 0U;
  response_value = 0U;
  response_head  = response;
  response      += 2;

  DAP_TransferAbort = 0U;

  post_read   = 0U;
  check_write = 0U;

  request++;            // Ignore DAP index

  request_count = *request++;

  for (; request_count; request_count--) {
    request_value = *request++;
    if (request_value & DAP_TRANSFER_RnW) {
      // Read register
      if (post_read) {
        // Read was posted before
        retry = DAP_Data.transfer.retry_count;
        if ((request_value & (DAP_TRANSFER_APnDP | DAP_TRANSFER_MATCH_VALUE)) == DAP_TRANSFER_APnDP) {
          // Read previous AP data and post next AP read
          do {
            response_value = SWD_Transfer(request_value, &data);
          } while ((response_value == DAP_TRANSFER_WAIT) && retry-- && !DAP_TransferAbort);
        } else {
          // Read previous AP data
          do {
            response_value = SWD_Transfer(DP_RDBUFF | DAP_TRANSFER_RnW, &data);
          } while ((response_value == DAP_TRANSFER_WAIT) && retry-- && !DAP_TransferAbort);
          post_read = 0U;
        }
        if (response_value != DAP_TRANSFER_OK) { break; }
        // Store previous AP data
        *response++ = (uint8_t) data;
        *response++ = (uint8_t)(data >>  8);
        *response++ = (uint8_t)(data >> 16);
        *response++ = (uint8_t)(data >> 24);
      }
      if (request_value & DAP_TRANSFER_MATCH_VALUE) {
        // Read with value match
        match_value = (*(request+0) <<  0) |
                      (*(request+1) <<  8) |
                      (*(request+2) << 16) |
                      (*(request+3) << 24);
        request += 4;
        match_retry = DAP_Data.transfer.match_retry;
        if (request_value & DAP_TRANSFER_APnDP) {
          // Post AP read
          retry = DAP_Data.transfer.retry_count;
          do {
            response_value = SWD_Transfer(request_value, NULL);
          } while ((response_value == DAP_TRANSFER_WAIT) && retry-- && !DAP_TransferAbort);
          if (response_value != DAP_TRANSFER_OK) { break; }
        }
        do {
          // Read register until its value matches or retry counter expires
          retry = DAP_Data.transfer.retry_count;
          do {
            response_value = SWD_Transfer(request_value, &data);
          } while ((response_value == DAP_TRANSFER_WAIT) && retry-- && !DAP_TransferAbort);
          if (response_value != DAP_TRANSFER_OK) { break; }
        } while (((data & DAP_Data.transfer.match_mask) != match_value) && match_retry-- && !DAP_TransferAbort);
        if ((data & DAP_Data.transfer.match_mask) != match_value) {
          response_value |= DAP_TRANSFER_MISMATCH;
        }
        if (response_value != DAP_TRANSFER_OK) { break; }
      } else {
        // Normal read
        retry = DAP_Data.transfer.retry_count;
        if (request_value & DAP_TRANSFER_APnDP) {
          // Read AP register
          if (post_read == 0U) {
            // Post AP read
            do {
              response_value = SWD_Transfer(request_value, NULL);
            } while ((response_value == DAP_TRANSFER_WAIT) && retry-- && !DAP_TransferAbort);
            if (response_value != DAP_TRANSFER_OK) { break; }
            post_read = 1U;
          }
        } else {
          // Read DP register
          do {
            response_value = SWD_Transfer(request_value, &data);
          } while ((response_value == DAP_TRANSFER_WAIT) && retry-- && !DAP_TransferAbort);
          if (response_value != DAP_TRANSFER_OK) { break; }
          // Store data
          *response++ = (uint8_t) data;
          *response++ = (uint8_t)(data >>  8);
          *response++ = (uint8_t)(data >> 16);
          *response++ = (uint8_t)(data >> 24);
        }
      }
      check_write = 0U;
    } else {
      // Write register
      if (post_read) {
        // Read previous data
        retry = DAP_Data.transfer.retry_count;
        do {
          response_value = SWD_Transfer(DP_RDBUFF | DAP_TRANSFER_RnW, &data);
        } while ((response_value == DAP_TRANSFER_WAIT) && retry-- && !DAP_TransferAbort);
        if (response_value != DAP_TRANSFER_OK) { break; }
        // Store previous data
        *response++ = (uint8_t) data;
        *response++ = (uint8_t)(data >>  8);
        *response++ = (uint8_t)(data >> 16);
        *response++ = (uint8_t)(data >> 24);
        post_read = 0U;
      }
      // Load data
      data = (*(request+0) <<  0) |
             (*(request+1) <<  8) |
             (*(request+2) << 16) |
             (*(request+3) << 24);
      request += 4;
      if (request_value & DAP_TRANSFER_MATCH_MASK) {
        // Write match mask
        DAP_Data.transfer.match_mask = data;
        response_value = DAP_TRANSFER_OK;
      } else {
        // Write DP/AP register
        retry = DAP_Data.transfer.retry_count;
        do {
          response_value = SWD_Transfer(request_value, &data);
        } while ((response_value == DAP_TRANSFER_WAIT) && retry-- && !DAP_TransferAbort);
        if (response_value != DAP_TRANSFER_OK) { break; }
        check_write = 1U;
      }
    }
    response_count++;
    if (DAP_TransferAbort) { break; }
  }

  for (; request_count; request_count--) {
    // Process canceled requests
    request_value = *request++;
    if (request_value & DAP_TRANSFER_RnW) {
      // Read register
      if (request_value & DAP_TRANSFER_MATCH_VALUE) {
        // Read with value match
        request += 4;
      }
    } else {
      // Write register
      request += 4;
    }
  }

  if (response_value == DAP_TRANSFER_OK) {
    if (post_read) {
      // Read previous data
      retry = DAP_Data.transfer.retry_count;
      do {
        response_value = SWD_Transfer(DP_RDBUFF | DAP_TRANSFER_RnW, &data);
      } while ((response_value == DAP_TRANSFER_WAIT) && retry-- && !DAP_TransferAbort);
      if (response_value != DAP_TRANSFER_OK) { goto end; }
      // Store previous data
      *response++ = (uint8_t) data;
      *response++ = (uint8_t)(data >>  8);
      *response++ = (uint8_t)(data >> 16);
      *response++ = (uint8_t)(data >> 24);
    } else if (check_write) {
      // Check last write
      retry = DAP_Data.transfer.retry_count;
      do {
        response_value = SWD_Transfer(DP_RDBUFF | DAP_TRANSFER_RnW, NULL);
      } while ((response_value == DAP_TRANSFER_WAIT) && retry-- && !DAP_TransferAbort);
    }
  }

end:
  *(response_head+0) = (uint8_t)response_count;
  *(response_head+1) = (uint8_t)response_value;

  return (((request - request_head) << 16) | (response - response_head));
}
#endif

// Process JTAG Transfer command and prepare response
//   request:  pointer to request data
//   response: pointer to response data
//   return:   number of bytes in response (lower 16 bits)
//             number of bytes in request (upper 16 bits)
#if (DAP_JTAG != 0)
static uint32_t DAP_JTAG_Transfer(const uint8_t *request, uint8_t *response) {
  const
  uint8_t  *request_head;
  uint32_t  request_count;
  uint32_t  request_value;
  uint32_t  request_ir;
  uint8_t  *response_head;
  uint32_t  response_count;
  uint32_t  response_value;
  uint32_t  post_read;
  uint32_t  match_value;
  uint32_t  match_retry;
  uint32_t  retry;
  uint32_t  data;
  uint32_t  ir;

  request_head   = request;

  response_count = 0U;
  response_value = 0U;
  response_head  = response;
  response      += 2;

  DAP_TransferAbort = 0U;

  ir        = 0U;
  post_read = 0U;

  // Device index (JTAP TAP)
  DAP_Data.jtag_dev.index = *request++;
  if (DAP_Data.jtag_dev.index >= DAP_Data.jtag_dev.count) { goto end; }

  request_count = *request++;

  for (; request_count; request_count--) {
    request_value = *request++;
    request_ir = (request_value & DAP_TRANSFER_APnDP) ? JTAG_APACC : JTAG_DPACC;
    if (request_value & DAP_TRANSFER_RnW) {
      // Read register
      if (post_read) {
        // Read was posted before
        retry = DAP_Data.transfer.retry_count;
        if ((ir == request_ir) && ((request_value & DAP_TRANSFER_MATCH_VALUE) == 0U)) {
          // Read previous data and post next read
          do {
            response_value = JTAG_Transfer(request_value, &data);
          } while ((response_value == DAP_TRANSFER_WAIT) && retry-- && !DAP_TransferAbort);
        } else {
          // Select JTAG chain
          if (ir != JTAG_DPACC) {
            ir = JTAG_DPACC;
            JTAG_IR(ir);
          }
          // Read previous data
          do {
            response_value = JTAG_Transfer(DP_RDBUFF | DAP_TRANSFER_RnW, &data);
          } while ((response_value == DAP_TRANSFER_WAIT) && retry-- && !DAP_TransferAbort);
          post_read = 0U;
        }
        if (response_value != DAP_TRANSFER_OK) { break; }
        // Store previous data
        *response++ = (uint8_t) data;
        *response++ = (uint8_t)(data >>  8);
        *response++ = (uint8_t)(data >> 16);
        *response++ = (uint8_t)(data >> 24);
      }
      if (request_value & DAP_TRANSFER_MATCH_VALUE) {
        // Read with value match
        match_value = (*(request+0) <<  0) |
                      (*(request+1) <<  8) |
                      (*(request+2) << 16) |
                      (*(request+3) << 24);
        request += 4;
        match_retry  = DAP_Data.transfer.match_retry;
        // Select JTAG chain
        if (ir != request_ir) {
          ir = request_ir;
          JTAG_IR(ir);
        }
        // Post DP/AP read
        retry = DAP_Data.transfer.retry_count;
        do {
          response_value = JTAG_Transfer(request_value, NULL);
        } while ((response_value == DAP_TRANSFER_WAIT) && retry-- && !DAP_TransferAbort);
        if (response_value != DAP_TRANSFER_OK) { break; }
        do {
          // Read register until its value matches or retry counter expires
          retry = DAP_Data.transfer.retry_count;
          do {
            response_value = JTAG_Transfer(request_value, &data);
          } while ((response_value == DAP_TRANSFER_WAIT) && retry-- && !DAP_TransferAbort);
          if (response_value != DAP_TRANSFER_OK) { break; }
        } while (((data & DAP_Data.transfer.match_mask) != match_value) && match_retry-- && !DAP_TransferAbort);
        if ((data & DAP_Data.transfer.match_mask) != match_value) {
          response_value |= DAP_TRANSFER_MISMATCH;
        }
        if (response_value != DAP_TRANSFER_OK) { break; }
      } else {
        // Normal read
        if (post_read == 0U) {
          // Select JTAG chain
          if (ir != request_ir) {
            ir = request_ir;
            JTAG_IR(ir);
          }
          // Post DP/AP read
          retry = DAP_Data.transfer.retry_count;
          do {
            response_value = JTAG_Transfer(request_value, NULL);
          } while ((response_value == DAP_TRANSFER_WAIT) && retry-- && !DAP_TransferAbort);
          if (response_value != DAP_TRANSFER_OK) { break; }
          post_read = 1U;
        }
      }
    } else {
      // Write register
      if (post_read) {
        // Select JTAG chain
        if (ir != JTAG_DPACC) {
          ir = JTAG_DPACC;
          JTAG_IR(ir);
        }
        // Read previous data
        retry = DAP_Data.transfer.retry_count;
        do {
          response_value = JTAG_Transfer(DP_RDBUFF | DAP_TRANSFER_RnW, &data);
        } while ((response_value == DAP_TRANSFER_WAIT) && retry-- && !DAP_TransferAbort);
        if (response_value != DAP_TRANSFER_OK) { break; }
        // Store previous data
        *response++ = (uint8_t) data;
        *response++ = (uint8_t)(data >>  8);
        *response++ = (uint8_t)(data >> 16);
        *response++ = (uint8_t)(data >> 24);
        post_read = 0U;
      }
      // Load data
      data = (*(request+0) <<  0) |
             (*(request+1) <<  8) |
             (*(request+2) << 16) |
             (*(request+3) << 24);
      request += 4;
      if (request_value & DAP_TRANSFER_MATCH_MASK) {
        // Write match mask
        DAP_Data.transfer.match_mask = data;
        response_value = DAP_TRANSFER_OK;
      } else {
        // Select JTAG chain
        if (ir != request_ir) {
          ir = request_ir;
          JTAG_IR(ir);
        }
        // Write DP/AP register
        retry = DAP_Data.transfer.retry_count;
        do {
          response_value = JTAG_Transfer(request_value, &data);
        } while ((response_value == DAP_TRANSFER_WAIT) && retry-- && !DAP_TransferAbort);
        if (response_value != DAP_TRANSFER_OK) { break; }
      }
    }
    response_count++;
    if (DAP_TransferAbort) { break; }
  }

  for (; request_count; request_count--) {
    // Process canceled requests
    request_value = *request++;
    if (request_value & DAP_TRANSFER_RnW) {
      // Read register
      if (request_value & DAP_TRANSFER_MATCH_VALUE) {
        // Read with value match
        request += 4;
      }
    } else {
      // Write register
      request += 4;
    }
  }

  if (response_value == DAP_TRANSFER_OK) {
    // Select JTAG chain
    if (ir != JTAG_DPACC) {
      ir = JTAG_DPACC;
      JTAG_IR(ir);
    }
    if (post_read) {
      // Read previous data
      retry = DAP_Data.transfer.retry_count;
      do {
        response_value = JTAG_Transfer(DP_RDBUFF | DAP_TRANSFER_RnW, &data);
      } while ((response_value == DAP_TRANSFER_WAIT) && retry-- && !DAP_TransferAbort);
      if (response_value != DAP_TRANSFER_OK) { goto end; }
      // Store previous data
      *response++ = (uint8_t) data;
      *response++ = (uint8_t)(data >>  8);
      *response++ = (uint8_t)(data >> 16);
      *response++ = (uint8_t)(data >> 24);
    } else {
      // Check last write
      retry = DAP_Data.transfer.retry_count;
      do {
        response_value = JTAG_Transfer(DP_RDBUFF | DAP_TRANSFER_RnW, NULL);
      } while ((response_value == DAP_TRANSFER_WAIT) && retry-- && !DAP_TransferAbort);
    }
  }

end:
  *(response_head+0) = (uint8_t)response_count;
  *(response_head+1) = (uint8_t)response_value;

  return (((request - request_head) << 16) | (response - response_head));
}
#endif

// Process Dummy Transfer command and prepare response
//   request:  pointer to request data
//   response: pointer to response data
//   return:   number of bytes in response (lower 16 bits)
//             number of bytes in request (upper 16 bits)
static uint32_t DAP_Dummy_Transfer(const uint8_t *request, uint8_t *response) {
  const
  uint8_t  *request_head;
  uint32_t  request_count;
  uint32_t  request_value;

  request_head  =  request;

  request++;            // Ignore DAP index

  request_count = *request++;

  for (; request_count; request_count--) {
    // Process dummy requests
    request_value = *request++;
    if (request_value & DAP_TRANSFER_RnW) {
      // Read register
      if (request_value & DAP_TRANSFER_MATCH_VALUE) {
        // Read with value match
        request += 4;
      }
    } else {
      // Write register
      request += 4;
    }
  }

  *(response+0) = 0U;   // Response count
  *(response+1) = 0U;   // Response value

  return (((request - request_head) << 16) | 2U);
}

// Process Transfer command and prepare response
//   request:  pointer to request data
//   response: pointer to response data
//   return:   number of bytes in response (lower 16 bits)
//             number of bytes in request (upper 16 bits)
static uint32_t DAP_Transfer(const uint8_t *request, uint8_t *response) {
  uint32_t num;

  switch (DAP_Data.debug_port) {
#if (DAP_SWD != 0)
    case DAP_PORT_SWD:
      num = DAP_SWD_Transfer(request, response);
      break;
#endif
#if (DAP_JTAG != 0)
    case DAP_PORT_JTAG:
      num = DAP_JTAG_Transfer(request, response);
      break;
#endif
    default:
      num = DAP_Dummy_Transfer(request, response);
      break;
  }

  return (num);
}

// Process SWD Transfer Block command and prepare response
//   request:  pointer to request data
//   response: pointer to response data
//   return:   number of bytes in response
#if (DAP_SWD != 0)
static uint32_t DAP_SWD_TransferBlock(const uint8_t *request, uint8_t *response) {
  uint32_t  request_count;
  uint32_t  request_value;
  uint32_t  response_count;
  uint32_t  response_value;
  uint8_t  *response_head;
  uint32_t  retry;
  uint32_t  data;

  response_count = 0U;
  response_value = 0U;
  response_head  = response;
  response      += 3;

  DAP_TransferAbort = 0U;

  request++;            // Ignore DAP index

  request_count = *request | (*(request+1) << 8);
  request += 2;
  if (request_count == 0U) { goto end; }

  request_value = *request++;
  if (request_value & DAP_TRANSFER_RnW) {
    // Read register block
    if (request_value & DAP_TRANSFER_APnDP) {
      // Post AP read
      retry = DAP_Data.transfer.retry_count;
      do {
        response_value = SWD_Transfer(request_value, NULL);
      } while ((response_value == DAP_TRANSFER_WAIT) && retry-- && !DAP_TransferAbort);
      if (response_value != DAP_TRANSFER_OK) { goto end; }
    }
    while (request_count--) {
      // Read DP/AP register
      if ((request_count == 0U) && (request_value & DAP_TRANSFER_APnDP)) {
        // Last AP read
        request_value = DP_RDBUFF | DAP_TRANSFER_RnW;
      }
      retry = DAP_Data.transfer.retry_count;
      do {
        response_value = SWD_Transfer(request_value, &data);
      } while ((response_value == DAP_TRANSFER_WAIT) && retry-- && !DAP_TransferAbort);
      if (response_value != DAP_TRANSFER_OK) { goto end; }
      // Store data
      *response++ = (uint8_t) data;
      *response++ = (uint8_t)(data >>  8);
      *response++ = (uint8_t)(data >> 16);
      *response++ = (uint8_t)(data >> 24);
      response_count++;
    }
  } else {
    // Write register block
    while (request_count--) {
      // Load data
      data = (*(request+0) <<  0) |
             (*(request+1) <<  8) |
             (*(request+2) << 16) |
             (*(request+3) << 24);
      request += 4;
      // Write DP/AP register
      retry = DAP_Data.transfer.retry_count;
      do {
        response_value = SWD_Transfer(request_value, &data);
      } while ((response_value == DAP_TRANSFER_WAIT) && retry-- && !DAP_TransferAbort);
      if (response_value != DAP_TRANSFER_OK) { goto end; }
      response_count++;
    }
    // Check last write
    retry = DAP_Data.transfer.retry_count;
    do {
      response_value = SWD_Transfer(DP_RDBUFF | DAP_TRANSFER_RnW, NULL);
    } while ((response_value == DAP_TRANSFER_WAIT) && retry-- && !DAP_TransferAbort);
  }

end:
  *(response_head+0) = (uint8_t)(response_count >> 0);
  *(response_head+1) = (uint8_t)(response_count >> 8);
  *(response_head+2) = (uint8_t) response_value;

  return (response - response_head);
}
#endif

// Process JTAG Transfer Block command and prepare response
//   request:  pointer to request data
//   response: pointer to response data
//   return:   number of bytes in response
#if (DAP_JTAG != 0)
static uint32_t DAP_JTAG_TransferBlock(const uint8_t *request, uint8_t *response) {
  uint32_t  request_count;
  uint32_t  request_value;
  uint32_t  response_count;
  uint32_t  response_value;
  uint8_t  *response_head;
  uint32_t  retry;
  uint32_t  data;
  uint32_t  ir;

  response_count = 0U;
  response_value = 0U;
  response_head  = response;
  response      += 3;

  DAP_TransferAbort = 0U;

  // Device index (JTAP TAP)
  DAP_Data.jtag_dev.index = *request++;
  if (DAP_Data.jtag_dev.index >= DAP_Data.jtag_dev.count) { goto end; }

  request_count = *request | (*(request+1) << 8);
  request += 2;
  if (request_count == 0U) { goto end; }

  request_value = *request++;

  // Select JTAG chain
  ir = (request_value & DAP_TRANSFER_APnDP) ? JTAG_APACC : JTAG_DPACC;
  JTAG_IR(ir);

  if (request_value & DAP_TRANSFER_RnW) {
    // Post read
    retry = DAP_Data.transfer.retry_count;
    do {
      response_value = JTAG_Transfer(request_value, NULL);
    } while ((response_value == DAP_TRANSFER_WAIT) && retry-- && !DAP_TransferAbort);
    if (response_value != DAP_TRANSFER_OK) { goto end; }
    // Read register block
    while (request_count--) {
      // Read DP/AP register
      if (request_count == 0U) {
        // Last read
        if (ir != JTAG_DPACC) {
          JTAG_IR(JTAG_DPACC);
        }
        request_value = DP_RDBUFF | DAP_TRANSFER_RnW;
      }
      retry = DAP_Data.transfer.retry_count;
      do {
        response_value = JTAG_Transfer(request_value, &data);
      } while ((response_value == DAP_TRANSFER_WAIT) && retry-- && !DAP_TransferAbort);
      if (response_value != DAP_TRANSFER_OK) { goto end; }
      // Store data
      *response++ = (uint8_t) data;
      *response++ = (uint8_t)(data >>  8);
      *response++ = (uint8_t)(data >> 16);
      *response++ = (uint8_t)(data >> 24);
      response_count++;
    }
  } else {
    // Write register block
    while (request_count--) {
      // Load data
      data = (*(request+0) <<  0) |
             (*(request+1) <<  8) |
             (*(request+2) << 16) |
             (*(request+3) << 24);
      request += 4;
      // Write DP/AP register
      retry = DAP_Data.transfer.retry_count;
      do {
        response_value = JTAG_Transfer(request_value, &data);
      } while ((response_value == DAP_TRANSFER_WAIT) && retry-- && !DAP_TransferAbort);
      if (response_value != DAP_TRANSFER_OK) { goto end; }
      response_count++;
    }
    // Check last write
    if (ir != JTAG_DPACC) {
      JTAG_IR(JTAG_DPACC);
    }
    retry = DAP_Data.transfer.retry_count;
    do {
      response_value = JTAG_Transfer(DP_RDBUFF | DAP_TRANSFER_RnW, NULL);
    } while ((response_value == DAP_TRANSFER_WAIT) && retry-- && !DAP_TransferAbort);
  }

end:
  *(response_head+0) = (uint8_t)(response_count >> 0);
  *(response_head+1) = (uint8_t)(response_count >> 8);
  *(response_head+2) = (uint8_t) response_value;

  return (response - response_head);
}
#endif

// Process Transfer Block command and prepare response
//   request:  pointer to request data
//   response: pointer to response data
//   return:   number of bytes in response (lower 16 bits)
//             number of bytes in request (upper 16 bits)
static uint32_t DAP_TransferBlock(const uint8_t *request, uint8_t *response) {
  uint32_t num;

  switch (DAP_Data.debug_port) {
#if (DAP_SWD != 0)
    case DAP_PORT_SWD:
      num = DAP_SWD_TransferBlock (request, response);
      break;
#endif
#if (DAP_JTAG != 0)
    case DAP_PORT_JTAG:
      num = DAP_JTAG_TransferBlock(request, response);
      break;
#endif
    default:
      *(response+0) = 0U;       // Response count [7:0]
      *(response+1) = 0U;       // Response count[15:8]
      *(response+2) = 0U;       // Response value
      num = 3U;
  }

  if (*(request+3) & DAP_TRANSFER_RnW) {
    // Read register block
    num |=  4U << 16;
  } else {
    // Write register block
    num |= (4U + ((*(request+1) | (*(request+2) << 8)) * 4)) << 16;
  }

  return (num);
}

// Process SWD Write ABORT command and prepare response
//   request:  pointer to request data
//   response: pointer to response data
//   return:   number of bytes in response
#if (DAP_SWD != 0)
static uint32_t DAP_SWD_WriteAbort(const uint8_t *request, uint8_t *response) {
  uint32_t data;

  // Load data (Ignore DAP index)
  data = (*(request+1) <<  0) |
         (*(request+2) <<  8) |
         (*(request+3) << 16) |
         (*(request+4) << 24);

  // Write Abort register
  SWD_Transfer(DP_ABORT, &data);

  *response = DAP_OK;
  return (1U);
}
#endif

// Process JTAG Write ABORT command and prepare response
//   request:  pointer to request data
//   response: pointer to response data
//   return:   number of bytes in response
#if (DAP_JTAG != 0)
static uint32_t DAP_JTAG_WriteAbort(const uint8_t *request, uint8_t *response) {
  uint32_t data;

  // Device index (JTAP TAP)
  DAP_Data.jtag_dev.index = *request;
  if (DAP_Data.jtag_dev.index >= DAP_Data.jtag_dev.count) {
    *response = DAP_ERROR;
    return (1U);
  }

  // Select JTAG chain
  JTAG_IR(JTAG_ABORT);

  // Load data
  data = (*(request+1) <<  0) |
         (*(request+2) <<  8) |
         (*(request+3) << 16) |
         (*(request+4) << 24);

  // Write Abort register
  JTAG_WriteAbort(data);

  *response = DAP_OK;
  return (1U);
}
#endif

// Process Write ABORT command and prepare response
//   request:  pointer to request data
//   response: pointer to response data
//   return:   number of bytes in response (lower 16 bits)
//             number of bytes in request (upper 16 bits)
static uint32_t DAP_WriteAbort(const uint8_t *request, uint8_t *response) {
  uint32_t num;

  switch (DAP_Data.debug_port) {
#if (DAP_SWD != 0)
    case DAP_PORT_SWD:
      num = DAP_SWD_WriteAbort (request, response);
      break;
#endif
#if (DAP_JTAG != 0)
    case DAP_PORT_JTAG:
      num = DAP_JTAG_WriteAbort(request, response);
      break;
#endif
    default:
      *response = DAP_ERROR;
      num = 1U;
  }
  return ((5U << 16) | num);
}

// Process DAP Vendor command request and prepare response
// Default function (can be overridden)
//   request:  pointer to request data
//   response: pointer to response data
//   return:   number of bytes in response (lower 16 bits)
//             number of bytes in request (upper 16 bits)
__weak uint32_t DAP_ProcessVendorCommand(const uint8_t *request, uint8_t *response) {
  *response = ID_DAP_Invalid;
  return ((1U << 16) | 1U);
}

// Process DAP command request and prepare response
//   request:  pointer to request data
//   response: pointer to response data
//   return:   number of bytes in response (lower 16 bits)
//             number of bytes in request (upper 16 bits)
uint32_t DAP_ProcessCommand(const uint8_t *request, uint8_t *response) {
  uint32_t num;

  if ((*request >= ID_DAP_Vendor0) && (*request <= ID_DAP_Vendor31)) {
    return DAP_ProcessVendorCommand(request, response);
  }

  *response++ = *request;

  switch (*request++) {
    case ID_DAP_Info:
      num = DAP_Info(*request, response+1);
      *response = (uint8_t)num;
      return ((2U << 16) + 2U + num);

    case ID_DAP_HostStatus:
      num = DAP_HostStatus(request, response);
      break;

    case ID_DAP_Connect:
      num = DAP_Connect(request, response);
      break;
    case ID_DAP_Disconnect:
      num = DAP_Disconnect(response);
      break;

    case ID_DAP_Delay:
      num = DAP_Delay(request, response);
      break;

    case ID_DAP_ResetTarget:
      num = DAP_ResetTarget(response);
      break;

    case ID_DAP_SWJ_Pins:
      num = DAP_SWJ_Pins(request, response);
      break;
    case ID_DAP_SWJ_Clock:
      num = DAP_SWJ_Clock(request, response);
      break;
    case ID_DAP_SWJ_Sequence:
      num = DAP_SWJ_Sequence(request, response);
      break;

    case ID_DAP_SWD_Configure:
      num = DAP_SWD_Configure(request, response);
      break;

    case ID_DAP_JTAG_Sequence:
      num = DAP_JTAG_Sequence(request, response);
      break;
    case ID_DAP_JTAG_Configure:
      num = DAP_JTAG_Configure(request, response);
      break;
    case ID_DAP_JTAG_IDCODE:
      num = DAP_JTAG_IDCode(request, response);
      break;

    case ID_DAP_TransferConfigure:
      num = DAP_TransferConfigure(request, response);
      break;
    case ID_DAP_Transfer:
      num = DAP_Transfer(request, response);
      break;
    case ID_DAP_TransferBlock:
      num = DAP_TransferBlock(request, response);
      break;

    case ID_DAP_WriteABORT:
      num = DAP_WriteAbort(request, response);
      break;

#if ((SWO_UART != 0) || (SWO_MANCHESTER != 0))
    case ID_DAP_SWO_Transport:
      num = SWO_Transport(request, response);
      break;
    case ID_DAP_SWO_Mode:
      num = SWO_Mode(request, response);
      break;
    case ID_DAP_SWO_Baudrate:
      num = SWO_Baudrate(request, response);
      break;
    case ID_DAP_SWO_Control:
      num = SWO_Control(request, response);
      break;
    case ID_DAP_SWO_Status:
      num = SWO_Status(response);
      break;
    case ID_DAP_SWO_Data:
      num = SWO_Data(request, response);
      break;
#endif

    default:
      *(response-1) = ID_DAP_Invalid;
      return ((1U << 16) | 1U);
  }

  return ((1U << 16) + 1U + num);
}

// Execute DAP command (process request and prepare response)
//   request:  pointer to request data
//   response: pointer to response data
//   return:   number of bytes in response (lower 16 bits)
//             number of bytes in request (upper 16 bits)
uint32_t DAP_ExecuteCommand(const uint8_t *request, uint8_t *response) {
  uint32_t cnt, num, n;

  if (*request == ID_DAP_ExecuteCommands) {
    *response++ = *request++;
    cnt = *request++;
    *response++ = (uint8_t)cnt;
    num = (2U << 16) | 2U;
    while (cnt--) {
      n = DAP_ProcessCommand(request, response);
      num += n;
      request  += (uint16_t)(n >> 16);
      response += (uint16_t) n;
    }
    return (num);
  }

  return DAP_ProcessCommand(request, response);
}

// Setup DAP
void DAP_Setup(void) {

  // Default settings
  DAP_Data.debug_port  = 0U;
  DAP_Data.fast_clock  = 0U;
  DAP_Data.clock_delay = CLOCK_DELAY(DAP_DEFAULT_SWJ_CLOCK);
  DAP_Data.transfer.idle_cycles = 0U;
  DAP_Data.transfer.retry_count = 100U;
  DAP_Data.transfer.match_retry = 0U;
  DAP_Data.transfer.match_mask  = 0x00000000U;
#if (DAP_SWD != 0)
  DAP_Data.swd_conf.turnaround  = 1U;
  DAP_Data.swd_conf.data_phase  = 0U;
#endif
#if (DAP_JTAG != 0)
  DAP_Data.jtag_dev.count = 0U;
#endif

  DAP_SETUP();  // Device specific setup
}

redpajama_set_name: RedPajamaGithub


The root of the English word "beatitude" is "beauty." The Greek term kalos implies attractiveness -- literally, an attraction toward divine beauty.
In the first book of the Bible, beauty is central. We learn how God made the world as a "very good" creation (Gen. 1: 31) -- a beautiful cosmos. And in the first Gospel, the protoevangelion of the Christian scriptural canon, Matthew opens his very first verse by describing the message that he wishes to convey as "a book of genesis." By so doing, Matthew is being faithful to Genesis as an archetype of God's message or purpose for the world.
In his gospel account, Matthew is not offering a biography of Jesus, but a way of living for a new Israel, the Christian community, the church; he is presenting an ecclesiology, not a history. He is addressing a people in community, confirming a way of life. He is telling us that the beauty for which God created and intended the world must become part of our own life style and worldview.
Matthew is addressing a people in crisis. After the resurrection, an apocalyptic attitude sustained the Christian community. The early Christians believed Jesus would soon return. Yet Matthew believed and proclaimed otherwise: that the kingdom of heaven is already at hand, even now in our hands. God is already present in those who live a life of restoration and resurrection in Christ.
To help you appreciate how it is that Matthew could have an alternative vision, let me take an example from daily life. When we look at buildings, the untamed eye will observe bricks and mortar, wood and glass. An architect, however, will perceive beyond the surface appearance; an architect discerns harmony or pressure points. Yet another person will discern the beauty of the spiritual world, the presence or absence of God.
Matthew too is able to reveal a new understanding of our world, new -- and at the same time ever deepening -- perceptions of the presence of God in our lives. In the beginning, in the book and the event of Genesis, God saw chaos and darkness, and God cared enough about the world to place things in order, to render things beautiful. He created the cosmos. In Matthew's Genesis, God once again cared for and loved the world. The phrase "in the beginning" -- whether in the first book of the Old Testament or the first book of the New Testament -- is a symbol for whenever, signifying always. The term "whenever" implies the phrase "in the beginning." It also includes "every beginning." This reality teaches us to respond accordingly. Whenever we see any form of deviation, any deformation in nature, in life, or in the world, we too must care enough to respond; we too must love sufficiently to restore, to heal.
How does Matthew propose that we achieve this? Instead of searching for God in empty places, Matthew asked his community to return to and re-examine its roots. He begins his Gospel with three periods, three series of fourteen generations, in order to show how God's presence in this world, in history, has both roots and continuity. As Orthodox, we would adopt the term "tradition."
In the genealogy that is offered, Matthew is in fact very radical, hardly traditional -- he includes women, non-Jews and a foreigner. He could quite easily have included each of us.
God's kingdom is never reduced simply to a matter of rules and regulations. It is certainly not a reinforcement of worldly positions and secular institutions. God's kingdom is a reversal of attitudes, a metanoia, a conversion and reordering of values and behavior. It means becoming more and more a person who shares in the holiness, the beauty, and the perfection of God. It implies coming under the authority of God, rather than under the authority of this world. Living the Beatitudes signifies our acceptance of this new authority.
Matthew often uses the word "perfect." The Greek word for perfect (teleios) signifies reaching for a goal (telos). For Christians, this "end" is the kingdom of heaven. Therefore, Matthew is telling us that perfection is a process, a series of stages of progress. It is less a condition of perfection, than it is a potential or possibility. Think of the emphasis in St. Gregory of Nyssa on "never-ending perfection" (epektasis).
And in order to become perfect, Matthew tells us we must become poor. To become complete, he tells us we must surrender, we must be incomplete. If you want, "go sell all your possessions and give to the poor."
There is a cost involved here. The question is: How much have we sold? How much have you sold? How much have I sold? And are we in fact willing to give up and to give up everything? Are we prepared to sacrifices our preconceptions, our prestige, our positions, our possessions, our power?
Matthew is not romanticizing poverty. Sharing in the kingdom in fact depends on our effort to alleviate the various forms of poverty in the world. Poverty is not good; it is not blessed; it is not a virtue. Poverty is miserable; poverty is a clear indication that the kingdom of God has not yet come.
However, poverty can be voluntary, as with monastics. Voluntary poverty becomes a way of sharing with the poor, a means of giving up whatever gives us security. Indeed, such poverty is more than merely giving up. It is a way of giving! But so long as we justify our ways and our behavior, we shall not appreciate the need to change. We will not understand that everyone has a right to enough of the earth's resources: to sufficient water, energy, food, clothing, health, a safe environment, and peace.
If God's purpose is for us to be more and more, then we must admit that to have more than enough is to be less than human. It is to bear a lighter "footprint" on the world that we inhabit. In the Beatitudes, we learn that we must choose our gods; we cannot serve two masters. Remember, where your treasure is, there your heart is also. And our world offers us numerous temptations to find security in consumer goods.
"Blessed, then, are the poor in spirit." Blessed are those who submit to God, who put their trust in God, who have confidence in God, who are not controlled by their needs or by the demands of this world.
- trust that "our heavenly Father knows all that we need. Therefore, seek first the kingdom of God, and all these things will be given to [us] besides."
When we think of Jesus Christ, we imagine the healer, the one who overcomes brokenness and death, the Lord that assumed the scarred flesh and touched the shattered world. There is a softness of touch, almost a sense of joy, to this Beatitude. When Isaiah speaks of comfort, he says: "Give them oil of gladness in place of mourning" (61: 3). There is an entire literature and theology of tears in early ascetic writers.
Mourning and tears continually touch every level of our life. And Jesus brings healing to all levels of life. Yet comfort is not tantamount to relaxation; it is again a form of restoration. It is in fact a challenge.
How is healing brought to those who suffer, or comfort to those who mourn? First, Jesus notices the brokenness, cares for the broken, and responds to the broken. Second, all the healing miracles of Christ have to do with overcoming individualism, with breaking open the closedness within us and around us: the deaf person is shut off; the dumb person cannot communicate; the paralytic cannot step beyond himself; the leper is isolated, ostracized from the community; the demonized man is possessed, imprisoned.
And how does Jesus heal these people? To the deaf, he says: "effatha" (be opened). To the dumb person, he says: "speak." To the paralytic, he says: "take up your bed, and walk." To the leper, he says: "be cleaned." To the demonized man, he says: "be healed, go to the rest of the community, and show yourself."
These miracles offer us an insight into the healing and wholeness of the kingdom. Henceforth, if we wish to live by the Beatitudes, we can no longer remain deaf to the cry of those who suffer, or to an environment that groans.
And so we mourn. We mourn because we have betrayed our call to be faithful to God's plan and authority. We grieve and admit our sins -- sins of envy, greed, gluttony, jealousy and aggression -- against our neighbor and against the earth. We recognize of course that such external "sins" are only symptoms of our inner disease. However, by recognizing our own brokenness, we are forgiven and comforted. Then, and only then, are we given the power to heal.
It is significant that Matthew's Gospel shows that Christ's disciples were given the power to heal as early as in chapter 10. It is not until much later, in the final chapter 28 -- and in the very last verse of that chapter -- that they were also given the power to teach! The message is simple: when we are in pain, we do not easily receive or give teaching. When our community or our environment is broken, mere words about the beauty of nature will not go a long way in restoring the suffering that we have inflicted upon it.
There is a further dimension to our mourning. Mourning is a condition, not just a singular event. Standing before society's unwillingness to change, even Jesus is brought to tears. Sometimes even our wrongful ideologies, our misguided values are reinforced by established religion and the institutional church. One of the shortest and most powerful verses in the Bible is: "Jesus wept." Yet this verse is also a symbol of comfort and sweetness to a broken people.
Finally, in relation to the natural environment, the Book of Hosea tells us that even "the land itself mourns, and everything that dwells in it languishes [i.e., sheds tears]" (Hos. 4: 1).
Matthew wrote of birds in the sky; today, oil slicks wash them ashore. Grass in the fields brought joy in the times of Christ's disciples; today, toxic chemicals and warfare leave the land barren. Jesus assumed that foxes had homes; today, we cannot assume that foxes will survive. Jesus multiplied loaves and fishes; today, 800 million are severely undernourished.
Extending our care and concern to people and to inanimate creation brings good news to the whole world. One teardrop of mourning for our way of life can water the whole world.
As the King of heaven and earth, Christ comes not with violence but in meekness. He will inherit the earth and all its power, all its positions, all its prestige. Matthew reassures us that God is found at the very center of the world, with us in all generations. And this King comes to assume authority over all of creation, to reorder all creation from chaos into cosmos -- an allusion to the events recorded in the first Genesis.
The average Jew during the life of Christ, and the average Christian disciple of Christ, had one of two ways of responding to Jesus: either with meekness or violence; either through peace or indignation. The way in which we receive Christ is reflected in the way in which we regard the earth or the land.
God and land, divine Word and created world must be integrated. The spiritual life brings God, the land, and the people together in a balance and integrated order.
This means that the land or the earth must never become an end in itself. God is always the source of all worldly resources. Israel laid aside a weekly day of rest in order to remember this, to reflect on where our treasure is. Worshiping the created land, venerating any false god, is a form of idolatry. Yet on the other hand, Worshiping God without assuming responsibility for the land is a dangerous and misleading form of spiritualism.
We may, for instance, pray for the environment, imploring God to do something about the crisis that we confront, yet never changing our lifestyle, which may well be reinforcing the problem. Matthew's Christ warns us: "None of those who cry out: 'Lord, Lord,' will enter the kingdom but only the one who does the will of my Father" (7: 21).
Or else we may be activists who leave little or no room for prayer. Our lamps should not go out because of our failure to wait for God (25:1-3) in silence. Prayer is not a pretext for the evasion of responsibility. Prayer and action are equal dimensions of spirituality. We must understand how Jesus was as authentic when He healed the sick, as when He withdrew to be alone with God.
Our society, however, promotes a mentality that exalts the acquisition of material possessions. Once we are in "the land," it is difficult to "seek first the kingdom of God." It is easy to forget that this earth is inherited -- it is received; it is not taken, or snatched. It is never ours to own, but only God's to give.
Therefore, the land and its wealth must be oriented to others in order to promote God's kingdom, reordering the priorities of this world. Meekness is the blessed way of dealing justly with the land. The meek person reflects a reversal of attitudes toward power, possessions and positions. Otherwise, the land becomes a territory of violence, a domain of division, a realm of mistrust.
Meekness is a way of caring. It should touch every aspect of our lives. It should teach us that God is God, that we are God's, and that the land is God's. Thus, the land is ours only to use and share responsibly. Meekness is a blessed correction, a heavenly contrast to the violence which we have wrought upon the earth, a stark opposition to the desecration of God's plan for creation.
This Beatitude introduces the fundamental theme of justice in relation to the environment and the spiritual life. "The Lord is our justice," says the Prophet Jeremiah (Jer. 23: 5-6). And when we thirst for justice, we know that we shall be filled. "As the earth brings forth its plants ... so will the Lord God make justice" (Is. 61: 3-4, 10-11).
Hunger and thirst lead to dependence on God. And God promises that there will always be enough for all. That is justice; that is fairness; that is righteousness. However, like Israel in the Old Testament, we want more than enough, more than our share, more than what is just and fair. We lose our conviction and confidence that God will "give us our daily bread." God responds to our need, and asks in return that we do not store up treasure on earth, that we do not live in excess, so that others too may have enough. We are to seek to have only just enough, in order to be more and more.
When Matthew speaks of the kingdom, he speaks of justice (dikaiosyne). Matthew uses this word seven times in his Gospel. The opposite of justice, for Matthew, is not injustice; it is hypocrisy. Justice creates community; hypocrisy destroys commonality. Justice creates cosmos (beauty); hypocrisy creates chaos. Justice means sharing; hypocrisy signifies concealing and keeping. The ultimate test of our justice is to ask ourselves whether we continue our acts of piety when no one is watching.
Almsgiving: Almsgiving is not simply a matter of feeling. Almsgiving means responsibility. And almsgiving is not an optional virtue. Giving all that is in excess is naturally expected of everyone.
Prayer: In the Gospel of Matthew, Jesus teaches us that when we pray we must (a) not talk too much; and (b) learn to forgive. Yet when we look honestly at our life of prayer, we have to admit that we do tend to talk too much. Prayer must heal divisions, not harbor anger or resentment. "Forgive us ... as we forgive others," we pray in the Lord's Prayer. If we are not striving to create heaven on earth, then perhaps we should stop praying the Lord's Prayer. Our actions and our lifestyle will show whether we mean what we pray ("your kingdom come ... on earth as it is in heaven"), or whether we are merely talking too much.
Fasting: We fast in order to remember the kingdom. We fast in order to commit ourselves to the priorities and the ways of the kingdom. We fast in order to practice offering our resources to the poor and sharing our possessions with our neighbor. Fasting helps shape a vision whereby we can view the world with God's eyes. It clarifies the purpose and sharpens the focus, so that our view and our worldview is larger than ourselves.
"This is the fasting that I desire: releasing those bound unjustly ... setting free the oppressed .... sharing your bread with the hungry, sheltering the oppressed and the homeless, clothing the naked ... satisfying the afflicted .... Then the Lord will guide you always and give you plenty .... You will be like a watered garden, like a spring whose water never fails .... 'Repairer of the breach,' they shall call you" (Isaiah 58: 6-12).
Fasting reminds us of the hunger in the world. The degree to which we resist fasting may reflect the degree to which we contribute to hunger.
[The merciful heart] is a heart that burns out of compassion for birds, beasts, human beings, even demons. ... Such a heart cannot bear to hear of the slightest pain suffered anywhere in creation.
Blessedness, then, means showing mercy. Indeed, the perfection of God and the kingdom of God are almost synonymous with the quality of mercy. Mercy is a sign of God's kingdom. This is why we repeat "Lord, have mercy" in our liturgy. We are asking God to be who He is in spite of who we are. We may think here of the parable of the king who forgave the large debt. When the official refused to show a similar compassion to the servant, the forgiving king was angered. Sadly, while the mercy of the master changes the situation of the official, it does not convert his heart.
A Christian cannot win God's mercy. But a Christian can lose God's mercy by not extending it to others and to the environment.
At the same time, God's mercy is also passionate, full of "pathos" (or passion). If we do not show mercy, if we are a-pathetic, if we do not care, if we are indifferent to the cry of the earth, if we remain neutral in the face of injustice: then we do not reflect God's image, we are not revealing God's kingdom.
There are no excuses for our un-involvement. We have the information. Anyway, we are deeply -- innately and inevitably -- involved in one way or another. We must choose to care. Otherwise, we are not being fair; we are not acting in a just manner. Otherwise, we are being hypocritical, self-righteous, and certainly not righteous.
Let us consider one example of such mercy from the life of Christ. In the miracle of the feeding of the multitudes, the Lord encourages the disciples to act for their environment: "There is no need for them to disperse. Give them something to eat yourselves." (Mt 14: 16) "Use your own resources" is what He is telling them. The disciples response reflects ours: "We have nothing here."
What they are saying is that we have only limited resources. Yet it is the willingness to share that transforms what looks like very little in the eyes of the world into what is more than sufficient. We shall never give people enough to eat. But we must give them from our table.
How many people sit at our table? What kind of people do we invite to sit with us at our table? How many issues do we ignore at the table of our life? How significant -- or just how subtle -- is our attitude of prejudice?
Seeing God's face depends on purity of heart, a purity requiring total commitment to God's kingdom, an inner attitude of wholeheartedness. Our external actions indicate our internal priorities. "Where our treasure is, there our heart is also."
Purity of heart is achieved through purification, through asceticism. By asceticism, I mean learning what really matters, not being controlled by the cares of this world, not remaining on the surface level of life, not seeking instant results, not avoiding painful struggle. Asceticism is learning what to care for, and when not to care; when to be involved, and when not to interfere; it is taking the time and making the space to be still in order to "hear" God. Then our heart becomes pure; then we become better disposed to "see" God.
So purity of heart implies a process of stripping the surface. It is an invitation to greater depth. It is making choices about things, about people, about God. Then we value and desire not what we want, but what we need; and gradually we come to value and desire only what God wants. We begin to understand what blocks our vision of God, what separates us from God. We learn to see the world with new eyes. We hear God's silent words in creation. The very same things appear renewed, "a new heaven and a new earth."
At this point, it is very much like being in a guest-room by ourselves only to sense that we are in another person's presence. There, in our heart, we discover ourselves in relation to God; but there too we discover ourselves in communion with the entire world. Then we see Christ everywhere. And therefore -- as Fr. Alexander Schmemann liked to say -- we can only rejoice. For we have direct and intimate access to the face of God, to the ear of God, to the word of God.
And because we live -- or at least strive, desire to live -- in purity of heart, we can actually see God. And our prayer for purity becomes simply: Lord Jesus Christ, Son of God, have mercy on me and on your world.
Christ is the Son of God because He is in full communion with the nature of God; because He is fully committed to the will of God.
Full communion means sharing in all His resources. Full commitment to the Beatitudes signifies a reflection of God's unity, of divine peace, life, and justice. Even though Christ's communion and commitment lead Him to the cross and to death, nevertheless He remained surrendered to God's purpose, irrespective of whether this meant standing in direct contrast, indeed in contradiction to the way society understood peace and justice.
So perhaps it is important to stop measuring progress or success in the way society regards these. The criterion for success cannot be defined in quantitative terms. For Christ, the end was the cross; for John the Baptist, the end was his beheading.
Now, the emphasis on becoming children underlines another point. Peacemaking means building community; and community begins by realizing and respecting the dignity of each person. Each member of the community is precious in the eyes of God. Therefore, when Christ was asked about greatness, He called a young child over, stood it in the midst of those who were gathered, and said: "I assure you, unless you change [literally, repent] and become like little children, you will not enter the kingdom of God" (18: 2-3).
This was a radical, not a sentimental gesture. At the time of Jesus, children were denied human rights. They had no access to necessary resources for basic survival. By their age, as well as by law, they were segregated from the rest of society. In order then to be a "peacemaker," in order to be called a "child of God," we are to give way -- to defer -- to others, out of reverence for the rights of others. We must recognize that all people require the resources of this world.
It is in this light that we are invited to become peacemakers. This also means that making peace is work. It is in fact very difficult work. Yet it is our only hope for the restoration of a broken world. By working for peace, by working to heal the environment, by removing obstacles for peace, by avoiding what harms the environment, we may -- at least, this is what we are assured -- hear a voice in our heart that says: "This is my beloved. In my beloved -- and him, in her, in you -- I am well pleased." What greater joy, what richer blessing, what more abundant grace can there be than this?
Matthew wished to reassure his community about two things: first, if they lived by the Beatitudes, according to His name, then they should expect rejection; and second, if they were persecuted, this would be a sign that they were truly faithful.
This last Beatitude, like the first, is a reassurance that the kingdom of God can be immediately expected.
In response, the Christians become a "remnant" community, a small flock, the leaven. They can begin a new process of hope in a world unwilling to receive the kingdom. Yet they are not afraid; they are not alone. They may rejoice, for He has overcome the world. Fear gives way to faith in God's promise: "the kingdom of God is theirs." Indeed, it is ours.
Yet Matthew placed this Beatitude last in order to indicate something more powerful than this. This Beatitude is more than a mere conclusion. It is a clear commission, an explicit command for the disciples to enter the world of their day, to assume the problems of their time, to bring God's care into the world -- no matter what the cost, irrespective of the risk or the pain. That's why the Lord continues the Beatitude by changing to the second person: "Blessed are those who are persecuted.... Blessed are you when ... they persecute you .... Be glad and rejoice, for your reward is great in heaven."
The Beatitude now becomes a direct invitation, a personal blessing, a definite assurance and promise. And Christ later continues: "You are the salt of the earth .... You are the light of the world" (5: 13-15).
Matthew's new Genesis returns to an echo of the creation story, closing with a reminder about the first Genesis when God created the world; "and behold it was good," indeed "very good."
Fr. John Chryssavgis studied theology in Athens and Oxford. He has been professor of theology at St. Andrew's Theological College in Sydney and at Holy Cross School of Theology in Boston. He serves as theological advisor to the Ecumenical Patriarch on environmental issues. His recent books include Soul Mending: The Art of Spiritual Direction, In the Heart of the Desert: The Spirituality of the Desert Fathers and Mothers, and Cosmic Grace, Humble prayer: ecological initiatives of Ecumenical Patriarch Bartholomew. His text on the Beatitudes was the keynote address at the Orthodox Peace Fellowship conference at St. Tikhon's Monastery in June.
Reprinted from In Communion, Quarterly journal of the Orthodox Peace Fellowship, Spring-Summer 2003 / issue 30. Copyright by the author.


text:
Vietnam Approves Labor Code for 2021
December 10, 2019 Posted by Vietnam Briefing Written by Dezan Shira & Associates	Reading Time: 3 minutes
Vietnam's National Assembly approved a new Labor Code which will take effect in January 2021.
The amended code offers greater protection for employees and is viewed as better aligned with international best practices.
Businesses should review their labor practices and prepare themselves to be compliant when the labor code takes effect.
Vietnam has approved an amended Labor Code which will come into effect in January 2021. The amendment to the labor regulations are a step towards aligning with international labor standards particularly as Vietnam integrates into the world economy as noted by the International Labor Organization (ILO).
Most of the code remains the same however, changes have been introduced to probationary employment, mandatory work rules, notice requirements, and other provisions generally suited to employees.
We look at key aspects of the new code.
Key provisions of the labor code
Working hours: While the working hour limit remains the same as 48 hours per week, the new code states that normal working hours cannot exceed eight hours a day or 48 hours per week. However, if the employer and employee agree on an overtime deal, the overtime cannot exceed 12 hours a day, 40 hours a month and 200 hours a year. For industries such as textile and clothing, footwear and electronics in which seasonal orders during certain times of the year require an extensive workload, an overtime cap of 300 hours has been specified.
Labor contracts: The amended labor code now lists only two types of labor contracts as compared to three earlier. Definite-term contracts, which cannot have a term longer than three years, and indefinite-term contracts. The definite contract can only be renewed once. Foreigners who have work permits (valid for two years) will also be able to renew only once. Seasonal contracts will no longer be permitted from 2021.
We can help you become labor complaint in 2021
Termination: In a boost to employees, employees will be able to immediately terminate a contract for mistreatment, pregnancy and if the employer fails to pay salary on time. As per the current labor policy employees are subject to minimum notice requirements (30 days for definite term, 45 days for indefinite term).
Unions: Vietnam will now allow independent trade unions to operate as opposed to currently being supervised by the state-run Vietnam General Confederation of Labor (VGCL). The independent union will still be required to get permission from state authorities to operate. This is partly seen as Vietnam enters into free trade agreements which require the opening of trade union rights. Nevertheless, further guidance will be required on how this will happen practically.
Retirement age: Vietnam will also increase the retirement age for men to 62 from the current 60 and increase the same for women to 55 from the current 50. However, workers may retire later or sooner depending on the situation. For example, employees working in dangerous environments or involved in heavy lifting can retire sooner, while those who work in the private sector or in high skilled jobs can retire later. The maximum extension for this will be five years. However, the increase in retirement age will be done gradually for men and women by 2028 and 2035 respectively. The increase in retirement has been done to avoid a labor shortage from 2040 and to address social insurance deficits.
Discrimination: The new code has safeguards protecting employees from discrimination at the workplace. This includes protection from sexual harassment and discrimination based on skin color, race, nationality, ethnic group, gender, marital status, pregnancy, political views, disability, HIV status or if in a trade group. The amended labor code also enhances protections for younger workers.
In addition, the government will not regulate salary policies at individual companies that are negotiated between the employer and employees, however, rules on minimum wages must be followed.
Employees will also be entitled to an additional day off either preceding or after September 2 – the Vietnamese National Day.
The amended labor code will help Vietnam match international standards as it becomes a part of several free trade agreements including the European Vietnam Free Trade Agreement (EVFTA) and the Comprehensive and Progressive Agreement for Trans-Pacific Partnership (CPTPP).
The new code will have an impact on businesses and employers should seek to obtain assistance with regards to their labor practices to ensure their policies are legally compliant in 2021.
Vietnam Briefing is produced by Dezan Shira & Associates. The firm assists foreign investors throughout Asia from offices across the world, including in Hanoi and Ho Chi Minh City. Readers may write to vietnam@dezshira.com for more support on doing business in Vietnam.
« Vietnam to Increase Minimum Wage from January 2020
Vietnam's Public Holidays in 2020 »
An Introduction to Doing Business in Vietnam 2018-19
An Introduction to Doing Business in Vietnam 2018-19 will provide readers with an overview of the fundamentals...

redpajama_set_name: RedPajamaCommonCrawl


Q: What's on the table with North Korea, & what isn't?
FLAKE: A lot of us have been skeptical that North Korea will ever agree to total denuclearization. They believe they're in the position as a nuclear peer with us because of their nuclear weapons. But a freeze would be better than we've had before. So, there's nothing wrong with saying, "Hey, they may not denuclearize, but we could have a better situation than we currently have."


text:
import store from "../../store";
import { loader } from "../../store/Loader/LoaderAction";
import Auth from "../../utils/Auth";

export const isHandlerEnabled = (config = {}) => {
  return config.hasOwnProperty("handlerEnabled") && !config.handlerEnabled
    ? false
    : true;
};

export const requestHandler = request => {
  if (isHandlerEnabled(request)) {
   // Modify request here
    store.dispatch(loader(true));
  }
  return request;
};

export const successHandler = response => {
  if (isHandlerEnabled(response)) {
    // Hanlde Response
    store.dispatch(loader(false));
  }
  return response;
};

export const errorHandler = error => {
  if (isHandlerEnabled(error.config)) {
    store.dispatch(loader(false));
    // You can decide what you need to do to handle errors.
    // here's example for unautherized user to log them out .
    // error.response.status === 401 && Auth.signOut();
  }
  return Promise.reject({ ...error });
};


text:
Home›Latest›Capitol Studios Hosts Orchestra Sessions for Oscars for 20th Straight Year
Capitol Studios Hosts Orchestra Sessions for Oscars for 20th Straight Year
Latest, More Industry News
Capitol Studios, the iconic and state-of-the-art recording facility located in the historic Capitol Tower in Hollywood, California, recently hosted orchestral recording and rehearsal sessions for the 90th Oscars® – marking the 20th anniversary of Capitol Studios being used as the site for such sessions. Joining the 43-piece orchestra and 41-voice choir were technical personnel including Tommy Vicari (recording & mixing engineer), Steve Genewick (assistant recording engineer), Dan Vicari (orchestra setup), Larry Mar (Pro Tools engineer), Chandler Harrod (assistant recording engineer), Howard Wheeler (music director) and Ashley Irwin (music arranger and sound consultant). Sessions took place in the combined Capitol Studios A and B.
Vicari and Genewick note, "As has been done in many previous years, we assembled the orchestra at Capitol Studio A and B to do a number of tasks. Obviously, there is a live orchestra at the ceremony itself, but for logistical reasons, certain passages need to be pre-recorded, including occasional pieces that must be married to a video package, so we went through each of those musical segments and recorded them with great efficiency. We also use the time at Capitol Studios to rehearse all the live music for the show and make reference recordings, in order that stage blocking and choreography can rehearse to the final arrangements. We also let any artists who are scheduled to perform on the show lay down a guide vocal for these same reasons – although the vocals on the show are always live."
"It's often a 60-to-65-piece orchestra, but this year's had a smaller orchestra but a full chorus," stated Genewick. "Our setup is pretty big – each member of the rhythm section, as well as the conductor, gets a personal mixer for a custom headphone mix. Each section of the orchestra also gets a separate headphone mix, either mono or stereo. All of these mixes are generated from a separate Pro Tools rig in the control room. Typically we record about 85-90 tracks of audio into Pro Tools, and all of those channels get mixed on Studio A's Neve 88RS console."
Vicari and Genewick, who have been involved for 19 of the 20 Capitol Studios Oscar sessions, reflect on how things have changed over the past two decades. Genewick notes, "Things have evolved quite a bit, mostly in the control room: Tommy and I decided to move from analog tape to digital tape to Pro Tools, and the format of the show has changed up a little bit so pre-records and video elements are a bigger part of the soundtrack. There were two years in there where we did the music live from Capitol Studios during the ceremony, which was a blast but quite a challenge, as we had to incorporate fiber lines to and from the Dolby Theatre down the street."
Tommy Vicari noted, "When using composed material from the year's film scores, obviously we don't have access to a larger orchestra to replicate the orchestras used on the original sound tracks, so we try to recreate it with a smaller ensemble. Because the setup has evolved over the past 20 years, we are able to make our orchestra sound larger than it really is. We also pivot from popular music to classical to big band, as well as atmospheric-type scores, so we need to be able to turn on a dime, according to what the original movie called for. Fortunately, our amazing Capitol Studios crew allows us to rehearse and record an enormous amount of music, in a very short amount of time -- basically four three-hour sessions in total."
"The annual sessions for the Oscars are a yearly highlight for us here at Capitol Studios," stated Paula Salvatore, VP/Studio Manager, Capitol Studios, "Studio A is one of the great spaces to record an orchestra, so it's great to use it for its full potential in dynamic, intense sessions. 20 years has flown by, and we thank all the engineers, technical personnel and musicians for their professionalism and passion."
For more information, please visit capitolstudios.com.
Tagscapitol studiosmusicOscars
Make Music Day Returns on Thursday, June ...
Focusrite Announces New Plug-in Collective Featuring Sound ...
Up Close: Yamaha Guitars
Close Up, Latest, Magazine
Guitar & Bass Jam 2015
Feature Articles, Magazine
The HeadRush Pedalboard: A Groundbreaking Guitar Effects Processor
Feature Articles, Latest, Magazine


"Being Ms. Moschetto's client meant knowing that I was not in this alone. I felt enormously comforted by her extensive knowledge, guidance, and support, ensuring the best possible outcome. Marijean and her staff truly cared about me, my daughter, and our well-being. "


text:
Home Interviews Architect Stephen Kieran, FAIA, LEED Fellow
Stephen Kieran, FAIA, LEED Fellow
Brainard Carey
US Embassy, Nine Elms, London
https://yourartmentor.com/interview/stevenkiernan.mp3
Subscribe: Apple Podcasts | Android | Google Podcasts | RSS | Click here to join mailing list
Stephen Kieran is a partner at KieranTimberlake, an award-winning architecture firm established in 1984 and a leader in practice-based architectural research and innovative buildings. He received a Bachelor of Art from Yale University, a Master of Architecture from the University of Pennsylvania, and is a Fellow of the American Academy in Rome, 1980-81. He has co-authored six books on architecture, including the influential book, refabricating Architecture. In addition to his architectural practice, Stephen has held professorships at University of Pennsylvania, University of Washington, Yale University, University of Michigan, and Princeton University.
Cellophane House™ is five-story, fully recyclable, and transparent dwelling assembled in just two weeks on a site in midtown Manhattan. © Peter Aaron/OTTO
The US Embassy in London encompasses the democratic ideals of transparency, openness, and equality. © Richard Bryant/Arcaidimages.com
KieranTimberlake
Previous articleXavier de Luca
Next articleSaskia Sassen
Billie Tsien
Brent Budsberg
Max Strang


Joe Cook and Nolan Manson were a pleasure to work with. They were prompt, efficient, and thorough. Thanks!
Great- on time and professional. Excellent outcome.
Nick Roberson is very courteous and professional. Jason Autry and his crew were very good and Jason was very professional answering all my questions.
We not only adhere to the highest industry standards, we strive to be the industry leader in the home improvement related services we provide. We also use state-of-the-art products and technology which are designed to fix your home. We are the authorized Basement Systems dealer in Senatobia, MS.
Mark D. had noticed that the crawl space in his home was moist and he was worried that the moisture would affect his home. Redeemers Group came in and offered Mark and his family a great solution to their crawl space issues.
One of the main components of the crawl space solution included the installation of the SumerSump® sump pump and the CleanSpace® System. Both systems are essential to keeping any basement or crawlspace dry. The SuperSump® pump system is specifically designed to handle the amount of water that a basement collects during heavy rains. It can pump 2220 gallons per hour at an 8-foot discharge head quietly and efficiently.
We are glad that we could help Mark D. enjoy a dry, healthy crawl space. Redeemers Group is pleased that we could solve Mark's crawl space problems in Senatobia, MS.


Use this form for assitance with your entry, or to find out more about the competition, or for sponsorship enquiries.
Alternatively call us now on 0121 237 1107 or contact us by email info@btaa.org.uk.
The British Travelgoods, Handbags & Accessories Association is part of the British Allied Trades Federation, which is a company limited by guarantee and registered in England and Wales, number 69391. The registered office is Federation House, 10 Vyse Street, Birmingham B18 6LT.


: Koller, S.; Mayrhofer, L.; Grifoni, M.
epl. A letters journal exploring the frontiers of physics 88 (2009), Nr.5, Art. 57001, 6 S.
We present a microscopic theory for interacting graphene armchair nanoribbon quantum dots. Long range interaction processes are responsible for Coulomb blockade and spin-charge separation. Short range ones, arising from the underlying honeycomb lattice of graphene, smear the spin-charge separation and induce exchange correlations between bulk electrons - delocalized on the ribbon - and single electrons localized at the two ends. As a consequence, entangled end-bulk states where the bulk spin is no longer a conserved quantity occur. Entanglement's signature is the occurrence of negative differential conductance effects in a fully symmetric set-up due to symmetry-forbidden transitions.


text:
using System.IO;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;

namespace OrchardCore.Deployment.Core.Mvc
{
    public class DeleteFileResultFilter : ResultFilterAttribute
    {
        public override void OnResultExecuted(ResultExecutedContext context)
        {
            var result = context.Result as PhysicalFileResult;

            if (result == null)
            {
                return;
            }

            var fileInfo = new FileInfo(result.FileName);

            if (fileInfo.Exists)
            {
                fileInfo.Delete();
            }
        }
    }
}


For those of you who are interested in getting the free upgrade to Windows 10 keep in mind that at this point Microsoft is giving a deadline of July 29, 2016.
Windows 7 and Windows 8 users who see the pop up at the bottom right of their screens and it indicates that you are eligible for it.
Pieri from PC Computing suggest, if you have Windows 7 and are eligible and your computer is less than 4 years old you may take advantage of it. Keep in mind there "may" be some programs that may not be compatible. If your Windows 7 pc is older it may still work but you might notice it will be very slow and sluggish—so you decide if you wish to try it or not. Windows 8 and 8.1 users should take advantage of the upgrade to Windows 10. Windows 7 users: if you decide not to upgrade that is also ok –it is not mandatory.
If you end up not liking Windows 10 you have a 30-day window to revert back to your previous operating system.
Can you do the upgrade yourself?
Back up your data —just in case.
Scan your system to ensure you don't have any spyware or viruses.
Make sure your PC has all the windows updates and is up to date.
Give yourself a good 2-3 hours for this entire process.
The computer will restart several times until it is finally completed. In some cases if the printer is too old (5+ yrs) the printer will no longer work. In other cases you may need to reinstall the printer driver for it to work in Windows 10. You can go to the manufacturer's website to download the printer from there..because your printer CD won't work.
If all this sounds like too much of a hassle and you don't want to take a chance. Contact PC Computing and Pieri will do it for you.
There's More to Mold than Just the Spore!
Mold can emit a fungal gas! When particular molds colonize and they progress through their life cycle, they emit a gas (musty smell). As the reservoir of fungus grows to several billion spores in the colony, our noses detect the smell of these fungal gases.
When a closed indoor environment continues to fill with the mycotoxic gases, they can become a health risk. The affect it has on the human body is dependent on three variables. Our individual immune systems, the type of spore, and the volume of fungal gas determines the impact on our bodies. Additionally, the longer the exposure to these gases, the greater the likelihood we will develop a sensitivity. Much like other environmental allergens we are exposed to, the longer the exposure, the greater the chance our bodies will have an adverse reaction.
Some health effects include headaches, shortness of breath, dizziness, lethargy, fever, and digestive problems. More severe reactions are hypersensitivity and asthma symptoms. Although rare, certain Aspergillus species release aflatoxins that are carcinogenic.
There are many things in life we cannot control, but exposure to fungal gases is not one of them. With a little effort, we can reduce or eliminate this health hazard by using a disinfectant or removing the affected material. In some instances, it may be necessary to seek a professional opinion or get professional help.
Mr. Drenik is the president of MicroArmor, Inc. He has performed thousands of mold tests over the last 20 years and completed over 3,000 mold remediation products. Call 440.946.5578.


Across the street from our old office was a local Japanese restaurant that served yummy Curry Omuraisu. A large omelette stuffed with chicken curry rice, I loved how each bite was full of meaty curry goodness. It's been months since I last had it though since we moved offices, so when I realized we still had leftover Japanese curry, I decided to give it a go.
My version of curry omuraisu was simple enough. I simply went through the motions of making fried rice, only, I added dollops of leftover curry sauce to it. I would've loved to use actual curry, but I finished all the pork and veggies the night before so I had to settle for curry sauce. Still, I figured it would be all right if I'd have a side of meat and veggies with it.
1. Beat two eggs. Add salt and pepper to taste.
2. On a wide, non-stick pan, add oil. When hot, pour your beaten eggs, making sure to spread the egg thin and wide.
3. When one side is done, flip. When cooked, slide unto a plate.
4. Add your rice to the slightly greased pan. Saute to heat evenly.
5. Add as much sauce as you desire. The texture you want is slightly wet and sticky, but not dripping with liquid. Continue sautéing.
6. Spoon your rice on your thin omelette, keeping them together in a long cylinder.
7. Using a spoon, spatula, or your hands and some cling wrap, fold the two ends of the omelette, wrapping the rice.
8. Serve upturned, with the flaps underneath.
I saw someone cook Omuraisu on a J-drama once (I think Kimura Takuya's Hero) and the cook was so good. She actually managed to do the wrap thing simply by tapping the frying pan! She did little taps to the pan handle and sure enough, the omuraisu would flip over little by little, encasing the rice. I don't think I can manage to do that, hence this mock preparation, but as long as we get to eat afterwards, it's all right, I guess?
To go with it, I did an experimental salt and pepper beef stir-fry. Very easy to do so it's perfect for the morning rush. For my veggie component, I steamed some carrots and green beans in a microwave steamer—the kind you buy for 88 Pesos at Japan Home Center. Very useful for quick bento prep. A full meal in 20 minutes or so and a cure for Curry Omuraisu cravings. Not as satisfying as that resto's, but for a quick fix, it sure hits the spot.
1. Cut the steak into strips.
2. Sprinkle with some salt and lots of crushed pepper.
3. Stir-fry in butter until brown and slightly crisp on the sides.
I must make this again!
Also, I just wanna give a shout that I discovered a Japanese grocery at Greenhills, beside UCC. They sell the usual stuff, and not-so-usual stuff including ramune!
You didn't mention how wonderful the food starts to smell once you mix the curry sauce with the rice. I really had to restrain myself from eating everything right then!
Thanks Sunya! I agree with you too, there's something about the heady smell of curry cooking in the kitchen that leaves me drooling with anticipation.
I don't really worry about the egg spoiling as it's fried. Plus, since we're in a tropical country, the heat here is awful so I imagine food spoils here easier. I've never had a bento go bad on me yet so I guess as long as you avoid anything that spoils quickly and keep contaminants away, you'd be safe.


Daniel Oshiorenoya Yerimah better known as Deewyne is a Nigerian contemporary christian recording artist,singer,songwriter and performer from Edo state, Nigeria. Music started for him at an early age while learning how to play the drum from his mother and joining an acappela group(The Ordained Voices). He coordinated a mass choir for five years hosting five successful national conventions and featured among a group of five amazing vocalist that took gospel music to a new height both in the campus and state at large winning several awards.
Solo career kicked off 2007 and in 2008 he won the star road quest competition.His unique vocal dexterity and delivery makes him fit into different genres of music and has performed alongside major acts like kcee, jesse jags,brymo and samsong.
He describes his music as an embodiment of hope, joy, and the love of GOD in double.